GitHub Actions and Code Review
A lot of your busywork lives in the pull request, so it's a good place to hand work to Claude. You can do that in two ways: turn on a managed review service, or set up a GitHub Action yourself.
Which one should you use?
The two solve different problems. Use Code Review for comments on pull requests, and the GitHub Action when Claude should do work in CI.
| Code Review | GitHub Action | |
|---|---|---|
| What it does | Posts findings on pull requests | Runs any job you'd write a workflow for |
| Who sets it up | An Owner of your Claude organization | A repo admin |
| What you need | A Team or Enterprise plan | A way to sign in, such as an API key |
| What you maintain | Nothing | A workflow file |
If you aren't on a Team or Enterprise plan, skip ahead to the GitHub Action.
Turn on Code Review
Code Review runs on Anthropic's infrastructure, so there's nothing to build or host. An Owner of your Claude organization sets it up once:
- Start the setup. Open your organization's Code Review settings(opens in new tab) and click the switch. The setup guide(opens in new tab) shows each click.
- Pick the repos. Install the Claude GitHub app and choose which repos it watches. If you don't own the GitHub organization, an owner has to install and link the app first.
- Confirm the setup. If the setup ends in a dialog, Code Review stays off until you confirm it. If you weren't asked to pick repos, add them from the Repositories table.
- Set the timing. Each repo starts with a review on every push, which runs the most reviews and costs more. Click Edit on the repo's row to review once when a PR opens, or only when someone comments
@claude review.
What Code Review does
A set of review agents checks each diff against your full codebase. They remove duplicates and rank what's left, so you read a handful of real issues. Each one lands as an inline comment with a severity, an explanation, and a suggested fix. The check run sums them up in a table.
By itself, Code Review only comments, so the decision and the fix stay with you. It doesn't approve or block a PR, and it doesn't push fixes. Your repo's GitHub branch rules decide what merges.
To check your fix before you push, run /code-review in your own terminal. That starts a separate review of your diff, and --fix applies that review's findings to your working tree.
Set up the GitHub Action
When the job goes beyond review, use the action, anthropics/claude-code-action@v1. Run /install-github-app in Claude Code, which needs admin rights on the repo. It walks you through installing the GitHub app and saving your Anthropic API key as a repo secret. It can also add workflow files on a new branch, which turn on once you create and merge that pull request.
The prompt input decides when Claude runs. Without one, the action waits for someone to mention @claude. With one, Claude runs as soon as the event fires. The next two workflows show one of each.
Respond to @claude
This workflow has no prompt, so it waits for @claude in PR and issue comments. If setup added a claude.yml, merge that one and don't add a second. Otherwise, save this one as .github/workflows/claude.yml. The id-token: write permission lets the action sign in as the Claude GitHub app:
name: Claude Code
on:
issue_comment:
types: [created]
pull_request_review_comment:
types: [created]
jobs:
claude:
if: contains(github.event.comment.body, '@claude')
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
issues: write
id-token: write
actions: read
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 1
- uses: anthropics/claude-code-action@v1
with:
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
claude_args: "--model claude-sonnet-5"Suppose someone comments @claude implement the spec in the linked GitHub issue on a pull request. The action picks it up, and Claude pushes commits and comments with what it did.
Run on a schedule
This workflow has a prompt, so it runs on its own at 9:00 UTC every day. The workflow_dispatch line also lets you start it by hand from the Actions tab. The prompt names the repo, because this job has no checkout step:
name: Daily report
on:
schedule:
- cron: "0 9 * * *"
workflow_dispatch:
jobs:
report:
runs-on: ubuntu-latest
permissions:
contents: read
issues: read
id-token: write
steps:
- uses: anthropics/claude-code-action@v1
with:
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
prompt: "Generate a summary of yesterday's commits and open issues in ${{ github.repository }}"
claude_args: |
--permission-mode dontAsk
--allowedTools "mcp__github__list_commits,mcp__github__list_issues"A scheduled run doesn't post a comment on its own. You read the result in the run's log, in the Actions tab.
Limit what a run can do
No one is at the keyboard during a run, so give each job only what it needs. The claude_args input passes CLI arguments straight to Claude Code, and three of them set the limits:
--max-turnscaps the agent loop, so it can't run forever. A run that goes over the cap fails. So leave room, because even a small@claudecode change can take more than five turns.--allowedToolslists the tools Claude can use without asking. For a report, list only read-only tools.--permission-mode dontAskdenies anything else that needs approval. Use it on a job like the report, because it would also deny file edits you haven't listed. Without it, the action defaults to auto mode, where a safety review can let unlisted tools through.
Adapt it to your setup
Both workflows sign in with an API key and act as the Claude GitHub app. If your setup differs, start from these inputs:
| If you want to | Use |
|---|---|
| Sign in with a Claude subscription | claude_code_oauth_token |
| Store no secret | Workload identity federation, set up through a Claude Console service account |
| Run on Amazon Bedrock | use_bedrock: "true" |
| Run on Google Cloud's Agent Platform | use_vertex: "true" |
| Run on Microsoft Foundry | use_foundry: "true" |
| Act as something other than the app | github_token |
| Listen for a different phrase | trigger_phrase |
With a subscription, point that input at the CLAUDE_CODE_OAUTH_TOKEN secret and remove the API key line. With a cloud provider, you sign in with your cloud account, which takes a few more setup steps(opens in new tab). If you change the trigger phrase, change the workflow's if line to match.
Key takeaways
- Turn on Code Review when you want findings on pull requests with nothing to maintain.
- Set up the action when Claude should make changes or run on a schedule.
- Use
claude_argsto limit what each run can do.