anthropics / anthropics/claude-code-action
separate token for Claude's tool environment (GH_TOKEN) from the token used for action API calls
- Dominant language
- TypeScript
- Stars
- 8.9k
- Forks
- 2.1k
- Avg merge
- 3d 9h
- Merged PRs (30d)
- 10
Description
> **Disclaimer:** Claude Code was used in drafting this issue.
When `github_token` is provided, the action uses that single token for everything: Octokit API calls (posting comments, creating branches) and the `GH_TOKEN/GITHUB_TOKEN` env vars inherited by Claude's subprocess (used by `gh` CLI in Bash tool calls).
This creates a forced trade-off for organizations using private repos:
**- Without github_token:** The action uses its GitHub App token via OIDC exchange. Comments appear as claude[bot]. But Claude's `gh` CLI inherits this same App token, which is scoped to the triggering repo and cannot access other private repos in the org — any `gh api repos/org/other-repo/...` call returns 404.
**- With github_token (e.g., a bot PAT with cross-repo access):** Claude's `gh` CLI can now access other private repos. But comments now appear as the bot user instead of `claude[bot]`, since the PAT is also used for Octokit API calls.
This is a real problem when `CLAUDE.md` references guidelines or conventions stored in a separate private repo (e.g., a shared coding standards repo). Claude needs cross-repo read access during reviews, but comments should still come from `claude[bot]`.
**Proposed solution**
Add a new optional input (e.g., `claude_env_github_token` or `tool_use_github_token`) that, when provided, is used only for `GH_TOKEN`/`GITHUB_TOKEN` in Claude's subprocess environment — without affecting the token used for the action's own Octokit calls (comments, branch creation, etc.).
When not provided, behavior stays exactly as it is today (single token for everything).
**Alternatively,** if the OIDC token is converted to a token that has access only the triggering repo, allow us to specify `additional_repos`?
```yaml
- uses: anthropics/claude-code-action@v1
with:
additional_repositories: |
our-kb
```
Contributor guide
Research direction
Start by tracing the action's input handling, Octokit API calls, and Claude subprocess environment where GH_TOKEN/GITHUB_TOKEN is set. Verify the separate optional token affects only Claude's gh CLI access while comments and branch operations retain their existing identity, and confirm the unchanged behavior when it is omitted.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- github-actions, typescript
- Domain
- api, authentication, ci-cd
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100