Skip to content

ci: give the @claude mention handler a review-sized budget - #280

Merged
allxsmith merged 2 commits into
mainfrom
ci/claude-mention-review-budget
Jul 11, 2026
Merged

allxsmith merged 2 commits into
mainfrom
ci/claude-mention-review-budget

Conversation

@allxsmith

@allxsmith allxsmith commented Jul 11, 2026 •

Copy link
Copy Markdown
Owner

Pull Request

Description

Two mention-triggered review tasks failed today with error_max_turns: the @claude verification on #267 (run 29136350689) and the substitute deep review on #270 (run 29147803092). Root cause from the job logs: claude.yml caps Claude at 20 turns and allowlists no diff tools, so review-sized requests burn turns on permission denials (git diff, gh pr diff were 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.

  • bulma-ui (@allxsmith/bestax-bulma)
  • create-bestax (create-bestax)
  • docs (@allxsmith/bestax-docs)
  • Other (please specify): repo tooling (.github/workflows/claude.yml)

Related Issue(s)

Refs #273 (the deep-review label work surfaced this: @claude is 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

  • Bug fix
  • New feature
  • Refactor
  • Documentation
  • Performance
  • Build tooling
  • Other (please describe):

Checklist

  • My code follows the project style guidelines
  • I have performed a self-review of my code
  • I have added tests that prove my fix is effective or that my feature works (n/a — workflow YAML; validated with a YAML parser)
  • I have added/updated documentation as needed (n/a — no label/convention change)
  • I have updated Storybook stories as needed (bulma-ui) (n/a)
  • My changes require a change to the documentation
  • All new and existing tests passed (no code paths touched)
  • Any relevant dependencies are updated (n/a)
  • If this PR changes commands, conventions, or package structure, the affected CLAUDE.md files are updated (n/a — behavior tuning only)

Screenshots / Demos

n/a

Additional Context

  • The failed runs' logs show the exact failure: "subtype": "error_max_turns", "num_turns": 21, "permission_denials_count": 4.
  • This PR edits claude.yml, which runs from the default branch on issue_comment events — so unlike claude-review.yml changes, there's no tamper-guard interaction, and the change simply takes effect on merge.
  • Multiple --allowedTools occurrences merge additively with the action's defaults — same pattern already used in claude-review.yml and bestaxbot-reply.yml.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Pohc8xLkdx4gwXkW3xd7up


Generated by Claude Code

Summary by CodeRabbit

  • Chores
    • Updated the automated review workflow to allow longer analysis runs.
    • Expanded permitted capabilities during automated reviews to include a broader set of repository inspection commands and selected package-management actions (such as installing, running scripts, testing, and executing filtered commands).

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
@coderabbitai

coderabbitai Bot commented Jul 11, 2026 •

Copy link
Copy Markdown

Review Change Stack

Walkthrough

The 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.

Changes

Claude workflow configuration

Layer / File(s) Summary
Configure Claude action limits and tools
.github/workflows/claude.yml
Updates claude_args to allow 60 turns and permits git diff, git log, gh pr view, gh pr diff, and specified pnpm commands.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: expanding Claude's turn budget for review mentions.
Description check ✅ Passed The description follows the template and covers summary, affected package, issue reference, change type, checklist, and additional context.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ci/claude-mention-review-budget

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown
Contributor

Preview Deployment

Preview URL: https://eef602cf.bestax.pages.dev

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
.github/workflows/claude.yml (1)

72-80: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Allow Claude to use the provisioned toolchain

--allowedTools only adds permissions; it doesn’t include pnpm or node, so the setup steps won’t help Claude run tests/lint/build. Add the needed Bash(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

📥 Commits

Reviewing files that changed from the base of the PR and between 2cfe53c and b5f8c8a.

📒 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
@github-actions

Copy link
Copy Markdown
Contributor

Preview Deployment

Preview URL: https://f1ec3d74.bestax.pages.dev

@allxsmith
allxsmith merged commit dfaff24 into main Jul 11, 2026
10 checks passed

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between b5f8c8a and 739d79f.

📒 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:*)"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 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:


🌐 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:


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.

@github-actions

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 3.2.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 5.4.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 1.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@allxsmith
allxsmith deleted the ci/claude-mention-review-budget branch July 31, 2026 04:46
@bestax-release-bot

Copy link
Copy Markdown

🎉 This PR is included in version 1.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants