All posts
Claude in the Thread: In the workload, but not in the workflow?

Claude in the Thread: In the workload, but not in the workflow?

Tuan Phan V. Q.'s avatarTuan Phan V. Q.21 min read
Table of Contents34 sections

We moved the coding agent out of somebody's terminal and into the GitHub thread where the spec conversation already happens. Label an issue, get a draft PR. Type @claude review, get inline comments. Reply to one, get a fix pushed.

This is how it was built, what broke along the way, and an honest read on whether it was worth it.

Workflows

Issues handed off

Median run

Plumbing bugs

Merged unreviewed

5

10

~1m 40s

6

0


The problem

The work was small. The interruption wasn't.

internal-rewrite is a from-scratch rebuild of an internal line-of-business app, built against a frozen API contract. The backend slices landed fast. The frontend accumulated a different kind of debt entirely — the sort nobody schedules.

Ten places using an EmptyState component with four different title patterns. Pagination counts reading "1 result(s)". Dates rendering differently depending on the viewer's browser locale. A profile page whose two-column layout got flattened by an earlier change and nobody noticed for a week. Search placeholders phrased five ways across five screens.

Each one is fifteen minutes of actual work and forty minutes of everything around it: stash what you're doing, pull, cut a branch, find the files, make the change, run lint, run the build, write a conventional-commit message, push, open the PR, go back to what you were doing and rebuild the mental stack you just dropped.

The cost was never the typing. It was the context switch — and the fact that these tasks are individually too small to justify one, so they queue up until the UI is quietly inconsistent everywhere.

There was a second, subtler problem. The spec conversation already happened in the issue thread — someone wrote down exactly which titles change and which two deliberately don't. Then the work left GitHub to happen in a terminal, and the thread stopped being the record of what was decided. The reasoning and the diff lived in different places.



Where AI already was

In the workload, but not in the workflow.

This wasn't a team discovering AI. Claude Code had been writing most of this repo for weeks — migrations, modules, the Docker stack, the deploy pipeline. That part already worked well.

But it worked in a shape with three real limits:

It ran on one machine. The agent was as available as the person whose laptop it lived on. Nobody else could hand it anything.

Its work was invisible until finished. A teammate saw nothing between "I'll pick that up" and a PR appearing. No progress, no chance to redirect it mid-flight.

It couldn't be part of the conversation. If it had a question about the spec, the question surfaced in a terminal, to one person, who then had to go ask the thread and carry the answer back by hand.

So the proposal wasn't "use AI." AI was already in the workload. The proposal was to move it into the place where the team already talks about the work — where the spec is argued, where review happens, where the record lives.


The proposal

Three verbs, all of them typed into GitHub.

Everything below reduces to three things a person can do without leaving a browser tab, plus one rule that never bends.

You do this

You get

Workflow

Label an issue claude-implement

A branch, commits, validation, and a draft PR — or a blocking question posted back on the issue

claude-implement-issue

Comment @claude review on a PR

Inline comments on specific lines plus a summary verdict. Reads only — the editing tools are withheld

claude-review-pr

Comment @claude <anything> on a PR

An answer, an explanation, or a fix committed to that PR's existing branch

claude-pr-assistant

File the issue in a different repo

The same handoff, code and PR landing here, requirement staying there

two cross-repo variants

The rule that never bends: every output is a draft pull request that a human reviews and merges. Nothing the agent produces reaches the default branch on its own. That single constraint is what makes the rest of this safe enough to be worth trying.


Setup — same repo

Roughly twenty minutes if nobody has to ask an org owner for anything. The whole thing is one credential and three workflow files.

1. Mint the token from the CLI, not a website

Role: Claude subscriber

This is the step people look for in the wrong place. There is no dashboard button. The credential comes out of the Claude Code CLI on somebody's machine:

claude setup-token

It opens a browser, asks you to sign in, and prints a long-lived OAuth token. That value goes into a repository secret named CLAUDE_CODE_OAUTH_TOKEN. It requires a paid Claude subscription — a free account will not produce a working token.

Whose subscription is a real decision, not a detail. The token belongs to whoever ran the command. Their seat is what the usage bills against, and every workflow stops the day they leave or their subscription lapses. For anything past a trial, generate it from an account the organisation owns. If you'd rather meter per-request than per-seat, create an API key instead and swapclaude_code_oauth_token for anthropic_api_key in the workflows — one line each, nothing else changes.

2. Decide whose name is on the commits

Role: Repo admin

The default is github-actions[bot], which works fine and asks for nothing extra. We passed a personal access token as github_token instead, so commits and PRs carry a human name — reviewers see who is accountable for a change, not which machine emitted it.

That choice has two consequences, and both bite later if you don't take them now:

  • The job's permissions: block stops bounding the Claude step. The PAT's own scopes apply

instead. The block still governs your own gh bookkeeping steps, which should stay on GITHUB_TOKEN.

  • Everything the agent posts now arrives as a User event — and User comments trigger workflows.

See incident 502e6ab below.

Also enable Settings → Actions → Workflow permissions → Allow GitHub Actions to create and approve pull requests, or the run does all the work and fails on the last step.

3. Wire the implement workflow

Role: Repo admin

Trigger on issues: [labeled] and issue_comment: [created] — the second is what makes the thread a two-way channel instead of a one-shot command.

# .github/workflows/claude-implement-issue.yml
- uses: anthropics/claude-code-action@v1
  with:
    claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
    github_token: ${{ secrets.GH_PAT }}
    bot_name: your-github-username
    # the numeric account id — api.github.com/users/your-github-username
    bot_id: "0000000"
    track_progress: true
    base_branch: ${{ steps.base.outputs.branch }}
    branch_prefix: "feature/"
    branch_name_template: "{{prefix}}{{entityType}}-{{entityNumber}}-{{description}}"
    claude_args: |
      --allowedTools "Bash(gh pr create:*),Bash(gh pr view:*),Bash(gh issue view:*),Bash(npm:*),Bash(npx:*),Bash(php:*),Bash(composer:*)"

track_progress: true is doing more than its name suggests. It switches the action into tag mode, which gives you three things at once: the issue body and every comment pre-loaded into the prompt, a branch cut from base_branch before the agent starts, and a single tracking comment the agent keeps editing as it works. That comment is the live status display, and it's also where clarifying questions appear.

4. Make review genuinely read-only

Role: Repo admin

The review workflow is the one where the tool lists matter most, for a reason that is easy to get backwards.

# .github/workflows/claude-review-pr.yml
claude_args: |
  --allowedTools "mcp__github_inline_comment__create_inline_comment,
                  mcp__github_comment__update_claude_comment,
                  mcp__github_ci__get_ci_status,Read,Glob,Grep,LS,
                  Bash(gh pr view:*),Bash(gh pr diff:*),Bash(git diff:*)"
  --disallowedTools "Edit,MultiEdit,Write,Bash(git push:*),Bash(git commit:*),
                     Bash(gh pr merge:*),Bash(gh pr review:*),Bash(gh api:*),
                     Bash(gh secret:*),Bash(gh workflow:*)"
  • The allow-list is what enables inline comments at all. The action only starts its

inline-comment MCP server when an mcp__github_inline_comment__* tool is allowed. Drop that entry and reviews silently degrade to one summary comment.

  • The deny-list is the actual read-only enforcement. Since the PAT carries write access

regardless of the job's permissions:, withholding the editing and pushing tools is the only thing stopping this run from changing code.

5. Route the three so they never double-fire

Role: Repo admin

All three workflows observe issue_comment, which GitHub fires for issues and PRs. Without explicit routing, one comment starts two agents on the same thread.

  • implement takes comments where github.event.issue.pull_request is unset — issues only — and

only while the label is still on.

  • review takes PR comments containing exactly @claude review.

  • assistant takes every other @claude mention on a PR, explicitly excluding @claude review.

Ordinary discussion never escalates into a full re-review, and each thread has exactly one agent responsible for it.



What actually broke

Six plumbing bugs, in the order we hit them.

None of these are in the quickstart. Every one cost a real run, and every one is the kind of thing that silently comes back if someone rewrites a workflow from scratch. They're listed by the commit that fixed them.

ef9b401 — Tag mode's default toolset can't open a PR

Evidence: PR #5 Symptom: Claude posted a "Create PR ➔" link instead of a pull request

Tag mode ships a default allow-list of Read, Grep, Glob plus git add/commit/push — and nothing else. No gh pr create. The agent did all the work, pushed the branch, then fell back to posting a link for a human to click. PR #5 is authored by a person for exactly this reason. It also couldn't run the lint and build commands the prompt told it to run. Values in claude_args merge with the defaults rather than replacing them, so the fix is additive.

502e6ab — Switching to a PAT broke every recursion guard at once

Evidence: 9 tracking comments Symptom: the agent's own comment re-triggered the workflow that posted it

Every guard rested on comment.user.type != 'Bot'. That held only while the agent commented as github-actions[bot]. Under a PAT its tracking comment arrives as a User event, which does trigger workflows — so each workflow re-fired on the comment it had just posted. The fix matches on content instead: the action rebuilds that comment as *Claude finished … or *Claude encountered an error…, shows Claude Code is working mid-run, and links its own /actions/runs/ URL in both states. Checked against all nine tracking comments the repo had received — each is caught by at least two of the three filters.

4114408 — The token sets who pushes, not who authored

Evidence: PR #17 Symptom: PR author the PAT's owner, every commit inside claude[bot]

The PAT made pull requests come out under a human name while every commit in them still read claude[bot] <41898282+claude[bot]@users.noreply.github.com>. The action builds its git identity from the separate bot_name and bot_id inputs, which default to claude[bot]. The token only decides who pushes and who opens the PR. Set both explicitly, and match them to the token you chose — pairing bot id 41898282 (which is github-actions[bot]) with the name claude[bot] puts two identities on one PR.

dc5db0f — actions/checkout quietly outranks the action's credentials

Evidence: first cross-repo run Symptom: 403 "Write access to repository not granted" — after the work was done

The first live cross-repo run implemented the change, validated it, and then failed to push. The PAT wasn't the problem — it can write to the repo, verified directly. actions/checkout persists GITHUB_TOKEN as an http.extraheader, and an extraheader overrides the credentials claude-code-action embeds in the origin URL. So git push authenticates as GITHUB_TOKEN no matter what the action configured. The job had contents: read on the assumption every write went through the PAT. It needs contents: write regardless.

6396fa3 — Two flows, two branch prefixes, one duplicated PR

Evidence: PRs #22 and #24 Symptom: backlog item 3 produced two near-identical pull requests

Both cross-repo workflows check for an existing PR before starting, by matching open PRs whose head branch carries this item's prefix. They used different prefixes, so neither could see the other's work and both implemented backlog item 3. The prefix is a dedup key, not cosmetics. Both now share feature/PBI-<n>-; whichever runs second finds the first one's PR and stops.

2ff3ecb — Slug truncation sliced mid-word

Evidence: a branch name Symptom: feature/PBI-3-warn-before-deleting-a-project-that-is-s

Cosmetic, and included precisely because it's the class of thing that survives forever once it ships. A hard character cut on the issue title produced branch names ending in half a word. Fixed by raising the limit and dropping the trailing fragment at a hyphen — but only when the title actually exceeded the limit, so short titles are untouched.

Read this list as a cost, not a warning. Six real incidents, all of them plumbing, none of them solved by an agent — a human read GitHub Actions internals to find every one. That debugging was the most expensive part of the whole exercise, and it's the part a demo never shows you.


Cross-repo

When the backlog lives somewhere you don't control.

The realistic case in most organisations: the requirement is an issue in a tracker owned by another team, and the code is in your repo. You often cannot install a workflow in their repo, and you should assume you'll never be allowed to write to it.

We built both answers, and they're worth understanding as a pair — the difference is entirely about how much you're allowed to ask for.

Dispatched (automatic)

Manual (zero-install)

Installed in the issues repo

a forwarder workflow + a secret

nothing at all

Access needed there

Issues: read and write

Issues: read

Started by

adding a routing label

a person typing an issue number in the Actions tab

Agent holds a cross-repo credential

yes

no — it's handed a file

Replies on the issue

yes, and a human reply re-triggers it

no — the run summary is the report

Answering a question

comment on the issue

re-run with the notes input

The dispatched design — what goes in the issues repo

Four things, and only the last one is a file:

  1. Two labels, doing different jobs. A routing label (WEB, or whatever your project code is)

says which code repo owns the issue. claude-implement says when to start. Keeping them separate means an issue can be tagged with its destination the moment it's filed, without that starting a run before the requirement is finished being written.

  1. A REPO_ROUTES repository variable — {"WEB":"owner/code-repo"}. A variable rather than a constant in the workflow, so adding a project later is a settings edit instead of a pull request.

  2. A GH_PAT secret with contents: write on the destination repo. That's the scope repository_dispatch requires — it is not an issues scope, which surprises people.

  3. The forwarder workflow, which resolves the routing label to a repo and sends the dispatch.

# .github/workflows/forward-issue-to-code-repo.yml  (in the ISSUES repo)
on:
  issues:        { types: [labeled] }
  issue_comment: { types: [created] }

permissions:
  issues: write        # only to comment, and to drop the label when routing fails

steps:
  - name: Resolve the destination from the routing label
    id: route
    env:
      LABELS: ${{ toJSON(github.event.issue.labels.*.name) }}
      ROUTES: ${{ vars.REPO_ROUTES }}          # {"WEB":"owner/code-repo"}
    run: |
      hits=$(jq -c --argjson r "$ROUTES" '[.[] | select($r[.] != null)] | unique' <<<"$LABELS")
      # exactly one routing label is required — zero or two both fail, loudly

  - name: Dispatch to the code repo
    env:
      GH_TOKEN: ${{ secrets.GH_PAT }}          # NOT GITHUB_TOKEN — see below
    run: |
      gh api "repos/${DEST}/dispatches" \
        -f event_type=implement-issue \
        -F "client_payload[issue]=${ISSUE}" \
        -F "client_payload[repo]=${GITHUB_REPOSITORY}"

Two traps here, both of which cost a run to find:

The dispatch has to come from a PAT. Agent mode on the receiving end calls checkHumanActor() and aborts when github.actor is a bot. A dispatch sent with GITHUB_TOKEN arrives as github-actions[bot] and is refused outright. This one is genuinely nasty to diagnose, because the forwarder reports success and the failure happens in the other repository's run.

Fail loudly when routing fails. No routing label, or two of them, and the forwarder comments the reason on the issue and removes claude-implement. The worst outcome in this design is a silent skip: the label sits on the issue, nothing happens, and nobody can tell whether the agent is working or was never called at all.

The dispatched design — what changes on the receiving end

Three things, all forced by the fact that repository_dispatch is not an issue event:

No tag mode. Tag mode needs a real issue or PR in this repo. So there's no auto-created branch, no pre-loaded thread and no tracking comment — the workflow cuts the branch itself and hands it over via a CLAUDE_BRANCH environment variable, and the agent reads the thread with gh issue view --repo.

No default tool list. Agent mode merges in nothing, so claude_args has to name every tool, not just the additions. Easy to miss; the symptom is an agent that can't do basic things.

Payloads are untrusted input. Anything holding a token with write access here can send a dispatch, and both payload fields land in shell commands and in the prompt. They're validated against ^[0-9]+$ and ^owner/name$ and re-emitted before first use.

One more detail that took a run to discover: replies posted back to the issue carry an invisible <!-- claude-bot --> marker. The forwarder skips comments containing it. Without that, the agent answering a question dispatches another run of itself.

The manual design — and why it's the one to propose first

This is the version to put in front of a team that will not install anything. Nothing lives in their repo: no workflow, no secret, no variable, no label. Somebody on your side opens the Actions tab, types an issue number, and clicks Run.

The whole cross-repo surface is one API read, in one step, before the agent starts. That step renders the issue and its comments to a markdown file — so the issue text never touches a shell command or a YAML expression — and the agent is handed the file, not a credential. Its tool grant contains no gh issue entry of any kind, and the workflow's own GITHUB_TOKEN cannot reach the other repository at all.

So the entire ask on the other side is a fine-grained token with Issues: read on one repo. That's a request a security-conscious team can actually say yes to.

One trap worth naming. Fine-grained PAT permissions are uniform across every repository you select. A single token covering both repos would carry write access into the issue tracker — the exact thing this design exists to avoid. Scope it to the issues repo alone, and nothing else.



When it doesn't know

The escape hatch is the part you have to design on purpose.

An agent that implements a misreading of the spec is worse than one that stops and asks. But an agent that asks too readily is also worse than useless — you get a question thread instead of a pull request, which is precisely the round trip you were trying to avoid.

So the instruction in every implement prompt is deliberately lopsided, and the wording carries the whole design:

Default hard toward implementing. Settle minor details yourself from the existing code, project conventions, tests, and neighbouring features. Do not ask about anything a careful colleague would just decide.

> Ask only when two readings of the issue lead to materially different implementations and guessing wrong would waste the work.

The bar is materially different implementations, not any uncertainty. And when it does ask, it's told to give the options it sees and say which one it would pick — so a one-line reply unblocks it — and then to write no code, make no commit, open no PR, and guess at nothing.

The label is the state machine

This is the part I'd copy into any similar system. Nothing persists state anywhere: the label and the PR list are the state.

Label state

Meaning

claude-implement on, no PR

Claude's turn — or it asked something and is waiting on you

claude-implement off, PR exists

Your turn — review the draft

The final step of every implement workflow does exactly one check: did a PR appear for this issue?

  • A PR exists → comment the link and remove the label. Later chatter on the issue can no longer

start a second implementation from scratch.

  • No PR → leave the label exactly where it is, and say so in the log.

That second branch is the entire feedback loop. The label staying on is what makes your next comment re-trigger the workflow — and because tag mode pre-loads the whole thread, the re-run sees the original issue, its own question, and your answer as one continuous requirement. Nobody has to restate anything.

Three flows, three channels

The mechanism is the same everywhere; only the channel changes with what each flow is allowed to write.

Flow

Where it asks

How you answer

Same-repo

its own tracking comment on the issue

reply on the issue — the label's still on, so it re-triggers

Dispatched

a comment it posts itself, prefixed <!-- claude-bot -->

reply on the issue — the forwarder dispatches again

Manual

.claude-questions.md, printed into the run summary

re-run the workflow with your answer in the notes input

The manual flow's version is the awkward one, and it's worth understanding as the direct price of installing nothing in the other repo. There's no comment channel at all, so questions land in the GitHub Actions run summary. The agent is explicitly told not to git add that file — a later step reads it, prints it to the summary, and deletes it, so a question never reaches the branch. You answer by re-running with notes filled in, which gets appended to the issue markdown, and the branch is reused so your answer continues the same work instead of starting over.

The honest caveat, stated here and again in the assessment: this path barely fired. The issues were specified well enough that the agent almost never had grounds to stop. That's a good outcome for throughput and a bad one for confidence — the most safety-critical branch in the whole design is the least exercised one.



The round trip

The run that justified the whole thing.

Everything above is plumbing. This is the part that showed the shape was actually worth building — one continuous exchange, start to finish, with nobody opening an editor.

Issue #13: an earlier change had flattened the Profile page's two-column layout. The fix was described as a partial revert of a specific commit.

HUMAN — Adds the claude-implement label to issue #13. Types nothing else.

CLAUDE — Posts a tracking comment and starts editing it live: reading the issue, finding the CSS, checking git history for the original commit, running lint and build, committing, pushing. (4m 10s — opens draft PR #14)

WORKFLOW — Comments "Draft implementation PR ready: …/pull/14" on the issue and removes the claude-implement label, so later chatter can't start a second implementation.

HUMAN — On the PR:

@claude review this

CLAUDE — Reviews the PR it just wrote, and finds a real bug in its own work. The stacking override was added to the @media (max-width: 980px) block. In the original commit being reverted, that rule lived in the 640px block. Effect: viewports between 901 and 980px now stack to a single column when they shouldn't. Posted as an inline comment on frontend/src/premium.css:179, plus a summary marking it blocking. (1m 38s — 1 blocking finding)

HUMAN — Replies to that inline comment, in five words:

@claude make senses, fix it

CLAUDE — Moves the rule from the 980px block to the 640px block, re-runs lint and build, commits to the same PR branch, and reports back in the thread. (1m 01s — pushed to the existing branch, no new PR)

HUMAN — Reviews the two-commit diff and merges.

Live status

The tracking comment does more work than it looks like.

One GitHub comment, edited repeatedly as the run proceeds, turns out to be a surprisingly complete interface. It's the progress indicator, the log link, the branch link, the place clarifying questions appear, and the final report — all in the spot a reader is already looking.

It's also load-bearing for a reason nobody plans for: it is the recursion hazard. Because that comment is posted under a real user account, it triggers the workflows watching the thread. Every filter in the guard exists to recognise this one comment in each of its three states — working, finished, errored. Get it wrong and one label starts an infinite loop.

Worth saying plainly: the status is honest about time and steps, but it reports what the agent did, not whether the result is right. "Ran lint and build" is a real signal. "Validated" is not the same word.


If you're copying this

Start with the manual cross-repo variant, even for same-repo work. It's the design that survives a security review, and it forces you to be explicit about what the agent can reach.

Set bot_name and bot_id on day one. Identity mismatches are invisible until a reviewer asks who wrote a commit.

Write the recursion guard before the first live run, and write it against comment content, not author type. Author type stops being reliable the moment you switch tokens.

Keep review as its own workflow with the editing tools withheld. The separation is what makes review adversarial rather than a rubber stamp on its own work.

Never let it merge. Draft PRs, human gate, no exceptions. Everything else here is a tradeoff; this one isn't.


Field report from internal-rewrite, built on anthropics/claude-code-action@v1. Five workflow files: implement, review, PR assistant, and two cross-repo variants. All figures, commit hashes and PR numbers come from the repository's own history — it's a private repo, so the references are here as citations rather than links you can follow.