Skip to content

Commit 64314c5

Browse files
authored
Merge pull request #3 from PSPDFKit-labs/matej/unified-multi-agent-review
Unify code and security review into single multi-agent pass
2 parents b17833f + c62aa2a commit 64314c5

8 files changed

Lines changed: 434 additions & 574 deletions

File tree

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
---
22
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
3+
description: Unified code and security review for a pull request
44
---
55

6-
Provide a code review for the given pull request.
6+
Provide a comprehensive code review for the given pull request, covering both code quality and security.
77

88
Create a todo list before starting.
99

@@ -16,7 +16,7 @@ To do this, follow these steps precisely:
1616
1. Launch a haiku agent to check if any of the following are true:
1717
- The pull request is closed
1818
- 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)
19+
- The pull request does not need review (e.g. automated PR, trivial change that is obviously correct)
2020
- Claude has already commented on this PR (check `gh pr view <PR> --comments` for comments left by claude)
2121

2222
If any condition is true, stop and do not proceed.
@@ -29,39 +29,42 @@ To do this, follow these steps precisely:
2929

3030
3. Launch a sonnet agent to view the pull request and return a summary of the changes.
3131

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:
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. The agents should do the following:
3333

3434
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.
35+
Audit changes for CLAUDE.md compliance in parallel, including both general and security-specific rules. 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.
3636

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.
37+
Agent 3: Opus code quality agent
38+
Scan for obvious bugs and code quality issues. 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.
3939

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.
40+
Agent 4: Opus security agent
41+
Look for security vulnerabilities in the introduced code. This includes injection, auth bypass, data exposure, unsafe deserialization, or other exploitable issues. Only look for issues that fall within the changed code.
4242

4343
**CRITICAL: We only want HIGH SIGNAL issues.** Flag issues where:
4444
- The code will fail to compile or parse (syntax errors, type errors, missing imports, unresolved references)
4545
- The code will definitely produce wrong results regardless of inputs (clear logic errors)
46+
- There is a clear, exploitable security vulnerability (e.g., injection, auth bypass, RCE, sensitive data exposure)
4647
- Clear, unambiguous CLAUDE.md violations where you can quote the exact rule being broken
4748

4849
Do NOT flag:
49-
- Code style or quality concerns
50+
- Code style or quality concerns that don't affect correctness
5051
- Potential issues that depend on specific inputs or state
5152
- Subjective suggestions or improvements
53+
- Security issues that depend on speculative inputs or unverified assumptions
54+
- Denial of Service (DoS) or rate limiting issues without concrete exploitability
5255

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

5558
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.
5659

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.
60+
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. Use Opus subagents for bugs and security issues, and sonnet agents for CLAUDE.md violations.
5861

5962
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.
6063

6164
7. If issues were found, skip to step 8 to post inline comments directly.
6265

6366
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."
67+
"No issues found. Checked for bugs, security vulnerabilities, and CLAUDE.md compliance."
6568

6669
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.
6770

@@ -79,7 +82,7 @@ Use this list when evaluating issues in Steps 4 and 5 (these are false positives
7982
- Something that appears to be a bug but is actually correct
8083
- Pedantic nitpicks that a senior engineer would not flag
8184
- 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
85+
- General code quality concerns (e.g., lack of test coverage) unless explicitly required in CLAUDE.md
8386
- Issues mentioned in CLAUDE.md but explicitly silenced in the code (e.g., via a lint ignore comment)
8487

8588
Notes:
@@ -92,7 +95,7 @@ Notes:
9295

9396
## Code review
9497

95-
No issues found. Checked for bugs and CLAUDE.md compliance.
98+
No issues found. Checked for bugs, security vulnerabilities, and CLAUDE.md compliance.
9699

97100
---
98101

.claude/commands/security-review.md

Lines changed: 0 additions & 106 deletions
This file was deleted.

README.md

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Claude Code Reviewer
22

3-
An AI-powered code review GitHub Action using Claude to analyze code changes. Runs two focused passes: a code quality review (correctness, reliability, performance, maintainability, testing) and a dedicated security review. This action provides intelligent, context-aware review for pull requests using Anthropic's Claude Code tool for deep semantic analysis.
3+
An AI-powered code review GitHub Action using Claude to analyze code changes. Uses a unified multi-agent approach for both code quality (correctness, reliability, performance, maintainability, testing) and security in a single pass. This action provides intelligent, context-aware review for pull requests using Anthropic's Claude Code tool for deep semantic analysis.
44

55
Based on the original work from [anthropics/claude-code-security-review](https://github.com/anthropics/claude-code-security-review).
66

@@ -12,7 +12,7 @@ Based on the original work from [anthropics/claude-code-security-review](https:/
1212
- **Contextual Understanding**: Goes beyond pattern matching to understand code semantics and intent
1313
- **Language Agnostic**: Works with any programming language
1414
- **False Positive Filtering**: Advanced filtering to reduce noise and focus on real issues
15-
- **Dual-Pass Review**: Runs focused code quality and security passes separately for better signal
15+
- **Unified Multi-Agent Review**: Combines code quality and security analysis in a single efficient pass
1616

1717
## Quick Start
1818

@@ -63,8 +63,6 @@ This action is not hardened against prompt injection attacks and should only be
6363
| `false-positive-filtering-instructions` | Path to custom false positive filtering instructions text file | None | No |
6464
| `custom-review-instructions` | Path to custom code review instructions text file to append to the audit prompt | None | No |
6565
| `custom-security-scan-instructions` | Path to custom security scan instructions text file to append to the security section | None | No |
66-
| `run-general-review` | Whether to run the code quality review pass (correctness, reliability, performance, maintainability, testing) | `true` | No |
67-
| `run-security-review` | Whether to run the dedicated security review pass | `true` | No |
6866

6967
### Action Outputs
7068

@@ -135,17 +133,17 @@ Follow the Quick Start guide above. The action handles all dependencies automati
135133
136134
To run the reviewer locally against a specific PR, see the [evaluation framework documentation](claudecode/evals/README.md).
137135
138-
<a id="security-review-slash-command"></a>
136+
<a id="review-slash-command"></a>
139137
140-
## Claude Code Integration: /code-review Command
138+
## Claude Code Integration: /review Command
141139
142-
This repository includes `/code-review` and `/security-review` [slash commands](https://docs.anthropic.com/en/docs/claude-code/slash-commands) that provide the same review capabilities as the GitHub Action workflow. Use `/code-review` for a broad review (correctness, reliability, performance, maintainability, testing, and security), and `/security-review` for a security-focused review.
140+
This repository includes a `/review` [slash command](https://docs.anthropic.com/en/docs/claude-code/slash-commands) that provides the same review capabilities as the GitHub Action workflow. The command performs a comprehensive review covering code quality (correctness, reliability, performance, maintainability, testing) and security using a multi-agent approach.
143141
144142
### Customizing the Command
145143
146-
The default commands are designed to work well in most cases, but they can also be customized based on your specific requirements. To do so:
144+
The default command is designed to work well in most cases, but it can also be customized based on your specific requirements. To do so:
147145
148-
1. Copy the [`code-review.md`](https://github.com/PSPDFKit-labs/claude-code-review/blob/main/.claude/commands/code-review.md?plain=1) or [`security-review.md`](https://github.com/PSPDFKit-labs/claude-code-review/blob/main/.claude/commands/security-review.md?plain=1) file from this repository to your project's `.claude/commands/` folder.
146+
1. Copy the [`review.md`](https://github.com/PSPDFKit-labs/claude-code-review/blob/main/.claude/commands/review.md?plain=1) file from this repository to your project's `.claude/commands/` folder.
149147
2. Edit the copied file to customize the review instructions.
150148
151149
## Custom Scanning Configuration

0 commit comments

Comments
 (0)