Skip to content

Commit b17833f

Browse files
authored
General code review
## Overview This PR generalizes the action into a dual‑pass reviewer: a broad code‑quality review plus a dedicated security pass. It also refreshes the slash commands, filtering logic, and docs to match the new workflow. ## What Changed - Run two review passes in the GitHub Action: general review + security‑focused review - Added inputs to toggle each pass (`run-general-review`, `run-security-review`) - Introduced a security‑specific prompt alongside the general prompt - Updated `.claude/commands/code-review.md` and `.claude/commands/security-review.md` to align with the new multi‑agent workflow - Strengthened filtering logic and metadata to handle security vs general findings cleanly - Updated documentation and examples to reference the PSPDFKit‑labs fork - Added/updated tests for the dual‑pass flow ## Why A single pass blends concerns and can dilute security‑specific signal. Running a dedicated security pass improves focus without losing broader quality review coverage. ## Testing - `python -m pytest claudecode -v`
2 parents 25e460e + a749112 commit b17833f

32 files changed

Lines changed: 1533 additions & 715 deletions

.claude/commands/code-review.md

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
---
2+
allowed-tools: 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:*), Bash(gh api:*), mcp__github_inline_comment__create_inline_comment
3+
description: Code review a pull request
4+
---
5+
6+
Provide a code review for the given pull request.
7+
8+
Create a todo list before starting.
9+
10+
**Agent assumptions (applies to all agents and subagents):**
11+
- 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.
12+
- Only call a tool if it is required to complete the task. Every tool call should have a clear purpose.
13+
14+
To do this, follow these steps precisely:
15+
16+
1. Launch a haiku agent to check if any of the following are true:
17+
- The pull request is closed
18+
- The pull request is a draft
19+
- The pull request does not need code review (e.g. automated PR, trivial change that is obviously correct)
20+
- Claude has already commented on this PR (check `gh pr view <PR> --comments` for comments left by claude)
21+
22+
If any condition is true, stop and do not proceed.
23+
24+
Note: Still review Claude generated PR's.
25+
26+
2. Launch a haiku agent to return a list of file paths (not their contents) for all relevant CLAUDE.md files including:
27+
- The root CLAUDE.md file, if it exists
28+
- Any CLAUDE.md files in directories containing files modified by the pull request
29+
30+
3. Launch a sonnet agent to view the pull request and return a summary of the changes.
31+
32+
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:
33+
34+
Agents 1 + 2: CLAUDE.md compliance sonnet agents
35+
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.
36+
37+
Agent 3: Opus bug agent (parallel subagent with agent 4)
38+
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.
39+
40+
Agent 4: Opus bug agent (parallel subagent with agent 3)
41+
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.
42+
43+
**CRITICAL: We only want HIGH SIGNAL issues.** Flag issues where:
44+
- The code will fail to compile or parse (syntax errors, type errors, missing imports, unresolved references)
45+
- The code will definitely produce wrong results regardless of inputs (clear logic errors)
46+
- Clear, unambiguous CLAUDE.md violations where you can quote the exact rule being broken
47+
48+
Do NOT flag:
49+
- Code style or quality concerns
50+
- Potential issues that depend on specific inputs or state
51+
- Subjective suggestions or improvements
52+
53+
If you are not certain an issue is real, do not flag it. False positives erode trust and waste reviewer time.
54+
55+
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.
56+
57+
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.
58+
59+
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.
60+
61+
7. If issues were found, skip to step 8 to post inline comments directly.
62+
63+
If NO issues were found, post a summary comment using `gh pr comment` (if `--comment` argument is provided):
64+
"No issues found. Checked for bugs and CLAUDE.md compliance."
65+
66+
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.
67+
68+
9. Post inline comments for each issue using `mcp__github_inline_comment__create_inline_comment`. For each comment:
69+
- Provide a brief description of the issue
70+
- For small, self-contained fixes, include a committable suggestion block
71+
- For larger fixes (6+ lines, structural changes, or changes spanning multiple locations), describe the issue and suggested fix without a suggestion block
72+
- 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.
73+
74+
**IMPORTANT: Only post ONE comment per unique issue. Do not post duplicate comments.**
75+
76+
Use this list when evaluating issues in Steps 4 and 5 (these are false positives, do NOT flag):
77+
78+
- Pre-existing issues
79+
- Something that appears to be a bug but is actually correct
80+
- Pedantic nitpicks that a senior engineer would not flag
81+
- Issues that a linter will catch (do not run the linter to verify)
82+
- General code quality concerns (e.g., lack of test coverage, general security issues) unless explicitly required in CLAUDE.md
83+
- Issues mentioned in CLAUDE.md but explicitly silenced in the code (e.g., via a lint ignore comment)
84+
85+
Notes:
86+
87+
- Use gh CLI to interact with GitHub (e.g., fetch pull requests, create comments). Do not use web fetch.
88+
- You must cite and link each issue in inline comments (e.g., if referring to a CLAUDE.md, include a link to it).
89+
- If no issues are found, post a comment with the following format:
90+
91+
---
92+
93+
## Code review
94+
95+
No issues found. Checked for bugs and CLAUDE.md compliance.
96+
97+
---
98+
99+
- When linking to code in inline comments, follow the following format precisely, otherwise the Markdown preview won't render correctly: https://github.com/PSPDFKit-labs/claude-code-review/blob/c21d3c10bc8e898b7ac1a2d745bdc9bc4e423afe/package.json#L10-L15
100+
- Requires full git sha
101+
- 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.
102+
- Repo name must match the repo you're code reviewing
103+
- # sign after the file name
104+
- Line range format is L[start]-L[end]
105+
- 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`)

0 commit comments

Comments
 (0)