Repository navigation
ci: give the @claude mention handler a review-sized budget - #280
Conversation
Raise --max-turns 20 -> 60 and allowlist read-only diff tools (git diff/log, gh pr view/diff). Two mention-triggered review tasks died today on error_max_turns after burning turns on permission denials for exactly these tools. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Pohc8xLkdx4gwXkW3xd7up
WalkthroughThe Claude GitHub Actions configuration increases the maximum turns from 20 to 60 and adds an allowlist for Git, GitHub CLI pull request inspection, and constrained pnpm commands. ChangesClaude workflow configuration
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Preview DeploymentPreview URL: https://eef602cf.bestax.pages.dev |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
.github/workflows/claude.yml (1)
72-80: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winAllow Claude to use the provisioned toolchain
--allowedToolsonly adds permissions; it doesn’t includepnpmornode, so the setup steps won’t help Claude run tests/lint/build. Add the neededBash(pnpm …)/Bash(node …)patterns, or drop the setup steps if this workflow is review-only.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In @.github/workflows/claude.yml around lines 72 - 80, Update the claude_args allowedTools configuration to include Bash permissions for the provisioned pnpm and node commands, preserving the existing git and gh read-only permissions. Ensure Claude can run the workflow’s setup, tests, lint, and build toolchain without removing the current review capabilities.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In @.github/workflows/claude.yml:
- Around line 72-80: Update the claude_args allowedTools configuration to
include Bash permissions for the provisioned pnpm and node commands, preserving
the existing git and gh read-only permissions. Ensure Claude can run the
workflow’s setup, tests, lint, and build toolchain without removing the current
review capabilities.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: bea190f9-5282-47aa-8af8-867c183c7530
📒 Files selected for processing (1)
.github/workflows/claude.yml
…lchain CodeRabbit nitpick on #280: the setup steps install pnpm/node but no pnpm command was ever allowlisted, so the toolchain was dead weight. Mirrors claude-review.yml's list plus install (no install step here). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Pohc8xLkdx4gwXkW3xd7up
Preview DeploymentPreview URL: https://f1ec3d74.bestax.pages.dev |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/workflows/claude.yml:
- Line 83: Add GH_TOKEN to the Claude workflow step that configures
claude_code_oauth_token, sourcing it from secrets.GITHUB_TOKEN (or the existing
github_token equivalent). Keep the allowedTools entries for gh pr view and gh pr
diff unchanged, and ensure the token is available in that step’s environment.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: b94c2b62-f25b-480d-a96f-1c8cf299419c
📒 Files selected for processing (1)
.github/workflows/claude.yml
| --max-turns 20 | ||
| --max-turns 60 | ||
| --model claude-sonnet-5 | ||
| --allowedTools "Bash(git diff:*),Bash(git log:*),Bash(gh pr view:*),Bash(gh pr diff:*),Bash(pnpm install:*),Bash(pnpm run:*),Bash(pnpm test:*),Bash(pnpm exec:*),Bash(pnpm --filter:*)" |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Inspect claude.yml: permissions block, whether github_token/GH_TOKEN is provided,
# and how sibling workflows authenticate gh.
fd -a 'claude.yml' .github/workflows | xargs -r sed -n '1,90p'
echo '--- token/permissions references across claude* workflows ---'
fd . .github/workflows -e yml -e yaml | xargs -r rg -n 'permissions:|github_token|GH_TOKEN|GITHUB_TOKEN|gh pr (view|diff)'Repository: allxsmith/bestax
Length of output: 12420
🌐 Web query:
anthropics/claude-code-action gh pr view GH_TOKEN GITHUB_TOKEN allowlisted Bash tools token handling
💡 Result:
Claude Code interacts with GitHub through the GitHub CLI (gh) and the anthropic/claude-code-action in GitHub Actions. Managing token authentication and tool permissions effectively is critical for these workflows. ### Token Handling and Precedence The gh CLI follows a specific order of precedence for authentication, which can lead to conflicts if not managed correctly [1][2][3]. * Precedence: The CLI prioritizes GH_TOKEN over GITHUB_TOKEN [1][2]. * Injection Conflict: Claude Code historically injected a GITHUB_TOKEN (often a Personal Access Token) directly into the environment of the Bash tool. This could override OAuth tokens stored in the system's local keychain, causing authentication failures or unexpected behavior when using gh commands [3]. * Best Practice: In CI/CD workflows, it is recommended to explicitly set GH_TOKEN in the environment to ensure the gh CLI uses the intended credentials [1][2]. For example: env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} [2] ### Bash Tools and Permission Management Claude Code uses an allowlist/denylist permission system to control access to Bash commands [4][5][6]. * Allowlisting: You can add specific commands to permissions.allow to permit them without manual approval [4]. * Sandboxing: When autoAllowBashIfSandboxed is enabled (default), commands running within a sandbox boundary are automatically allowed, bypassing the standard prompt for most Bash tools [4][5]. * Security Risks: * Compound Commands: Relying on simple allowlists can be risky because compound commands (e.g., cmd1 && cmd2) might bypass permission filters if only the first token is evaluated [7]. * Command Parsing: Claude Code parses commands into an Abstract Syntax Tree (AST) to match against rules. Commands that cannot be parsed safely or do not match an allowlist entry trigger manual approval [6]. * Credential Masking: To prevent credentials from being exposed, use the mask mode in sandbox settings. This protects the environment variable while allowing tools (like gh or npm) to remain functional [8]. ### Specific GitHub Actions Considerations The claude-code-action is designed to run on your infrastructure [9]. It intelligently selects execution modes and can be configured to use specific secrets for authentication [10][9]. When using features like gh pr view, be aware that automated polling or frequent executions can trigger high CPU usage or bypass intended permission constraints if not properly cached [11][12]. To mitigate this, ensure your configuration balances automation needs with resource and security constraints [12][6].
Citations:
- 1: fix: set GH_TOKEN alongside GITHUB_TOKEN for gh CLI precedence anthropics/claude-code-action#752
- 2: https://engineering-playbook.vercel.app/claude-code/github-integration
- 3: [Bug] Claude Code injects GITHUB_TOKEN PAT into Bash environment, conflicting with gh CLI OAuth token anthropics/claude-code#31502
- 4: https://code.claude.com/docs/en/permissions
- 5: https://code.claude.com/docs/en/security
- 6: https://code.claude.com/docs/en/agent-sdk/secure-deployment
- 7: Chained bash commands silently bypass the tool permission allowlist anthropics/claude-code#36637
- 8: https://code.claude.com/docs/en/sandboxing.md
- 9: https://github.com/anthropics/claude-code-action?tab=readme-ov-file
- 10: https://github.com/anthropics/claude-code-action
- 11: [FEATURE] Automatic
gh pr viewpolling bypasses the permission system and cannot be disabled anthropics/claude-code#23580 - 12: [BUG] gh pr view polling causes repeated 200-500% CPU spikes when branch has no PR anthropics/claude-code#37583
🌐 Web query:
anthropics/claude-code-action README GH_TOKEN github_token claude_code_oauth_token gh CLI authentication
💡 Result:
In Claude Code, authentication is separated into two primary domains: Anthropic API access and GitHub repository access. 1. Anthropic/Claude Code Authentication The CLAUDE_CODE_OAUTH_TOKEN is used for long-lived authentication to Claude Code itself, particularly in CI/CD or non-interactive environments where a browser-based login is not possible [1][2]. You can generate this token by running the command 'claude setup-token' locally in your terminal [3][2]. Once generated, set this token as the CLAUDE_CODE_OAUTH_TOKEN environment variable in your CI/CD configuration or environment [2]. 2. GitHub CLI (gh) and Repository Authentication Claude Code uses the GitHub CLI ('gh') to interact with repositories [4][5]. To authenticate GitHub operations, Claude Code looks for a GitHub token in the following order [6]: - Provider-specific environment variables - GH_TOKEN - GITHUB_TOKEN - 'gh auth token' (retrieved from the local GitHub CLI configuration) [6] For GitHub Actions workflows, it is best practice to pass the 'GITHUB_TOKEN' (provided automatically by the workflow) to the 'claude-code-action' [4]. In your workflow file, you can explicitly map this token: - name: Run Claude Code uses: anthropics/claude-code-action@beta env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: github_token: ${{ secrets.GITHUB_TOKEN }} #... other configuration [7][8] When running Claude Code locally, you can authenticate the GitHub CLI by running 'gh auth login' [4][6]. This stores your credentials securely, and Claude Code will automatically detect and use them [5][1]. If you need to run Claude Code in a headless or CI environment, setting the 'GH_TOKEN' or 'GITHUB_TOKEN' environment variable directly is the standard method for providing repository-level credentials [4][6].
Citations:
- 1: https://vineetagarwal-code-claude-code.mintlify.app/guides/authentication
- 2: [DOCS] Authentication docs missing recovery guidance for expired
CLAUDE_CODE_OAUTH_TOKENanthropics/claude-code#51784 - 3: https://github.com/anthropics/claude-code-action/blob/main/docs/setup.md
- 4: https://engineering-playbook.vercel.app/claude-code/github-integration
- 5: https://github.com/bitwise-media-group/gh-claude
- 6: https://github.com/lopushok9/claude-code-codex-auth/blob/main/README.md
- 7: https://github.com/anthropics/claude-code-action/blob/154d0de1/action.yml
- 8: Claude Code Action Not Using Provided GitHub App Token anthropics/claude-code-action#235
Pass GH_TOKEN into the Claude step Bash(gh pr view:*) and Bash(gh pr diff:*) need a GitHub token. This step only sets claude_code_oauth_token, so add GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} (or github_token) here to avoid auth failures and wasted turns.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In @.github/workflows/claude.yml at line 83, Add GH_TOKEN to the Claude workflow
step that configures claude_code_oauth_token, sourcing it from
secrets.GITHUB_TOKEN (or the existing github_token equivalent). Keep the
allowedTools entries for gh pr view and gh pr diff unchanged, and ensure the
token is available in that step’s environment.
|
🎉 This PR is included in version 3.2.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
|
🎉 This PR is included in version 5.4.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
|
🎉 This PR is included in version 1.0.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
|
🎉 This PR is included in version 1.0.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Pull Request
Description
Two mention-triggered review tasks failed today with
error_max_turns: the@claudeverification on #267 (run 29136350689) and the substitute deep review on #270 (run 29147803092). Root cause from the job logs:claude.ymlcaps Claude at 20 turns and allowlists no diff tools, so review-sized requests burn turns on permission denials (git diff,gh pr diffwere denied 4 times in the #270 run) and hit the cap before posting anything.This PR makes the mention path viable for review work:
--max-turns 20→--max-turns 60--allowedTools "Bash(git diff:*),Bash(git log:*),Bash(gh pr view:*),Bash(gh pr diff:*)"— read-only additions only; the write surface (git add/commit/push via the action's defaults) is unchanged, and WebSearch/WebFetch remain blocked by the action.Usage note: the turn cap is a ceiling, not a target — Q&A mentions still finish in a handful of turns; only genuinely large asks use the headroom. The owner-only trigger gate is untouched.
@allxsmith/bestax-bulma)create-bestax)@allxsmith/bestax-docs).github/workflows/claude.yml)Related Issue(s)
Refs #273 (the deep-review label work surfaced this:
@claudeis the documented substitute review path for PRs the tamper guard blocks, e.g. #270, and it was under-provisioned for that job)Type of Change
Checklist
CLAUDE.mdfiles are updated (n/a — behavior tuning only)Screenshots / Demos
n/a
Additional Context
"subtype": "error_max_turns", "num_turns": 21, "permission_denials_count": 4.claude.yml, which runs from the default branch onissue_commentevents — so unlike claude-review.yml changes, there's no tamper-guard interaction, and the change simply takes effect on merge.--allowedToolsoccurrences merge additively with the action's defaults — same pattern already used inclaude-review.ymlandbestaxbot-reply.yml.🤖 Generated with Claude Code
https://claude.ai/code/session_01Pohc8xLkdx4gwXkW3xd7up
Generated by Claude Code
Summary by CodeRabbit