Skip to content

Commit be9a995

Browse files
shahar-cauraclaude
andcommitted
forge: Add Claude Code review workflow with author guard
Restrict @claude trigger to MEMBER/OWNER/COLLABORATOR to prevent unauthorized API usage on this public repo. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent ebf9bb2 commit be9a995

1 file changed

Lines changed: 180 additions & 0 deletions

File tree

Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
name: Claude Code Review
2+
3+
on:
4+
pull_request:
5+
branches: [master, dev]
6+
types: [opened, synchronize, reopened]
7+
issue_comment:
8+
types: [created]
9+
10+
jobs:
11+
claude-review:
12+
# Run on all PR events OR when someone comments @claude
13+
if: |
14+
(github.event_name == 'pull_request') ||
15+
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude') &&
16+
(github.event.comment.author_association == 'MEMBER' ||
17+
github.event.comment.author_association == 'OWNER' ||
18+
github.event.comment.author_association == 'COLLABORATOR'))
19+
runs-on: ubuntu-latest
20+
permissions:
21+
contents: read
22+
pull-requests: write
23+
issues: write
24+
id-token: write
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v4
28+
with:
29+
fetch-depth: 0
30+
31+
- name: Claude Code Review
32+
uses: anthropics/claude-code-action@v1
33+
with:
34+
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
35+
github_token: ${{ secrets.GITHUB_TOKEN }}
36+
trigger_phrase: "@claude"
37+
assignee_trigger: "claude"
38+
use_sticky_comment: true
39+
show_full_output: true
40+
track_progress: true
41+
prompt: |
42+
Review this pull request. For EVERY issue or suggestion, you MUST provide a copy-paste ready prompt for Claude Code CLI.
43+
44+
## Format Requirements
45+
46+
For each issue, use EXACTLY this format:
47+
48+
### Issue Title
49+
**Severity**: Critical/High/Medium/Low
50+
**File**: `path/to/file.py:line-range`
51+
**Problem**: One sentence description.
52+
53+
<details>
54+
<summary>🤖 Claude Code Prompt (click to copy)</summary>
55+
56+
```
57+
[COMPLETE, SELF-CONTAINED PROMPT THAT CAN BE PASTED DIRECTLY INTO CLAUDE CODE]
58+
59+
The prompt must include:
60+
- Exact file path(s) to modify
61+
- Specific line numbers or function names
62+
- What to add/change/remove
63+
- Any constraints or requirements
64+
```
65+
66+
</details>
67+
68+
---
69+
70+
## Example Output
71+
72+
### 1. Missing Input Validation
73+
**Severity**: High
74+
**File**: `src/routers/api.py:21-35`
75+
**Problem**: No validation on user input parameters.
76+
77+
<details>
78+
<summary>🤖 Claude Code Prompt (click to copy)</summary>
79+
80+
```
81+
Add input validation to src/routers/api.py in the create_user endpoint (lines 21-35):
82+
1. Validate that 'email' is a valid email format using a regex or pydantic EmailStr
83+
2. Validate that 'name' is 1-100 characters and contains only alphanumeric and spaces
84+
3. Return 422 Unprocessable Entity with descriptive error messages for invalid input
85+
4. Add unit tests for the validation in tests/test_api.py
86+
```
87+
88+
</details>
89+
90+
---
91+
92+
## Review Sections
93+
94+
1. **Summary**: 2-3 sentences about what this PR does
95+
2. **Critical/High Issues**: Must fix before merge
96+
3. **Medium/Low Issues**: Should fix but not blocking
97+
4. **Suggestions**: Nice-to-have improvements
98+
99+
## Guidelines
100+
- Every issue MUST have a Claude Code prompt - no exceptions
101+
- Prompts must be self-contained (include all context needed)
102+
- Include file paths and line numbers in prompts
103+
- Focus on real issues, not style preferences
104+
- Skip sections with nothing to report
105+
106+
---
107+
108+
## 📋 Aggregated Fix Prompts (MANDATORY)
109+
110+
You MUST include this section at the END of your review. Create ONE "Fix All" code block per severity level.
111+
112+
For EACH severity level that has issues, add a section like this:
113+
114+
## 🚀 Fix All Prompts
115+
116+
### 🔴 Fix All Critical Issues
117+
(Include this section only if there are Critical issues)
118+
119+
```
120+
Please fix the following CRITICAL issues:
121+
122+
1. [Copy the full prompt from Critical issue #1]
123+
124+
2. [Copy the full prompt from Critical issue #2]
125+
```
126+
127+
### 🟠 Fix All High Priority Issues
128+
(Include this section only if there are High Priority issues)
129+
130+
```
131+
Please fix the following HIGH PRIORITY issues:
132+
133+
1. [Copy the full prompt from High issue #1]
134+
135+
2. [Copy the full prompt from High issue #2]
136+
```
137+
138+
### 🟡 Fix All Medium/Low Issues
139+
(Include this section only if there are Medium/Low issues)
140+
141+
```
142+
Please fix the following issues:
143+
144+
1. [Copy the full prompt from Medium/Low issue #1]
145+
```
146+
147+
### 🟢 Fix All Suggestions
148+
(Include this section only if there are Suggestions)
149+
150+
```
151+
Please implement the following suggestions:
152+
153+
1. [Copy the full prompt from Suggestion #1]
154+
```
155+
156+
IMPORTANT: This "Fix All Prompts" section is REQUIRED. Each code block should contain ALL prompts from that severity level combined, so users can copy one block to fix all issues of that severity.
157+
158+
# Add this job to your existing workflow
159+
apply-fixes:
160+
if: |
161+
github.event_name == 'issue_comment' &&
162+
contains(github.event.comment.body, '@claude fix')
163+
runs-on: ubuntu-latest
164+
permissions:
165+
contents: write
166+
pull-requests: write
167+
steps:
168+
- uses: actions/checkout@v4
169+
with:
170+
ref: ${{ github.event.issue.pull_request.head.ref }}
171+
fetch-depth: 0
172+
token: ${{ secrets.GITHUB_TOKEN }}
173+
# TODO: see the auto fix works
174+
# - uses: anthropics/claude-code-action@v1
175+
# with:
176+
# anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
177+
# github_token: ${{ secrets.GITHUB_TOKEN }}
178+
# prompt: |
179+
# Look at the review comments on this PR and fix ALL issues marked as Critical or High.
180+
# Make the changes directly. Commit with message "fix: address review feedback"

0 commit comments

Comments
 (0)