7.6 KiB
allowed-tools, description
| allowed-tools | description |
|---|---|
| Bash(gh issue view:*), Bash(gh search:*), Bash(gh issue list:*), Bash(gh pr comment:*), Bash(gh pr diff:*), Bash(gh pr view:*), Bash(gh pr list:*), mcp__github_inline_comment__create_inline_comment | Code review a pull request |
Provide 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:
- The pull request is closed
- The pull request is a draft
- The pull request does not need code review (e.g. automated PR, trivial change that is obviously correct)
- Claude has already commented on this PR (check
gh pr view <PR> --commentsfor 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:
- The root CLAUDE.md file, if it exists
- Any CLAUDE.md files in directories containing files modified by the pull request
-
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:
- Objective bugs that will cause incorrect behavior at runtime
- Clear, unambiguous CLAUDE.md violations where you can quote the exact rule being broken
We do NOT want:
- Subjective concerns or "suggestions"
- Style preferences not explicitly required by CLAUDE.md
- Potential issues that "might" be problems
- Anything requiring interpretation or judgment calls
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.
-
Post summary comment FIRST using
gh pr comment(if--commentargument is provided):- Total number of issues found
- Brief one-line summary of each issue (no "Bug:" prefix)
- Or if no issues: "No issues found. Checked for bugs and CLAUDE.md compliance."
When writing your comment, follow these guidelines: a. Keep your output brief b. Avoid emojis c. Link and cite relevant code, files, and URLs for each issue d. When citing CLAUDE.md violations, you MUST quote the exact text from CLAUDE.md that is being violated (e.g., CLAUDE.md says: "Use snake_case for variable names")
-
THEN post inline comments for each issue using
mcp__github_inline_comment__create_inline_comment:path: the file pathline(andstartLinefor ranges): select the buggy lines so the user sees thembody: Brief description of the issue (no "Bug:" prefix). For small fixes (up to 5 lines changed), include a committable suggestion:For larger fixes (6+ lines or structural changes), do NOT use suggestion blocks. Instead:corrected code here- Describe what the issue is
- Explain the suggested fix at a high level
- Include a copyable prompt for Claude Code that the user can use to fix the issue, formatted as:
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):
- Pre-existing issues
- Something that appears to be a bug but is actually correct
- Pedantic nitpicks that a senior engineer would not flag
- Issues that a linter will catch (do not run the linter to verify)
- General code quality concerns (e.g., lack of test coverage, general security issues) unless explicitly required in CLAUDE.md
- Issues mentioned in CLAUDE.md but explicitly silenced in the code (e.g., via a lint ignore comment)
Notes:
- Use gh CLI to interact with GitHub (e.g., fetch pull requests, create comments). Do not use web fetch.
- Create a todo list before starting.
- You must cite and link each issue (e.g., if referring to a CLAUDE.md, include a link to it).
- For your final comment, follow the following format precisely (assuming for this example that you found 3 issues):
Code review
Found 3 issues:
- (CLAUDE.md says: "")
- (some/other/CLAUDE.md says: "")
- (bug due to )
If this code review was useful, please react with 👍. Otherwise, react with 👎.
- Or, if you found no issues:
Auto code review
No issues found. Checked for bugs and CLAUDE.md compliance.
If this code review was useful, please react with 👍. Otherwise, react with 👎.
- When linking to code, follow the following format precisely, otherwise the Markdown preview won't render correctly:
c21d3c10bc/package.json (L10-L15)- Requires full git sha
- You must provide the full sha. Commands like
https://github.com/owner/repo/blob/$(git rev-parse HEAD)/foo/barwill not work, since your comment will be directly rendered in Markdown. - Repo name must match the repo you're code reviewing
-
sign after the file name
- Line range format is L[start]-L[end]
- Provide at least 1 line of context before and after, centered on the line you are commenting about (eg. if you are commenting about lines 5-6, you should link to
L4-7)