Skip to content
AI Skills Central

Type to search Agent Skills, workflows, tutorials, tools and the glossary.

Workflow recipe

Code review with Claude Code on every pull request

Write your checklist once, dry-run it locally, then review every pull request in GitHub Actions and post the findings.

By Checked Intermediate45 min6 steps
Bookmark

Bookmarks are kept in your free account, so you can find this page again on any device.

Sign in to bookmark
On this page

To set up AI code review with Claude Code, write your review checklist as a file in the repository and dry-run it locally on a real pull request. Then install the Claude GitHub app, add a workflow that uses anthropics/claude-code-action@v1, test it on a pull request with a planted problem, and tune the noise for a week before deciding.

This recipe is for teams that already review pull requests by hand and want a first pass that catches the boring things before a person looks. The review rules are written once and the same review runs locally and in Anthropic’s official GitHub Action.

The automated review does not replace a human approval. Treat it like a careful colleague who reads every diff but does not know why the change was made.

EditorAbout 10 min

1. Write your review checklist as a file

Most AI reviews are noisy because nobody told the reviewer what matters. Put the rules your team already applies into a short Markdown file in the repository, for example docs/review-checklist.md. Keep it to things a reviewer can check from the diff.

# Review checklist

Report only problems you can point to in the diff. Skip style issues that the linter already enforces.

## Must fix
- New or changed behaviour without a test that would fail if it broke.
- Errors swallowed silently (empty catch blocks, ignored return values).
- SQL built with string concatenation or template strings instead of parameters.
- Secrets, tokens or personal data in code, fixtures or logs.
- Public API changes (routes, exported functions, database columns) without a migration or changelog note.

## Should fix
- Functions over ~60 lines that mix I/O and logic.
- Copy-pasted blocks that differ in one value.
- Missing input validation at a trust boundary (HTTP handlers, queue consumers).

## Ignore
- Formatting, import order, naming preferences.
- Generated files under `dist/`, `*.lock` and `drizzle/migrations/`.

Two rules make the difference: “report only problems you can point to in the diff” and an explicit ignore list.

TerminalAbout 10 min

2. Dry-run the review locally on a real pull request

Before you automate anything, check that the checklist produces useful comments. Pick a recently merged pull request that had a real problem in review, and run Claude Code in the repository.

cd your-repo
claude

Then paste this prompt, replacing the number:

Local review prompt · Claude Code
Review pull request #[PR NUMBER] in this repository. 1. Run: gh pr diff [PR NUMBER] 2. Read docs/review-checklist.md and apply it to the diff. 3. Open any file you need for context, but only comment on lines the PR changed. Output a list of findings. For each one give: file and line, which checklist rule it breaks, why it matters in one sentence, and a suggested fix. Put "Must fix" items first. If you find nothing that breaks the checklist, say so in one line and stop.

Compare the output with what the human reviewer actually said. If it misses the real problem, add a rule to the checklist. If it reports noise, add the noise to the “Ignore” section. Two or three rounds are usually enough.

Claude CodeAbout 5 min

3. Install the Claude GitHub app and add your API key

The quickest route is the installer inside Claude Code. In the same session, run:

/install-github-app

It walks you through installing the Claude GitHub app on the repository and storing your key as a repository secret. You must be a repository admin.

If you prefer to do it by hand: install the app from github.com/apps/claude, then go to the repository’s Settings, Secrets and variables, Actions, and add a secret named ANTHROPIC_API_KEY.

EditorAbout 10 min

4. Add the review workflow

Create .github/workflows/claude-review.yml. This is based on the official example in the action’s repository, with the prompt pointed at your checklist and draft pull requests skipped.

name: Claude review

on:
  pull_request:
    types: [opened, synchronize, ready_for_review, reopened]

concurrency:
  group: claude-review-${{ github.event.pull_request.number }}
  cancel-in-progress: true

jobs:
  review:
    if: github.event.pull_request.draft == false
    runs-on: ubuntu-latest
    permissions:
      contents: read
      pull-requests: write
      id-token: write
    steps:
      - name: Checkout repository
        uses: actions/checkout@v6
        with:
          fetch-depth: 1

      - name: Review with Claude
        uses: anthropics/claude-code-action@v1
        with:
          anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
          track_progress: true
          prompt: |
            REPO: ${{ github.repository }}
            PR NUMBER: ${{ github.event.pull_request.number }}

            Review this pull request against docs/review-checklist.md.
            Only comment on lines this PR changes, and only when a checklist rule applies.
            Use inline comments for specific lines. Finish with one top-level comment
            that lists Must fix items first, then Should fix. If nothing applies,
            post a single comment saying the checklist found no issues.
          claude_args: |
            --allowedTools "mcp__github_inline_comment__create_inline_comment,Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*)"

What the pieces do:

  • concurrency cancels a running review when someone pushes again, so you pay for one review per push, not a queue of stale ones.
  • track_progress: true posts a progress comment with checkboxes and updates it as the review runs.
  • --allowedTools limits the agent to reading the pull request and posting comments. It cannot push code from this workflow.

Commit the workflow and the checklist to your default branch.

GitHubAbout 5 min

5. Test it on a pull request with a planted problem

Open a small pull request that breaks one “Must fix” rule on purpose, for example an empty catch block or a SQL string built with a template literal. Within a few minutes you should see a progress comment, then inline comments and a summary.

If nothing happens, open the Actions tab and read the job log. The common causes are in “When it goes wrong” below.

EditorAbout 5 min

6. Tune the noise for a week, then decide

Run it on real pull requests for a week and keep a tally: useful findings, wrong findings, and things it should have caught. Then adjust:

  • Wrong or petty findings: add them to the “Ignore” section of the checklist.
  • Missed problems: add a concrete rule, ideally with an example of the bad pattern.
  • Large generated diffs: add a paths-ignore filter under pull_request in the workflow.

Agree as a team what the comment means. A good default is that “Must fix” items need a reply (fix or explain), and everything else is advisory.

Check it worked

Verification checklist

0 of 6 done

When it goes wrong

If the workflow never starts, check that the file is on the default branch and the on: events match. Pull requests from Dependabot and other bots are ignored by default: the action only runs for users with write access unless you configure allowed_bots.

If pull requests from forks get no review, that is by design. GitHub does not pass repository secrets to workflows triggered from forks, and the action checks that the author has write access. On open source projects, run reviews for maintainers’ branches or have a maintainer trigger them.

If the job fails with a permission error when posting comments, it is missing pull-requests: write. Organisation policies can also force the default GITHUB_TOKEN to read-only, so check the organisation’s Actions settings too.

If you get comments on unchanged code or a wall of nitpicks, tighten the prompt (“only lines this PR changes”) and grow the “Ignore” list. Vague rules such as “code should be clean” produce vague comments.

If costs are higher than you expected, remember that every push starts a run. Keep concurrency with cancel-in-progress, skip drafts, exclude generated paths, and watch spend in the Anthropic Console for the first week.

Variations

With Codex instead of Claude Code, connect Codex cloud to GitHub and comment @codex review on a pull request. Codex follows the review guidance in your AGENTS.md, so paste the same checklist there under a “Review guidelines” heading. Locally, /review in the Codex CLI reviews your working tree before you push.

To review only when someone asks, trigger on issue_comment and check for a phrase such as @claude review. The action’s repository has examples of comment-triggered workflows.

You can also start from a published review skill instead of your own checklist, such as the code-review skill, and point the prompt at it. Read it first and keep the parts that match your team’s rules.

For security findings with fewer false positives, follow the AI security review of a pull request. Reviewing AI-written code covers what a person still has to check, and running coding agents headless in CI explains the CI side in more depth. The same action can also triage GitHub issues. The rolling out coding agents to a team path puts review in context, and more recipes are in the AI workflow examples hub.

Outcome and tools

Outcome
Pull requests get an automated review comment based on your team's review checklist.
For
Developers, Team leads
Variants for
Claude Code, Codex

Check your understanding

Code review with Claude Code quiz

A review checklist in the repository, a local dry run, the GitHub app and API key secret, the review workflow, a planted-problem test, tuning the noise, and what goes wrong.

7 questions · pass mark 70%

Question 1 of 70 answered
  1. Why do most AI code reviews come out noisy, according to the recipe?
  • Your first session with Claude Code

    Install it, run it in a real repository, approve its first changes, commit a reviewed edit and learn the commands you will use daily.

    TutorialBeginner30 min

  • Write a useful AGENTS.md: example, template and test

    An AGENTS.md example and template with build and test commands, conventions and traps, plus a before-and-after task that shows whether the file actually helps.

    WorkflowBeginner30 min6 steps

  • Differential security review (Trail of Bits)

    Trail of Bits' security-focused review of a PR, commit or diff that scales its depth to the change, measures blast radius and writes a Markdown report.

    Agent Skill

  • AI code review

    Using models to review pull requests, and reviewing AI-written code critically.

    SkillIntermediate

Back to top