Code review a pull request
Automated code review for GitHub pull requests that checks for bugs and CLAUDE.md compliance violations, posting inline comments with fix suggestions when issues are found.
/plugin marketplace add michelabboud/claude-code/plugin install code-review@claude-code-pluginsProvide a code review for the given pull request.
To do this, follow these steps precisely:
Launch a haiku agent to check if any of the following are true:
gh pr view <PR> --comments for comments left by claude)If any condition is true, stop and do not proceed.
Note: Still review Claude generated PR's.
Launch a haiku agent to return a list of file paths (not their contents) for all relevant CLAUDE.md files including:
Launch a sonnet agent to view the pull request and return a summary of the changes
Launch 4 agents in parallel to independently review the changes. Each agent should return the list of issues, where each issue includes a description and the reason it was flagged (e.g. "CLAUDE.md adherence", "bug"). The agents should do the following:
Agents 1 + 2: CLAUDE.md compliance sonnet agents Audit changes for CLAUDE.md compliance in parallel. Note: When evaluating CLAUDE.md compliance for a file, you should only consider CLAUDE.md files that share a file path with the file or parents.
Agent 3: Opus bug agent (parallel subagent with agent 4) Scan for obvious bugs. Focus only on the diff itself without reading extra context. Flag only significant bugs; ignore nitpicks and likely false positives. Do not flag issues that you cannot validate without looking at context outside of the git diff.
Agent 4: Opus bug agent (parallel subagent with agent 3) Look for problems that exist in the introduced code. This could be security issues, incorrect logic, etc. Only look for issues that fall within the changed code.
CRITICAL: We only want HIGH SIGNAL issues. This means:
We do NOT want:
If you are not certain an issue is real, do not flag it. False positives erode trust and waste reviewer time.
In addition to the above, each subagent should be told the PR title and description. This will help provide context regarding the author's intent.
For each issue found in the previous step by agents 3 and 4, launch parallel subagents to validate the issue. These subagents should get the PR title and description along with a description of the issue. The agent's job is to review the issue to validate that the stated issue is truly an issue with high confidence. For example, if an issue such as "variable is not defined" was flagged, the subagent's job would be to validate that is actually true in the code. Another example would be CLAUDE.md issues. The agent should validate that the CLAUDE.md rule that was violated is scoped for this file and is actually violated. Use Opus subagents for bugs and logic issues, and sonnet agents for CLAUDE.md violations.
Filter out any issues that were not validated in step 5. This step will give us our list of high signal issues for our review.
If issues were found, skip to step 8 to post inline comments directly.
If NO issues were found, post a summary comment using gh pr comment (if --comment argument is provided):
"No issues found. Checked for bugs and CLAUDE.md compliance."
Post inline comments for each issue using mcp__github_inline_comment__create_inline_comment:
path: the file path
line (and startLine for ranges): select the buggy lines so the user sees them
body: Brief description of the issue (no "Bug:" prefix). For small fixes (up to 5 lines changed), include a committable suggestion:
corrected code here
Suggestions must be COMPLETE. If a fix requires additional changes elsewhere (e.g., renaming a variable requires updating all usages), do NOT use a suggestion block. The author should be able to click "Commit suggestion" and have a working fix - no followup work required.
For larger fixes (6+ lines, structural changes, or changes spanning multiple locations), do NOT use suggestion blocks. Instead:
Fix [file:line]: [brief description of issue and suggested fix]
IMPORTANT: Only post ONE comment per unique issue. Do not post duplicate comments.
Use this list when evaluating issues in Steps 4 and 5 (these are false positives, do NOT flag):
Notes:
No issues found. Checked for bugs and CLAUDE.md compliance.
https://github.com/owner/repo/blob/$(git rev-parse HEAD)/foo/bar will not work, since your comment will be directly rendered in Markdown.L4-7)