Vibe coding with Claude Code course Β· Module 13: Twitch clone
An Agent on the CI Deck: @claude in a Pull Request
In this lesson7
The CI from the previous lesson tells you that something is wrong, but it fixes nothing. The bosun leaves a comment in a pull request, "add a character counter under the chat field", and you stand on shore without a laptop, with only your phone. In this lesson you give Claude a place on the CI deck. Claude Code GitHub Actions is the official action anthropics/claude-code-action@v1, which runs Claude Code in a workflow, on a GitHub machine. You write @claude and a request in a comment, and Claude reads the code, makes changes and pushes commits. For the first time the agent works without you at the keyboard, so permissions, secrets and costs weigh more than in any previous lesson.
What you will learn
- connect the action with the
/install-github-appcommand and read the workflow it adds; - tell interactive mode, which waits for
@claude, from automation mode with apromptfield; - order a change with a comment and review the diff before you merge it;
- limit who calls the agent, how many turns it takes and where the secret lives.
Installation: /install-github-app
The Claude Code documentation describes a quick road and a manual one. The quick one is a single command in a session, but it has three conditions: a repository on github.com, the gh from lesson 1_5 installed and logged in, and admin rights to the repository. In your clone's repository you have them. In the project folder run claude and type the command:
/install-github-appThe wizard leads you through three steps. First it installs the Claude app on GitHub. You give consent in the browser, and the documentation warns that the app asks for a broader set of permissions, because it serves several Claude features, and that GitHub does not allow accepting only some of them. Then the wizard saves the secret. When Claude Code already has an API key, it uses it; otherwise you choose a long-lived token of your subscription or an API key from the Claude Console. The wizard saves it as a repository secret named CLAUDE_CODE_OAUTH_TOKEN or ANTHROPIC_API_KEY. At the end it pushes a branch with the workflow files and opens in the browser a pull request ready to be created. The Esc key interrupts the wizard: the step in progress finishes, the next one does not start.
A word about the account. A subscription token can also be created by hand with the command claude setup-token, and runs with it use your subscription instead of paid API tokens. The documentation adds that such a token is tied to the subscription of the person who generated it, so for a secret shared in an organisation it recommends an API key from the Claude Console. An agent run automatically is a different way of using a plan than a conversation at the desk: check the terms of your plan before you build an automation on it.
What the wizard added
Before you merge the wizard's pull request, read the file. On GitHub open the Files changed tab, and in Cursor ask Claude to fetch the wizard's branch and switch to it, then open .github/workflows/claude.yml. The documentation shows an interactive mode example like this one, and your file may differ in details. First the triggers:
name: Claude Code
on:
issue_comment:
types: [created]
pull_request_review_comment:
types: [created]
jobs:
claude:
if: contains(github.event.comment.body, '@claude')
runs-on: ubuntu-latestYou know on from lesson 12_5, only the events are different: a new comment in an issue or in a pull request, and a new comment on a line of code in a review. if checks whether the comment contains @claude; if not, the machine does not start at all and uses no minutes. The action checks the word once more by itself, and the documentation notes that it must be the whole word @claude, so @claude-bot or /claude will not work. Next come the permissions and the steps:
permissions:
contents: write
pull-requests: write
issues: write
id-token: write
actions: read
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 1
- uses: anthropics/claude-code-action@v1
with:
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}Here permissions is broader than in CI, because Claude is meant to write: contents: write lets it push commits, and pull-requests and issues let it answer in comments. The documentation calls id-token: write required for the action's default login as the Claude app, and actions: read lets Claude read CI results in the pull request. fetch-depth: 1 fetches only the last commit. If you chose a subscription token, the last line reads claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}. The checkout version in the example may be older than the one in your ci.yml; ask Claude to make both files use the same one.
Without prompt it waits, with prompt it starts by itself
The action step has no prompt field. According to the documentation that is interactive mode: Claude waits for @claude in a comment, in a review or in a new issue, and shows progress and the result in a comment under that issue or pull request. When the workflow has a prompt field, the action switches to automation mode: it starts on every event from on without any mention, for example on every opened pull request, and the result goes by default to the run log, not to a comment. That is how the pull request review works, which the wizard also offers. If you chose it, the branch has a second file, claude-code-review.yml, and Claude leaves its remarks as comments on lines of code.
Request for Claude Code: a comment in a pull request
Merge the wizard's pull request: from now on @claude works in the repository. Ask your local Claude for a branch with one small change, for example a new placeholder text in the chat field, and for a pull request through gh, as in lesson 12_5. In that pull request write a comment:
Request for Claude Code (comment in the pull request):
@claude in components/LiveChat.tsx add a character counter under the
message field in the format 12/300, matching the field's maxLength. Add a case
to components/LiveChat.test.tsx. Do not change other files.A comment is a request like any other: file, goal, limit and proof. Claude answers with a comment in the same pull request and updates it as it works. According to the action's FAQ, on an open pull request it pushes commits straight to its branch, and on an issue it creates a new branch and gives a link to a ready pull request form. It merges nothing, and does no rebase or force push. Commits from the Claude app also start the CI from lesson 12_5; the documentation warns that this would not happen if the action wrote with the default GITHUB_TOKEN.
Now it is your turn. Open Files changed or fetch the branch in Cursor with git pull and read the diff as in every lesson: whether only two files changed, and whether the test checks the counter instead of having been loosened. Wait for green CI. You are the one who merges.
Captain's review
- Who calls the agent. According to the documentation the action starts only for a person with write access to the repository, and it rejects bots unless you list them in
allowed_bots. A stranger in a public repository cannot spend your tokens with a comment. Do not loosen this with theallowed_non_write_usersoption. - Minimum permissions. The documentation advises giving the workflow only the permissions it needs and reviewing Claude's changes before merging. The review example in the documentation has
contents: read, because it pushes nothing. - Costs. Every run uses GitHub Actions minutes and API tokens or the subscription limit. A concrete request means fewer turns, and a short
CLAUDE.mdmeans less reading on every run. - The secret. The key or token lives only in the repository secrets. Never in a comment, because a comment in a public repository can be read by anyone.
A typical agent mistake with a vague comment, for example "@claude fix the chat", is many turns and a diff in files you did not ask about, sometimes with a test changed together with the code, as in lesson 12_1. You recognise it in Files changed by the list of files. Then you do not merge, you write a narrower comment.
Next step
What is left is to put brakes on the costs, which the documentation names directly: a turn limit in claude_args and a time limit for the job. Ask Claude Code locally:
In .github/workflows/claude.yml add a limit of 10 turns through claude_args
and a job time limit of 15 minutes. Show the diff.In the diff look for two new lines: the time limit on the job itself and the turn limit in the action step, as here:
claude:
timeout-minutes: 15
# if, runs-on and permissions unchanged
steps:
# checkout step unchanged
- uses: anthropics/claude-code-action@v1
with:
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
claude_args: "--max-turns 10"You know --max-turns from claude -p: here it works the same way, because claude_args passes command-line flags to Claude Code. timeout-minutes belongs to the job, and according to the GitHub documentation, without it a job can run for as long as 360 minutes. Commit, pull request, green CI and merge. In the editor below waits a simulator: pick a workflow with or without a prompt field, type a comment, change the author and check whether the action starts.
Remember: a deckhand on watch carries out the orders written in the logbook, but the captain approves the course; the agent in CI pushes commits, and you are the one who merges.
Code for this lesson: App.tsx
// Claude Code action simulator in GitHub Actions: will it start and where will it show the result
import { useState } from 'react';
type Workflow = 'interactive' | 'automation';
type GitHubEvent = 'comment' | 'pr_opened';
type Author = 'write' | 'no_write' | 'bot';
interface Check {
ok: boolean;
text: string;
}
interface Outcome {
runs: boolean;
checks: Check[];
result: string;
}
const WORKFLOWS: Record<Workflow, { label: string; on: GitHubEvent; lines: string[] }> = {
interactive: {
label: 'claude.yml: no prompt field',
on: 'comment',
lines: ['on:', ' issue_comment:', ' types: [created]', "if: contains(github.event.comment.body, '@claude')", 'with:', ' anthropic_api_key: (secret)'],
},
automation: {
label: 'review.yml: with a prompt field',
on: 'pr_opened',
lines: ['on:', ' pull_request:', ' types: [opened, synchronize]', 'with:', ' anthropic_api_key: (secret)', ' prompt: "Review the changes"'],
},
};
const EVENT_LABEL: Record<GitHubEvent, string> = {
comment: 'New comment in a pull request',
pr_opened: 'Pull request opened',
};
// The action looks for @claude as a whole word: neither @claude-bot nor /claude matches
export function hasTriggerWord(comment: string): boolean {
return /(^|\s)@claude(?![\w-])/.test(comment);
}
export function simulate(workflow: Workflow, event: GitHubEvent, comment: string, author: Author): Outcome {
const checks: Check[] = [];
const stop = (text: string): Outcome => {
checks.push({ ok: false, text });
return { runs: false, checks, result: 'Claude does not work in this run' };
};
if (WORKFLOWS[workflow].on !== event) {
return stop('The workflow does not start: this event is not in the on section');
}
checks.push({ ok: true, text: 'The event is in the on section, the workflow starts' });
if (workflow === 'interactive') {
if (!comment.includes('@claude')) return stop('if: the comment has no @claude, the machine does not start and uses no minutes');
checks.push({ ok: true, text: 'if: the comment contains @claude, the machine starts' });
}
if (author === 'bot') return stop('The action rejects a bot that is not in allowed_bots: the run ends with an error');
if (author === 'no_write') return stop('The author has no write access to the repository: the action stops the run');
checks.push({ ok: true, text: 'The author has write access to the repository' });
if (workflow === 'interactive') {
if (!hasTriggerWord(comment)) return stop('The action checks the word @claude itself: this is not the whole word, so Claude does not answer');
checks.push({ ok: true, text: 'Interactive mode: no prompt field, so Claude carries out the request from the comment' });
return {
runs: true,
checks,
result: 'Claude answers with a comment in the pull request and pushes commits to its branch. You read the diff and you merge.',
};
}
checks.push({ ok: true, text: 'Automation mode: the prompt field starts Claude without any mention' });
return {
runs: true,
checks,
result: 'By default the result goes to the run log; a comment appears only when the prompt asks for one and Claude has a tool for it.',
};
}
export default function App() {
const [workflow, setWorkflow] = useState<Workflow>('interactive');
const [event, setEvent] = useState<GitHubEvent>('comment');
const [comment, setComment] = useState('@claude add a character counter under the chat field');
const [author, setAuthor] = useState<Author>('write');
const outcome = simulate(workflow, event, comment, author);
return (
<div className="min-h-screen space-y-4 bg-zinc-950 p-4 text-zinc-100">
<h1 className="text-xl font-bold">An agent on the CI deck: will the action start?</h1>
<div className="grid gap-4 md:grid-cols-2">
<section className="space-y-3 text-sm">
<label className="block">
Workflow
<select value={workflow} onChange={(e) => setWorkflow(e.target.value as Workflow)} className="mt-1 block w-full rounded bg-zinc-800 p-2">
{(Object.keys(WORKFLOWS) as Workflow[]).map((key) => (
<option key={key} value={key}>
{WORKFLOWS[key].label}
</option>
))}
</select>
</label>
<pre className="rounded bg-zinc-900 p-2 font-mono text-xs">{WORKFLOWS[workflow].lines.join('\n')}</pre>
<label className="block">
Event on GitHub
<select value={event} onChange={(e) => setEvent(e.target.value as GitHubEvent)} className="mt-1 block w-full rounded bg-zinc-800 p-2">
{(Object.keys(EVENT_LABEL) as GitHubEvent[]).map((key) => (
<option key={key} value={key}>
{EVENT_LABEL[key]}
</option>
))}
</select>
</label>
<label className="block">
Comment text
<input
value={comment}
onChange={(e) => setComment(e.target.value)}
disabled={event !== 'comment'}
className="mt-1 block w-full rounded bg-zinc-800 p-2 disabled:opacity-50"
/>
</label>
<label className="block">
Who did it
<select value={author} onChange={(e) => setAuthor(e.target.value as Author)} className="mt-1 block w-full rounded bg-zinc-800 p-2">
<option value="write">You (write access)</option>
<option value="no_write">A stranger in a public repository (no write access)</option>
<option value="bot">A bot outside allowed_bots</option>
</select>
</label>
</section>
<section className="space-y-2 text-sm">
<ol className="space-y-1">
{outcome.checks.map((check) => (
<li key={check.text}>
<strong className={check.ok ? 'text-emerald-400' : 'text-red-400'}>{check.ok ? 'Yes' : 'Stop'}</strong> {check.text}
</li>
))}
</ol>
<p role="status" className={outcome.runs ? 'font-semibold text-emerald-400' : 'font-semibold text-amber-400'}>
{outcome.runs ? 'The action works' : 'The action does not work'}
</p>
<p className="text-zinc-300">{outcome.result}</p>
<p className="text-zinc-500">Try: a comment without @claude, one with @claude-bot, a stranger as the author, a workflow with a prompt field.</p>
</section>
</div>
</div>
);
}Spotted a mistake in this lesson?
Check yourself
Answer the questions from this lesson. Pick an answer to see right away whether it is correct.
1. A workflow with the anthropics/claude-code-action action has no prompt field. What does the action do?
2. Where, according to the Claude Code documentation, may you turn on bypassPermissions mode?
These are 2 of 6 questions for this lesson. Solve the rest in the game.
Hands-on tasks in the game
- Vertical ordering
Order the steps of requesting a change through a comment in an open pull request:
- Horizontal ordering
Arrange in one line the rule from .claude/settings.json that forbids Claude to run docker system prune with any options:
Tasks after this lesson
- QuestionQuiz: the action without a prompt field
- Put in orderSorting: a request through a comment
- QuestionQuiz: where to use bypassPermissions
- QuestionQuiz: an unattended automation
- Put in orderSorting: a deny rule for Docker
- QuestionQuiz: the JSON answer from claude -p
- QuestionQuiz: the token in secrets, not in the request
- QuestionQuiz: who can call @claude
- Project to submitSend Live from the Deck to the mentor
- VideoModule summary