Authenticate the Claude Code workflow with a subscription OAuth token - #1180
Conversation
`anthropics/claude-code-action@v1` accepts `claude_code_oauth_token` as an alternative to `anthropic_api_key`, so `@claude` mentions can run on the organization's Claude subscription instead of token-usage billing. Requires the `CLAUDE_CODE_OAUTH_TOKEN` repo secret (minted with `claude setup-token`) to exist before this merges. Refs #1179 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Bind the doc to .github/workflows/claude.yml so drift flags it when the workflow's auth changes again. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Preview deployment: https://busbykxclaude-oauth-token-auth.preview.avy-fx.org |
Proves CLAUDE_CODE_OAUTH_TOKEN authenticates from a runner before claude.yml's change reaches main. Delete before merge. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Served its purpose: run 31213153669 authenticated with CLAUDE_CODE_OAUTH_TOKEN alone (no ANTHROPIC_API_KEY in scope) and returned a successful model response. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Ran the step-3 smoke test on this branch and it passed, so the subscription token is verified end-to-end from CI. A temporary That establishes the two things worth knowing before merge: the token authenticates a real model call from a Blacksmith runner, and it does so with no Still post-merge-only: the actual |
The gate now judges borderline PRs by invoking Sonnet through the Claude Code CLI with CLAUDE_CODE_OAUTH_TOKEN instead of calling the Messages API with a usage-billed key, matching the subscription auth adopted for @claude mentions in #1180. The recap job stays on ANTHROPIC_API_KEY until BuilderIO/agent-native#2741 lets the reusable workflow accept a subscription token. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Description
Switches
.github/workflows/claude.ymlfrom the token-usage-billedANTHROPIC_API_KEYtoclaude_code_oauth_token, so@claudementions run on the organization's Claude subscription instead.anthropics/claude-code-action@v1declaresclaude_code_oauth_tokenas an explicit alternative toanthropic_api_keyand forwards it to the CLI asCLAUDE_CODE_OAUTH_TOKEN, so this is a one-line swap.This cannot merge until the
CLAUDE_CODE_OAUTH_TOKENrepo secret exists — it does not today. Mint it withclaude setup-tokenfrom an account on the org subscription (prefer a shared account over a personal one, so the secret survives personnel changes) and add it first, or@claudewill fail with no credentials.Related Issues
Part of #1179. The other two consumers named in that issue are deferred: the
size-gaterework has nothing to apply to until #1178 merges, and thevisual-recapjob is blocked upstream becauseBuilderIO/agent-native's reusable workflow declares noCLAUDE_CODE_OAUTH_TOKENsecret. Both are documented with the specific upstream touchpoints in this comment.Key Changes
.github/workflows/claude.yml—anthropic_api_key→claude_code_oauth_tokendocs/claude-github-issues.md— troubleshooting section now names the new secretdrift.lock— binds that doc toclaude.ymlso drift flags it if the workflow's auth changes againHow to test
Note that
issues/issue_commentworkflows only ever run from the default branch, so this branch'sclaude.ymlcannot be exercised by an@claudemention pre-merge. Test in this order:env -u ANTHROPIC_API_KEY CLAUDE_CODE_OAUTH_TOKEN='<token>' claude -p 'reply with OK'. Catches a wrong account, an expired token, or a missing subscription.CLAUDE_CODE_OAUTH_TOKENrepo secret.push-triggered scratch workflow on this branch (push events do run workflows from the pushed ref) that invokesanthropics/claude-code-action@v1with the same input, then delete it before merge.@claudeon a throwaway issue and confirm the run authenticates in the Actions tab.Low risk either way — the failure mode is "
@claudestops responding," not a production impact, and revert is one commit.Future enhancements / Questions
ANTHROPIC_API_KEYis intentionally left in repo secrets: #1178'spr-visual-recap.ymlstill references it and has no other credential until the upstream piece lands. One known minor behavior change — the action's inline-comment classifier reads onlyANTHROPIC_API_KEY, so unconfirmed buffered comments now post unclassified instead of being filtered. Comments Claude posts withconfirmed: true(the normal review path) are unaffected, and the fallback is the action's own documented pre-buffering behavior.