Imported from hexsis-llc/skills (
skills/claude-pr-review/SKILL.md). Install upstream withnpx skills add hexsis-llc/skills --skill claude-pr-review. Copyright stays with the author.
Claude PR Review
The Hexsis method for automated Claude pull-request review. The pull request is untrusted input steering an agent that holds a model token and a GitHub token, so the setup is review-only: Claude reads, judges, and posts one formal review, and can do nothing else. Every control in the templates closes a path that has failed in practice. Keep them all unless the user decides otherwise with the trade-off in front of them.
What the setup does:
- Automatic review of ready, same-repository pull requests. A workflow step writes the diff as line-oriented files. Read-only
diff-reviewersub-agents read every source chunk in parallel, arules-reviewerchecks the change against the repository's rules, and a freshfinding-validatorconfirms each candidate finding. Claude then submits exactly one formal review on the head commit. @claudementions on pull requests from users with write access, answered inline, on public and private repositories. Mentions cannot submit a verdict.- Tracking comments. Each automatic review posts a
github-actionscomment that says Claude is reviewing, and a later job edits it to say the review finished, failed, was cancelled, or was skipped, with a link to the review job. A mention gets the action's ownclaude[bot]tracking comment. If a mention fails or is cancelled while that comment still says "working", agithub-actionsnote links the failed job. - An informational job summary of turns, denied tool calls, sub-agents, the diff lines and files read, and the review the run left. It never fails the job or dismisses a review: coverage is reported, not enforced, and the verdict is advisory.
Files
| File | Becomes | Role |
|---|---|---|
templates/claude-review.yml |
.github/workflows/claude-review.yml |
The review workflow |
templates/claude-review-gate.mjs |
scripts/claude-review-gate.mjs |
Builds the diff manifest and the job summary |
templates/check-workflow-policy.mjs |
scripts/check-workflow-policy.mjs |
Enforces the secret and permission boundary in CI, and keeps the job token out of every workflow's checkouts |
templates/*.test.mjs |
scripts/*.test.mjs |
node:test suites for both scripts |
The scripts need Node.js 22 or later and no dependencies. They go in scripts/ unless that directory feeds a build; see Choose the script directory. Search the templates for PARAMETER to find each repo-specific choice.
Parameters
| Parameter | Default | Where it lives |
|---|---|---|
| Runner label | ubuntu-latest |
runs-on in job review only. A self-hosted label also goes in .github/actionlint.yaml under self-hosted-runner.labels. The runner needs sudo apt access and Docker, or bubblewrap and the MCP image baked in. Jobs track and report stay on ubuntu-latest: they run only bash steps, should not take self-hosted slots, and report must not depend on a runner that may have failed. |
| Model | claude-sonnet-5-5 |
--model in claude_args |
| Review rules location | AGENTS.md, CLAUDE.md |
REVIEW_RULES in the job env. Read from the default branch's copy, plus the nearest same-named file above each changed path. |
| Trigger set | automatic review and @claude mentions |
on:, the job if:, and trigger_phrase |
| Docs-governance mode | off |
REVIEW_GOVERNANCE in the job env. See Docs-governance mode. |
| Auth | CLAUDE_CODE_OAUTH_TOKEN secret |
the action's token input, plus reviewSecret and reviewTokenInput in the policy check. For an Anthropic API key, use anthropic_api_key and ANTHROPIC_API_KEY. |
| Source and skim classes | everything is source except lock files, fixtures, snapshots, and docs | the regexes at the top of the script |
| Chunk size | 800 diff lines | defaultChunkLines in the script |
| Max turns, timeout | 100 turns, 30 minutes | --max-turns, timeout-minutes. Sub-agent turns do not count toward max turns. |
| Transcript retention | 7 days | the upload step. On a public repository, anyone can download the transcript. |
| Script directory | scripts/, or .github/scripts/ when scripts/ feeds a build |
every reference listed in Choose the script directory |
Set Up
1. Survey the target repository
Read, don't assume:
- the default branch, the existing workflows, and the CI job where Node checks run;
- the rules files (
AGENTS.md,CLAUDE.md,REVIEW.md, or nested ones); - the runner the repository already uses, for job
review; - branch protection and rulesets on the default branch, especially required-review rules;
- whether any workflow uses
secrets: inheritortoJSON(secrets). The policy check blocks both, because they would hand the review secret to another workflow; - every
actions/checkoutin every workflow, and whether it setspersist-credentials: false. The policy check requires that flag on each one, because later steps, third-party actions included, would otherwise find the job token in.git/config. Tell the user which existing checkouts need the flag added, and whether any of them pushes with that token and needs another credential instead; - whether every workflow fits the policy check's YAML subset: block-style mappings and sequences, single-line scalars and flow lists, and
|or>block scalars, with{}the only flow mapping. The check parses every workflow and fails closed on one it cannot read; - the docs-governance markers: an
AGENTS.mdthat routes to thedocs-governanceskill or a decision register (see Docs-governance mode). - whether anything builds from
scripts/: a DockerfileCOPY, an image recipe, a packaging list, or a hash or digest computed over the directory. If so, the review scripts go in.github/scripts/(see Choose the script directory).
Then show the user the parameter table with the values you chose, and get their confirmation. Done when every parameter has a value the user has seen.
Choose the script directory
The scripts default to scripts/. Some repositories copy or hash scripts/ into a build artifact, such as a container image or a runner-image recipe digest. Review scripts there would land in that artifact and change its digest on every review-script edit. Search the repository for scripts/ in Dockerfiles, build files, and workflows before you choose. If scripts/ feeds a build, use .github/scripts/ and set every reference to it:
- the two
node "$RUNNER_TEMP/trusted-rules/scripts/claude-review-gate.mjs"lines in the workflow, inFetch pull-request contextandSummarize review; - the
scripts/check-workflow-policy.mjspath in the workflow's header comment; - the test and policy commands in the CI workflow (step 3);
- the policy check's default root,
new URL('..', import.meta.url), which assumes the script sits one directory below the repository root. From.github/scripts/it isnew URL('../..', import.meta.url).
2. Resolve the pins
The template pins every action by commit SHA. Re-resolve each pin rather than trusting the template's:
- Claude action. Take the latest release with
gh release list -R anthropics/claude-code-action, then get its commit withgh api repos/anthropics/claude-code-action/commits/<tag> --jq .sha. - GitHub MCP image. At that SHA, read the image tag from
src/mcp/install-mcp-server.ts. Get its digest withdocker buildx imagetools inspect ghcr.io/github/github-mcp-server:<tag>. UpdateTAGandDIGESTin thePull GitHub MCP serverstep. - Built-in sub-agent types. At that SHA,
base-action/action.ymlnames the bundled Claude Code version. List that version's built-in sub-agent types from the Claude Code sub-agents docs, plusfork, which gets the main agent's tools. Put each type asAgent(<type>)inDENIED_TOOLSand inbuiltInAgentsin the policy check. - Action inputs. Check the action's
action.ymlat that SHA for every input the template passes. Inputs are renamed across major versions. - Other actions. Resolve
actions/checkout,actions/setup-node, andactions/upload-artifactto their latest release SHAs.
Done when every uses: line carries a SHA you resolved in this session, with its tag in a comment.
3. Install the templates
Copy the files into place and set every parameter. Add persist-credentials: false to each existing checkout the survey found without it. Keep each security control intact. Before you change one, read references/security-model.md; it explains what each control closes. Keep the review prompt's output contract intact; the job summary quotes the review it finds but checks nothing in it.
Add node --test scripts/claude-review-gate.test.mjs scripts/check-workflow-policy.test.mjs and node scripts/check-workflow-policy.mjs to the repository's existing CI. Use the script directory you chose in step 1. Adapt the test fixtures to the repository's own paths when you change the classes.
4. Validate locally
Run all of these:
actionlint1.7.8 or later on the workflow (docker run --rm -v "$PWD:/repo" -w /repo rhysd/actionlint:1.7.12 .github/workflows/claude-review.yml). The template passes with no findings. Older versions do not knowjob.check_run_id.- The two test suites.
- The policy check against the repository.
Done when all three are green. Report any check you could not run.
5. Hand the manual steps to the user
The agent cannot do these. Give them to the user as a checklist:
- Install the Claude GitHub App on the repository: https://github.com/apps/claude. It is the identity that posts reviews, through the OIDC token exchange.
- Create the model credential and add it as a repository secret. For a Claude subscription, run
claude setup-tokenand save the result asCLAUDE_CODE_OAUTH_TOKEN. For an API key, save it asANTHROPIC_API_KEY. The OAuth token lasts a year, and deleting the secret does not revoke it. - Merge the setup pull request without its own review. On the setup PR, the
Claude reviewjob fails atFetch pull-request contextwithMODULE_NOT_FOUND: that step runs the gate script from the default branch's copy, and the script is not there until the PR merges. Its tracking comment then says the review failed. This is expected and harmless. After the merge, every later PR that edits the workflow also gets no Claude review, by design: the token exchange refuses a workflow that differs from the default branch's copy, so the job passes and its summary warns that the action skipped Claude. A human reviews those PRs. - Decide whether a
claude[bot]approval counts toward any required-review rule. The safe default is that it does not, and merging stays human.
If the user runs /install-github-app instead, keep the app and the secret it creates. Discard its generated workflow in favor of this one.
6. Verify on a test pull request
After the setup is merged, open a small same-repository PR that changes one source file, one lock or doc file, and holds a planted defect. Then check:
- The
Claude reviewjob runs, and the GitHub MCP server connects. - The job summary shows zero denied tool calls, one
diff-reviewerper chunk, andSource files read in full: N of N. -
claude[bot]posts exactly one review on the head commit:REQUEST_CHANGES, with the planted defect as its own inline comment, following the output contract. - A follow-up push that fixes the defect re-runs the review and yields
APPROVE. A run still in progress for the older commit is cancelled. - A
github-actionscomment says Claude is reviewing the head commit, and ends as finished with a link to the review job. - A PR comment with
@claude <question>from a write-access user gets an inline reply and no verdict, andclaude[bot]'s tracking comment ends in a finished state. On a private repository, theRun Claudelog showsSuccessfully checked out PR branch. - Optional: cancel a review run by hand. Its tracking comment says the review was cancelled and links the job.
- A draft PR and a fork PR are skipped.
- The transcript artifact downloads.
Done when every box is checked, or each unchecked box is reported to the user with its run link. A green job that posted nothing is a failure; see references/troubleshooting.md.
Review Output Contract
The automatic review always ends with one formal review on the head commit:
- Confirmed findings:
REQUEST_CHANGES, with each finding as its own inline comment on its diff line. Findings never go into the body or a separate PR comment. - No confirmed finding:
APPROVE.
The verdict is never COMMENT.
The body is a short summary, never a list:
## Claude review: Changes requested
One or two paragraphs: what was checked, at most two findings by name (most severe
first), and the rest counted by severity ("there are 1 more critical, 3 major, and 2
minor findings, each in its own inline comment").
Each inline comment opens with **<Severity> · <Category>: <title>**, then Trigger, Impact, and Evidence with links, and adds a suggestion block only when it fully fixes the issue.
- Severity is Critical (breaks security, data, or a review rule, or fails for ordinary input), Major (fails on a reachable but narrower path), or Minor (a real defect with limited impact).
- Category is Correctness, Security, or Rules.
- Style, naming, and preference are never findings.
The prompt in the template carries the full contract. Nothing enforces it: the job summary reports the review this run left and warns when there is none or more than one, but the job still passes.
Docs-governance mode
Some repositories follow the docs-governance method: docs are the product authority, owner decisions live in one dated register, lasting docs live in docs/ by kind, and scratch stays in an ignored .scratch/. The docs-governance skill covers that method; this skill does not depend on it. Detect such a repository by an AGENTS.md or CLAUDE.md that routes to the docs-governance skill or to a decision register (by default docs/product-decisions.md) and a docs index (docs/README.md).
When you detect it, suggest REVIEW_GOVERNANCE: 'on' to the user. With it on, the rules-reviewer also:
- reads the
docs-governanceskill from the trusted copy when the repository vendors it (for example.agents/skills/docs-governance/SKILL.md), and the register entries, ADRs and docs the change touches or relies on; - checks that the change agrees with every current register decision, that a decision the change records or changes left no contradicting doc unamended (current docs amended, dated records and research given a dated note), that no scratch (working notes, plans, handoffs, one-task specs) is committed, and that a moved or removed doc left no broken link and stayed listed correctly in the index.
A change that breaks one of these is a Rules finding that cites the decision's title or the doc's path. Leave the mode off everywhere else.
A repository on the earlier record-based model (CHG-* and DEC-* record files, a document registry) keeps its own governance docs; the rules reviewer reads them through AGENTS.md like any other review rules.
References
- references/security-model.md: read before changing any control, and when a user asks why the workflow is shaped this way. It covers least privilege, untrusted content, forks, mention triggers, the private-repository mention fetch, tracking comments, secrets and OIDC, no shell, read-only sub-agents, why coverage is reported but not enforced, and residual risks.
- references/troubleshooting.md: read when a run fails, ends early, posts nothing, or reads too little.
