You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
description: Code review changes since branch diverged from default branch
4
4
---
5
5
6
-
Provide a code review for the given pull request.
6
+
Review the code changes introduced since this branch diverged from the default branch (main).
7
7
8
8
**Agent assumptions (applies to all agents and subagents):**
9
9
- All tools are functional and will work without error. Do not test tools or make exploratory calls. Make sure this is clear to every subagent that is launched.
10
10
- Only call a tool if it is required to complete the task. Every tool call should have a clear purpose.
11
11
12
12
To do this, follow these steps precisely:
13
13
14
-
1. Launch a haiku agent to check if any of the following are true:
15
-
- The pull request is closed
16
-
- The pull request is a draft
17
-
- The pull request does not need code review (e.g. automated PR, trivial change that is obviously correct)
18
-
19
-
If any condition is true, stop and do not proceed.
20
-
21
-
Note: Still review Claude generated PR's.
14
+
1. Run `git diff main...HEAD` to get the diff and `git log main..HEAD --oneline` to get the commit list. If the diff is empty, stop and report there are no changes to review.
22
15
23
16
2. Launch a haiku agent to return a list of file paths (not their contents) for all relevant CLAUDE.md files including:
24
17
- The root CLAUDE.md file, if it exists
25
-
- Any CLAUDE.md files in directories containing files modified by the pull request
26
-
27
-
3. Launch a sonnet agent to view the pull request and return a summary of the changes
18
+
- Any CLAUDE.md files in directories containing files modified in the diff
28
19
29
-
4. 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:
20
+
3. 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:
30
21
31
22
Agents 1 + 2: CLAUDE.md compliance sonnet agents
32
23
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.
@@ -49,37 +40,15 @@ Note: Still review Claude generated PR's.
49
40
50
41
If you are not certain an issue is real, do not flag it. False positives erode trust and waste reviewer time.
51
42
52
-
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.
43
+
4. For each issue found in the previous step by agents 3 and 4, launch parallel subagents to validate 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.
53
44
54
-
5.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.
45
+
5.Filter out any issues that were not validated in step 4. This step will give us our list of high signal issuesfor our review.
55
46
56
-
6. 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.
57
-
58
-
7. Output a summary of the review findings to the terminal:
59
-
- If issues were found, list each issue with a brief description.
47
+
6. Output a summary of the review findings to the terminal:
48
+
- If issues were found, list each issue with a brief description and the file/line it occurs in.
60
49
- If no issues were found, state: "No issues found. Checked for bugs and CLAUDE.md compliance."
61
50
62
-
If `--comment` argument was NOT provided, stop here. Do not post any GitHub comments.
63
-
64
-
If `--comment` argument IS provided and NO issues were found, post a summary comment using `gh pr comment` and stop.
65
-
66
-
If `--comment` argument IS provided and issues were found, continue to step 8.
67
-
68
-
8. Create a list of all comments that you plan on leaving. This is only for you to make sure you are comfortable with the comments. Do not post this list anywhere.
69
-
70
-
9. Post inline comments for each issue using `mcp__github_inline_comment__create_inline_comment` with `confirmed: true`. For each comment:
71
-
- Provide a brief description of the issue
72
-
- For small, self-contained fixes, include a committable suggestion block
73
-
- For larger fixes (6+ lines, structural changes, or changes spanning multiple locations), describe the issue and suggested fix without a suggestion block
74
-
- Never post a committable suggestion UNLESS committing the suggestion fixes the issue entirely. If follow up steps are required, do not leave a committable suggestion.
75
-
- If there's already a previous inline comment for the issue, update it instead of creating a new inline comment.
76
-
- Suffix every comment body with: "Generated by AI (Anthropic Claude, [model name of the agent posting the comment])"
77
-
78
-
**IMPORTANT: Only post ONE comment per unique issue. Do not post duplicate comments.**
79
-
80
-
10. Check for previous comments from Claude about issues that are not present anymore and resolve the conversation.
81
-
82
-
Use this list when evaluating issues in Steps 4 and 5 (these are false positives, do NOT flag):
51
+
Use this list when evaluating issues in Steps 3 and 4 (these are false positives, do NOT flag):
83
52
84
53
- Pre-existing issues
85
54
- Something that appears to be a bug but is actually correct
@@ -90,23 +59,5 @@ Use this list when evaluating issues in Steps 4 and 5 (these are false positives
90
59
91
60
Notes:
92
61
93
-
- Use gh CLI to interact with GitHub (e.g., fetch pull requests, create comments). Do not use web fetch.
94
62
- Create a todo list before starting.
95
-
- You must cite and link each issue in inline comments (e.g., if referring to a CLAUDE.md, include a link to it).
96
-
- If no issues are found and `--comment` argument is provided, post a comment with the following format:
97
-
98
-
---
99
-
100
-
No issues found through automated code review.
101
-
102
-
Generated by AI (Anthropic Claude, [model name])
103
-
104
-
---
105
-
106
-
- When linking to code in inline comments, follow the following format precisely, otherwise the Markdown preview won't render correctly: https://github.com/anthropics/claude-code/blob/c21d3c10bc8e898b7ac1a2d745bdc9bc4e423afe/package.json#L10-L15
107
-
- Requires full git sha
108
-
- You must provide the full sha. Commands like `https://github.com/owner/repo/blob/$(git rev-parse HEAD)/foo/bar` will not work, since your comment will be directly rendered in Markdown.
109
-
- Repo name must match the repo you're code reviewing
110
-
-# sign after the file name
111
-
- Line range format is L[start]-L[end]
112
-
- 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`)
63
+
- You must cite each issue with the file path and line number.
**Agent assumptions (applies to all agents and subagents):**
9
+
- All tools are functional and will work without error. Do not test tools or make exploratory calls. Make sure this is clear to every subagent that is launched.
10
+
- Only call a tool if it is required to complete the task. Every tool call should have a clear purpose.
11
+
12
+
To do this, follow these steps precisely:
13
+
14
+
1. Launch a haiku agent to check if any of the following are true:
15
+
- The pull request is closed
16
+
- The pull request is a draft
17
+
- The pull request does not need code review (e.g. automated PR, trivial change that is obviously correct)
18
+
19
+
If any condition is true, stop and do not proceed.
20
+
21
+
Note: Still review Claude generated PR's.
22
+
23
+
2. Launch a haiku agent to return a list of file paths (not their contents) for all relevant CLAUDE.md files including:
24
+
- The root CLAUDE.md file, if it exists
25
+
- Any CLAUDE.md files in directories containing files modified by the pull request
26
+
27
+
3. Launch a sonnet agent to view the pull request and return a summary of the changes
28
+
29
+
4.**Follow steps 3–5 from `/code-review`** to run the parallel review agents and validate issues. Use the PR diff (obtained via `gh pr diff`) as the diff input. Pass the PR title and description as context to each subagent so they understand the author's intent.
30
+
31
+
5. Output a summary of the review findings to the terminal:
32
+
- If issues were found, list each issue with a brief description.
33
+
- If no issues were found, state: "No issues found. Checked for bugs and CLAUDE.md compliance."
34
+
35
+
If `--comment` argument was NOT provided, stop here. Do not post any GitHub comments.
36
+
37
+
If `--comment` argument IS provided and NO issues were found, post a summary comment using `gh pr comment` and stop.
38
+
39
+
If `--comment` argument IS provided and issues were found, continue to step 6.
40
+
41
+
6. Create a list of all comments that you plan on leaving. This is only for you to make sure you are comfortable with the comments. Do not post this list anywhere.
42
+
43
+
7. Post inline comments for each issue using `mcp__github_inline_comment__create_inline_comment` with `confirmed: true`. For each comment:
44
+
- Provide a brief description of the issue
45
+
- For small, self-contained fixes, include a committable suggestion block
46
+
- For larger fixes (6+ lines, structural changes, or changes spanning multiple locations), describe the issue and suggested fix without a suggestion block
47
+
- Never post a committable suggestion UNLESS committing the suggestion fixes the issue entirely. If follow-up steps are required, do not leave a committable suggestion.
48
+
- If there's already a previous inline comment for the issue, update it instead of creating a new inline comment.
49
+
- Suffix every comment body with: "Generated by AI (Anthropic Claude, [model name of the agent posting the comment])"
50
+
51
+
**IMPORTANT: Only post ONE comment per unique issue. Do not post duplicate comments.**
52
+
53
+
8. Check for previous comments from Claude about issues that are not present anymore and resolve the conversation.
54
+
55
+
Notes:
56
+
57
+
- Use gh CLI to interact with GitHub (e.g., fetch pull requests, create comments). Do not use web fetch.
58
+
- Create a todo list before starting.
59
+
- You must cite and link each issue in inline comments (e.g., if referring to a CLAUDE.md, include a link to it).
60
+
- If no issues are found and `--comment` argument is provided, post a comment with the following format:
61
+
62
+
---
63
+
64
+
No issues found through automated code review.
65
+
66
+
Generated by AI (Anthropic Claude, [model name])
67
+
68
+
---
69
+
70
+
- When linking to code in inline comments, follow the following format precisely, otherwise the Markdown preview won't render correctly: https://github.com/anthropics/claude-code/blob/c21d3c10bc8e898b7ac1a2d745bdc9bc4e423afe/package.json#L10-L15
71
+
- Requires full git sha
72
+
- You must provide the full sha. Commands like `https://github.com/owner/repo/blob/$(git rev-parse HEAD)/foo/bar` will not work, since your comment will be directly rendered in Markdown.
73
+
- Repo name must match the repo you're code reviewing
74
+
-# sign after the file name
75
+
- Line range format is L[start]-L[end]
76
+
- Provide at least 1 line of context before and after, centered on the line you are commenting about (e.g. if you are commenting about lines 5-6, you should link to `L4-7`)
0 commit comments