Skip to content

Commit 3e45f68

Browse files
committed
Change the Claude code-review command to review changes on either the default branch or a version branch, whichever is closer
1 parent 9da6683 commit 3e45f68

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

.claude/commands/code-review.md

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,29 @@
11
---
2-
allowed-tools: Bash(git diff:*), Bash(git log:*), Bash(git merge-base:*), Bash(git rev-parse:*)
2+
allowed-tools: Bash(git branch:*), Bash(git diff:*), Bash(git log:*), Bash(git merge-base:*), Bash(git rev-parse:*)
33
description: Code review changes since branch diverged from default branch
44
---
55

6-
Review the code changes introduced since this branch diverged from the default branch (main).
6+
Review the code changes introduced since this branch diverged from its base branch.
77

88
**Agent assumptions (applies to all agents and subagents):**
99
- 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.
1010
- Only call a tool if it is required to complete the task. Every tool call should have a clear purpose.
1111

1212
To do this, follow these steps precisely:
1313

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.
14+
1. Determine the base branch to diff against:
15+
- The default base branch is `main`.
16+
- Run `git branch` to list local branches and find any version branches (branches whose name matches the pattern `X.Y`, e.g. `0.6`, `1.2`).
17+
- For each version branch found, compare how close the current branch is to it vs. `main` by counting commits since divergence: `git log <branch>..HEAD --oneline | wc -l`. Pick the branch with the fewest commits (i.e. the most recent common ancestor). If a version branch is closer than `main`, use it as the base branch instead.
18+
- Store the chosen base branch name as BASE_BRANCH.
1519

16-
2. Launch a haiku agent to return a list of file paths (not their contents) for all relevant CLAUDE.md files including:
20+
2. Run `git diff BASE_BRANCH...HEAD` to get the diff and `git log BASE_BRANCH..HEAD --oneline` to get the commit list. If the diff is empty, stop and report there are no changes to review.
21+
22+
3. Launch a haiku agent to return a list of file paths (not their contents) for all relevant CLAUDE.md files including:
1723
- The root CLAUDE.md file, if it exists
1824
- Any CLAUDE.md files in directories containing files modified in the diff
1925

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:
26+
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:
2127

2228
Agents 1 + 2: CLAUDE.md compliance sonnet agents
2329
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.
@@ -40,11 +46,11 @@ To do this, follow these steps precisely:
4046

4147
If you are not certain an issue is real, do not flag it. False positives erode trust and waste reviewer time.
4248

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.
49+
5. 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.
4450

45-
5. Filter out any issues that were not validated in step 4. This step will give us our list of high signal issues for our review.
51+
6. Filter out any issues that were not validated in step 4. This step will give us our list of high signal issues for our review.
4652

47-
6. Output a summary of the review findings to the terminal:
53+
7. Output a summary of the review findings to the terminal:
4854
- If issues were found, list each issue with a brief description and the file/line it occurs in.
4955
- If no issues were found, state: "No issues found. Checked for bugs and CLAUDE.md compliance."
5056

0 commit comments

Comments
 (0)