Skip to content

ci: add Claude Code on-demand workflow for PRs#988

Open
evgeniko wants to merge 5 commits intomainfrom
ci/claude-code-action
Open

ci: add Claude Code on-demand workflow for PRs#988
evgeniko wants to merge 5 commits intomainfrom
ci/claude-code-action

Conversation

@evgeniko
Copy link
Collaborator

@evgeniko evgeniko commented Feb 24, 2026

Summary

Ports the Claude Code GitHub Actions workflow from native-token-transfers#818 to this repo.

  • Adds .github/workflows/claude.yml — triggers on @claude mentions in PR/issue comments, review comments, PR bodies, and issue bodies
  • Uses anthropics/claude-code-action@v1 with claude-opus-4-6
  • Read-only permissions: cannot push commits or modify files; can only post review comments
  • Requires CLAUDE_CODE_OAUTH_TOKEN secret to be configured in repo settings

Test plan

  • Add CLAUDE_CODE_OAUTH_TOKEN secret to repo settings
  • Comment @claude on a PR to verify the workflow triggers and Claude posts a review

🤖 Generated with Claude Code

@claude please review this PR

Summary by CodeRabbit

  • New Features
    • Automated code review workflow added — can be invoked from pull request or issue comments and from PR reviews to generate structured feedback.
    • Provides comprehensive analysis across correctness, security, performance, concurrency, resource management, error handling, and test coverage, with actionable, structured reports to improve code quality.

Adds a GitHub Actions workflow that allows repo collaborators to invoke
Claude Code on pull requests and issues by commenting `@claude`. Claude
can read code and post review comments but cannot modify files or push
changes.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@coderabbitai
Copy link

coderabbitai bot commented Feb 24, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5a324b9 and 4ddd666.

📒 Files selected for processing (1)
  • .github/workflows/claude.yml
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/claude.yml

📝 Walkthrough

Walkthrough

A new GitHub Actions workflow is added at .github/workflows/claude.yml to run the "Claude Code" action when issue comments, PR review comments, or PR reviews mention @claude; it resolves PR head SHAs for issue events, checks out full history, supplies an OAuth token, and passes a comprehensive system prompt and allowed tool list.

Changes

Cohort / File(s) Summary
Claude Code Review Automation
.github/workflows/claude.yml
Adds a new workflow that triggers on issue comments, PR review comments, and PR reviews mentioning @claude; configures permissions, resolves PR head SHA for comment events, checks out repo with full history, injects CLAUDE_CODE_OAUTH_TOKEN, supplies claude_args (model, allowedTools, and an extensive system prompt defining task routing and detailed code-review guidelines).

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant GitHub as "GitHub Events"
    participant Actions as "GitHub Actions"
    participant Repo as "Repository"
    participant Claude as "Claude Code Action"

    User->>GitHub: Post issue comment / PR review (mentions `@claude`)
    GitHub->>Actions: Trigger workflow (.github/workflows/claude.yml)
    Actions->>Repo: Resolve PR head SHA (if needed) & checkout (fetch-depth:0)
    Actions->>Claude: Run Claude Code with CLAUDE_CODE_OAUTH_TOKEN + claude_args
    Claude->>Actions: Return review results
    Actions->>GitHub: Post review comment / update PR
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A nibble, a hop, I scan each line,

I chase the bugs, make suggestions fine.
Mention my name, and I'll arrive—
Code reviewed, the repo thrives! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title directly and clearly describes the main change: adding a Claude Code GitHub Actions workflow for on-demand PR reviews triggered by @claude mentions.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch ci/claude-code-action

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Remove the pull_request and issues triggers that caused the workflow to
fire automatically when a PR body or issue title contained '@claude'.
The workflow now only triggers on explicit comment mentions.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@evgeniko
Copy link
Collaborator Author

@claude please review this PR

evgeniko and others added 2 commits February 24, 2026 14:33
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 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:
- Around line 25-28: For issue_comment-triggered runs the workflow must
explicitly checkout the PR head commit SHA instead of relying on
GITHUB_REF/GITHUB_SHA; add a prior step that queries the GitHub API (using
GITHUB_TOKEN, e.g., via actions/github-script or curl) to fetch the pull request
object and extract .head.sha, then pass that SHA into the actions/checkout@v4
step via the ref input (replace the current checkout that depends on
GITHUB_REF/GITHUB_SHA) so the checkout uses ref: <PR_HEAD_SHA> (keep
fetch-depth: 0) to avoid default-branch checkouts and TOCTOU risks.
- Around line 13-16: The current workflow `if` allows any commenter containing
"@claude" to trigger the job; restrict it by adding an `author_association`
guard to the condition so only trusted roles can invoke it (e.g., OWNER, MEMBER,
COLLABORATOR, or OWNER/MEMBER/CONTRIBUTOR as your policy). Update the three
sub-conditions that use contains(github.event.comment.body, '@claude') and
contains(github.event.review.body, '@claude') to also check the corresponding
author association field (github.event.comment.author_association or
github.event.review.author_association) against an allowlist of trusted
associations so external commenters cannot trigger the job.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a1f3ced and 5a324b9.

📒 Files selected for processing (1)
  • .github/workflows/claude.yml

- Restrict --allowedTools to read-only git subcommands and remove broad gh api:*
- Add author_association check to limit triggers to OWNER/MEMBER/COLLABORATOR
- Fix issue_comment checkout to use PR head SHA instead of default branch

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant