Fix Claude workflow scope for pushing workflow files#13
Conversation
The GitHub App token used by claude-code-action lacks the `workflow` scope, preventing Claude from pushing changes to .github/workflows/ files. Pass BOT_TOKEN (a PAT with repo + workflow scopes) via the github_token input to fix this. Closes #8, unblocks #9 Co-Authored-By: Claude <noreply@anthropic.com>
WalkthroughA GitHub Actions workflow is updated to pass the Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.github/workflows/claude.yml:
- Line 38: Add a job-level trust check so the workflow only runs for trusted
commenters instead of any user; update the job that uses the
BOT_TOKEN/github_token to include an if: condition checking the event
commenter’s author_association (e.g., use
contains('OWNER,CONTRIBUTOR,COLLABORATOR,MEMBER',
github.event.comment.author_association) or equivalent) so only those
associations can trigger the job, and keep the existing github_token: ${{
secrets.BOT_TOKEN }} usage unchanged.
| uses: anthropics/claude-code-action@v1 | ||
| with: | ||
| claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} | ||
| github_token: ${{ secrets.BOT_TOKEN }} |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
cat -n .github/workflows/claude.yml | head -80Repository: supermodeltools/supermodeltools.github.io
Length of output: 2034
🏁 Script executed:
grep -A 20 "^jobs:" .github/workflows/claude.yml | head -30Repository: supermodeltools/supermodeltools.github.io
Length of output: 864
Gate this workflow to trusted authors—anyone can trigger it right now.
Your workflow runs on user comments (issue_comment, pull_request_review_comment, etc.), and right now any random person can write @claude in an issue to trigger it. The job then runs with write permissions and passes your BOT_TOKEN secret to the Claude action. That's risky.
Think of it like this: you're telling a stranger "Hey, anytime you write a magic word, my bot will show up and do stuff with full write access to my repo."
The fix is simple—add a trust check to the job condition. GitHub gives us the author_association field for exactly this purpose. It tells us if the commenter is the owner, a team member, a collaborator, or a random public person.
Add author trust check to the job condition
jobs:
claude:
if: |
- (github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) ||
- (github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) ||
- (github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) ||
- (github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')))
+ (github.event_name == 'issue_comment' &&
+ contains(github.event.comment.body, '@claude') &&
+ contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.comment.author_association)) ||
+ (github.event_name == 'pull_request_review_comment' &&
+ contains(github.event.comment.body, '@claude') &&
+ contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.comment.author_association)) ||
+ (github.event_name == 'pull_request_review' &&
+ contains(github.event.review.body, '@claude') &&
+ contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.review.author_association)) ||
+ (github.event_name == 'issues' &&
+ (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')) &&
+ contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.issue.author_association))🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In @.github/workflows/claude.yml at line 38, Add a job-level trust check so the
workflow only runs for trusted commenters instead of any user; update the job
that uses the BOT_TOKEN/github_token to include an if: condition checking the
event commenter’s author_association (e.g., use
contains('OWNER,CONTRIBUTOR,COLLABORATOR,MEMBER',
github.event.comment.author_association) or equivalent) so only those
associations can trigger the job, and keep the existing github_token: ${{
secrets.BOT_TOKEN }} usage unchanged.
Adds
github_token: ${{ secrets.BOT_TOKEN }}to claude-code-action so Claude can push .github/workflows/ files. The default App token lacksworkflowscope which blocks issues #8 and #9.Summary by CodeRabbit