Skip to content

Commit 7635297

Browse files
craig[bot]ajstorm
andcommitted
Merge #154373
154373: dev-inf: First cut of Claude Code review GH action r=rickystewart a=ajstorm First drop of a three-stage claude code review GH action. Epic: none Release note: none Co-authored-by: Adam Storm <[email protected]>
2 parents 287999c + f0c3043 commit 7635297

File tree

1 file changed

+176
-0
lines changed

1 file changed

+176
-0
lines changed
Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
name: Claude Code PR Review
2+
3+
on:
4+
pull_request:
5+
types: [synchronize, ready_for_review, reopened, labeled]
6+
7+
jobs:
8+
claude-code-pr-review:
9+
runs-on: ubuntu-latest
10+
if: contains(github.event.pull_request.labels.*.name, 'O-AI-Review')
11+
permissions:
12+
contents: read
13+
pull-requests: write
14+
id-token: write
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v5
18+
with:
19+
fetch-depth: 1
20+
21+
- name: Authenticate to Google Cloud
22+
uses: 'google-github-actions/auth@v3'
23+
with:
24+
project_id: 'vertex-model-runners'
25+
service_account: '[email protected]'
26+
workload_identity_provider: 'projects/72497726731/locations/global/workloadIdentityPools/ai-review/providers/github'
27+
28+
- name: Stage 1 - Initial Bug Screening
29+
id: stage1
30+
uses: cockroachdb/claude-code-action@v1
31+
with:
32+
use_vertex: "true"
33+
claude_args: |
34+
--model claude-sonnet-4-5-20250929
35+
--allowedTools "Read,Grep,Glob,Bash(gh pr diff:*),Bash(gh pr view:*)"
36+
track_progress: true
37+
prompt: |
38+
REPO: ${{ github.repository }}
39+
PR NUMBER: ${{ github.event.pull_request.number }}
40+
41+
Examine each line of code in this PR for potential bugs that could negatively impact
42+
CockroachDB users. Focus on:
43+
- Basic logic errors
44+
- Obvious security vulnerabilities
45+
- Clear error handling problems
46+
- Type safety issues
47+
48+
When performing your analysis, be conservative but thorough. You should think:
49+
"would I be willing to go to jail if my analysis is incorrect?"
50+
51+
**CRITICAL**: You must respond with EXACTLY one of these formats:
52+
1. 'POTENTIAL_BUG_DETECTED - [brief description]' if you find a definite bug
53+
2. 'NO_BUG_FOUND' if no obvious bugs are found
54+
55+
If you detect bugs, clearly explain what you found and why it's problematic.
56+
57+
**OUTPUT REQUIREMENT**: End your response with a single line containing only:
58+
- `STAGE1_RESULT - POTENTIAL_BUG_DETECTED` or
59+
- `STAGE1_RESULT - NO_BUG_FOUND`
60+
61+
- name: Stage 2 - Database Expert Review
62+
id: stage2
63+
if: contains(steps.stage1.outputs.result, 'STAGE1_RESULT - POTENTIAL_BUG_DETECTED')
64+
uses: cockroachdb/claude-code-action@v1
65+
with:
66+
use_vertex: "true"
67+
claude_args: |
68+
--model claude-4-5-sonnet-20250929
69+
--allowedTools "Read,Grep,Glob,Bash(gh pr diff:*),Bash(gh pr view:*)"
70+
track_progress: true
71+
prompt: |
72+
REPO: ${{ github.repository }}
73+
PR NUMBER: ${{ github.event.pull_request.number }}
74+
75+
You are a database systems expert providing a second opinion. Stage 1 analysis
76+
found potential issues. Your job is to confirm or reject those findings.
77+
78+
**Stage 1 Results**:
79+
${{ steps.stage1.outputs.result }}
80+
81+
Review the Stage 1 findings and perform your own analysis. Do not identify
82+
new bugs unless they're glaringly obvious.
83+
84+
Be very thorough and conservative. Ask yourself: "would I risk losing my job
85+
over falsely identifying a bug?" If there's doubt, err on the side of
86+
NO_BUG_DETECTED.
87+
88+
**CRITICAL**: You must respond with EXACTLY one of these formats:
89+
1. 'POTENTIAL_BUG_DETECTED - [detailed description of confirmed bugs]'
90+
2. 'NO_BUG_FOUND' if bugs are not confirmed
91+
92+
**OUTPUT REQUIREMENT**: End your response with a single line containing only:
93+
- `STAGE2_RESULT - POTENTIAL_BUG_DETECTED [detailed description of confirmed bugs]` or
94+
- `STAGE2_RESULT - NO_BUG_FOUND`
95+
96+
- name: Stage 3 - Principal Engineer Final Review
97+
id: stage3
98+
if: contains(steps.stage2.outputs.result, 'STAGE2_RESULT - POTENTIAL_BUG_DETECTED')
99+
uses: cockroachdb/claude-code-action@v1
100+
with:
101+
use_vertex: "true"
102+
claude_args: |
103+
--model claude-4-5-sonnet-20250929
104+
--allowedTools "Read,Grep,Glob,Bash(gh pr diff:*),Bash(gh pr view:*)"
105+
track_progress: true
106+
prompt: |
107+
REPO: ${{ github.repository }}
108+
PR NUMBER: ${{ github.event.pull_request.number }}
109+
110+
You are a principal engineer performing the final, most critical analysis.
111+
Two previous stages have found potential issues that need final validation.
112+
113+
**Stage 1 Results**:
114+
${{ steps.stage1.outputs.result }}
115+
116+
**Stage 2 Results**:
117+
${{ steps.stage2.outputs.result }}
118+
119+
This is the final gate before flagging this PR as having critical bugs.
120+
Only confirm bugs that could cause:
121+
- Data loss or corruption
122+
- Incorrect errors, traps or panics
123+
- Security breaches
124+
- Cluster instability
125+
- Production outages
126+
127+
Be extremely conservative - only flag truly critical issues. If you're wrong,
128+
it could mean serious consequences for the project.
129+
130+
Use conservative language and minimize superlatives. Assume the reader has
131+
a heart condition - just articulate facts without emotion.
132+
133+
**CRITICAL**: You must respond with EXACTLY one of these formats:
134+
1. 'BUG_DETECTED: [description, line numbers and suggested fix]'
135+
2. 'NO_BUG_DETECTED' if issues are not critical enough
136+
137+
For each issue found, provide:
138+
1. The specific line(s) where the issue occurs
139+
2. A clear description of what is wrong
140+
3. A suggested fix
141+
142+
**OUTPUT REQUIREMENT**: End your response with a single line containing only:
143+
- `STAGE3_RESULT: POTENTIAL_BUG_CONFIRMED` or
144+
- `STAGE3_RESULT: NO_BUG_FOUND`
145+
146+
- name: Final Analysis Report
147+
if: always()
148+
uses: cockroachdb/claude-code-action@v1
149+
with:
150+
use_vertex: "true"
151+
claude_args: |
152+
--model claude-4-5-sonnet-20250929
153+
--allowedTools "Read,Grep,Glob,Bash(gh pr diff:*),Bash(gh pr view:*)"
154+
prompt: |
155+
REPO: ${{ github.repository }}
156+
PR NUMBER: ${{ github.event.pull_request.number }}
157+
158+
## Three-Stage Analysis Summary
159+
160+
Generate a final summary report based on the completed analysis stages:
161+
162+
**Stage 1 Result**: ${{ steps.stage1.outputs.result || 'Not completed' }}
163+
**Stage 2 Result**: ${{ steps.stage2.outputs.result || 'Skipped - Stage 1 found no bugs' }}
164+
**Stage 3 Result**: ${{ steps.stage3.outputs.result || 'Skipped - Stage 2 did not confirm bugs' }}
165+
166+
**Analysis Process**:
167+
- Stage 1 (Initial Screening): ${{ steps.stage1.conclusion }}
168+
- Stage 2 (Database Expert): ${{ steps.stage2.conclusion || 'Skipped' }}
169+
- Stage 3 (Principal Engineer): ${{ steps.stage3.conclusion || 'Skipped' }}
170+
171+
Provide a clear, concise summary of:
172+
1. How many stages were executed
173+
2. The final determination (critical bug found or no critical bugs)
174+
3. If bugs were found, what actions are recommended
175+
176+
**If all three stages detected bugs**, this indicates a potential issue that warrants investigation.

0 commit comments

Comments
 (0)