Skip to content

Commit abdc41e

Browse files
jfrench9claude
andauthored
Add Claude PR review command for automated code reviews (#79)
## Summary Adds a new Claude command template (`.claude/commands/pr-review.md`) that provides a structured, comprehensive PR review workflow for automated code analysis. ## Key Accomplishments - **New PR Review Command**: Introduces a reusable Claude command that standardizes how pull requests are reviewed, ensuring consistent and thorough analysis across the project. - **Structured Review Process**: The command template defines a comprehensive review methodology covering: - Change analysis and diff interpretation - Code quality assessment - Risk identification and breaking change detection - Testing considerations - Summary and recommendation generation - **Developer Experience**: Provides a one-command workflow for getting detailed, actionable PR feedback directly within the Claude development environment. ## Details This adds a 109-line command definition file that orchestrates an end-to-end PR review process. The command is designed to be invoked within the Claude CLI/IDE integration and produces structured output covering all critical aspects of a code review. > **Note**: The commit message ("Enhance ledger API with new schedule management and closing entry features") does not match the actual changes in this PR, which solely add the PR review command template. This appears to be a mismatched or placeholder commit message. ## Breaking Changes None. This is a purely additive change introducing a new tooling command with no impact on existing functionality or workflows. ## Testing Notes - Verify the command is discoverable and executable within the Claude commands interface. - Test the review command against PRs of varying complexity (single file, multi-file, large diffs) to validate output quality. - Confirm the command handles edge cases such as binary file changes, deleted files, and rename-only diffs gracefully. ## Infrastructure Considerations - This leverages the `.claude/commands/` convention for project-scoped command definitions — no additional infrastructure or dependencies are required. - The command template is self-contained and does not introduce any external service integrations or API calls beyond the existing Claude tooling environment. --- 🤖 Generated with [Claude Code](https://claude.ai/code) **Branch Info:** - Source: `chore/add-pr-review-command` - Target: `main` - Type: feature Co-Authored-By: Claude <noreply@anthropic.com>
2 parents 52881f0 + 7d7b2de commit abdc41e

1 file changed

Lines changed: 109 additions & 0 deletions

File tree

‎.claude/commands/pr-review.md‎

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
Review a pull request by gathering all PR metadata, diff, and review comments, then provide a comprehensive review summary.
2+
3+
## Instructions
4+
5+
### 1. Identify the PR
6+
7+
The user may provide a PR URL, number, or nothing:
8+
9+
- **URL provided** (e.g., `https://github.com/RoboFinSystems/robosystems/pull/577`): Extract the repo and PR number
10+
- **Number provided** (e.g., `577`): Use the current repository
11+
- **Nothing provided**: Detect from the current branch using `gh pr view --json number,url` — if no open PR exists for the current branch, ask the user which PR to review
12+
13+
### 2. Gather PR Data
14+
15+
Run these `gh` commands to collect all context:
16+
17+
```bash
18+
# PR metadata — use only valid fields
19+
gh pr view <NUMBER> --json title,body,author,state,labels,reviews,reviewRequests,statusCheckRollup,mergeStateStatus,headRefName,baseRefName,additions,deletions,changedFiles,createdAt,updatedAt
20+
21+
# PR diff (the actual code changes)
22+
gh pr diff <NUMBER>
23+
24+
# Inline review comments (gh api needs owner/repo — use gh repo view to get it)
25+
gh api repos/$(gh repo view --json nameWithOwner -q .nameWithOwner)/pulls/<NUMBER>/comments --paginate
26+
27+
# Top-level PR conversation comments
28+
gh api repos/$(gh repo view --json nameWithOwner -q .nameWithOwner)/issues/<NUMBER>/comments --paginate
29+
```
30+
31+
**Important `gh pr view --json` field reference** (common mistakes to avoid):
32+
- Use `reviews` not `reviewers` (reviewers is not a valid field)
33+
- Use `reviewRequests` for pending review requests
34+
- Use `headRefOid` for the HEAD commit SHA
35+
36+
### 3. Categorize Review Feedback
37+
38+
Organize all comments and checks into categories:
39+
40+
- **Human Reviews**: Comments from human reviewers (approve, request changes, general feedback)
41+
- **AI Reviews**: Comments from Claude, Copilot, or other AI review bots
42+
- **Code Quality**: Comments from linters, formatters, type checkers (e.g., CodeRabbit, SonarCloud, Codacy)
43+
- **Security**: Findings from security scanners (e.g., Snyk, Dependabot, CodeQL, GitGuardian)
44+
- **CI/CD**: Build status, test results, deployment checks
45+
46+
### 4. Review the Diff
47+
48+
With the full PR diff in hand, perform your own review focusing on:
49+
50+
- **Correctness**: Does the code do what the PR description says?
51+
- **Patterns**: Does it follow existing codebase patterns (check CLAUDE.md)?
52+
- **Security**: Any OWASP top 10 concerns?
53+
- **Multi-tenancy**: Are graph operations scoped to `graph_id`?
54+
- **Error handling**: Appropriate for the context?
55+
- **Tests**: Are changes covered by tests?
56+
- **Missing changes**: Any files that should have been updated but weren't?
57+
58+
### 5. Output Format
59+
60+
Provide a structured review:
61+
62+
```
63+
## PR Summary
64+
**Title**: ...
65+
**Author**: ... | **Branch**: ... → ...
66+
**Status**: ... | **Changes**: +X / -Y across Z files
67+
68+
<Brief summary of what the PR does>
69+
70+
## Existing Review Feedback
71+
72+
### Human Reviews
73+
<Summarize human reviewer comments and their status>
74+
75+
### AI Reviews
76+
<Summarize AI review comments — highlight unresolved items>
77+
78+
### Code Quality
79+
<Summarize code quality bot findings>
80+
81+
### Security
82+
<Summarize security scanner findings — flag anything critical>
83+
84+
### CI/CD Status
85+
<Pass/fail status of all checks>
86+
87+
## My Review
88+
89+
### Issues (should fix before merge)
90+
<Numbered list of problems found>
91+
92+
### Suggestions (non-blocking improvements)
93+
<Numbered list of suggestions>
94+
95+
### Questions
96+
<Anything unclear that needs clarification>
97+
98+
## Verdict
99+
<APPROVE / REQUEST_CHANGES / NEEDS_DISCUSSION — with brief rationale>
100+
```
101+
102+
### Notes
103+
104+
- If the PR diff is very large (>2000 lines), focus on the most important files and note which files were skimmed
105+
- For security findings, always err on the side of flagging — false positives are better than missed vulnerabilities
106+
- Cross-reference the PR description with the actual diff to catch scope creep or missing implementation
107+
- If the PR references an issue, check that the issue requirements are met
108+
109+
$ARGUMENTS

0 commit comments

Comments
 (0)