Skip to content

Commit 1ed4121

Browse files
fix(ci): rewrite Claude Code workflow for working automated PR reviews
Switch from broken v1 plugin-based config to @beta with direct_prompt: - Use direct_prompt instead of prompt + invalid allowed_tools input - Use @beta action which supports automated review without @claude mention - Use read permissions (action handles posting via OIDC token) - Skip bot-generated PRs (dependabot, renovate) - Add phased review prompt (root cause → config scrutiny → test integrity → code quality) - Upgrade actions/checkout to v6
1 parent db3391b commit 1ed4121

1 file changed

Lines changed: 89 additions & 29 deletions

File tree

.github/workflows/claude.yml

Lines changed: 89 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
name: Claude Code
22

33
on:
4+
pull_request:
5+
types: [opened, synchronize]
46
issue_comment:
57
types: [created]
68
pull_request_review_comment:
@@ -9,57 +11,115 @@ on:
911
types: [opened, assigned]
1012
pull_request_review:
1113
types: [submitted]
12-
pull_request:
13-
types: [opened, synchronize, ready_for_review, reopened]
1414

1515
jobs:
16-
claude:
17-
if: |
18-
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) ||
19-
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) ||
20-
(github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) ||
21-
(github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')))
16+
automated-review:
17+
if: github.event_name == 'pull_request' && github.event.pull_request.user.type != 'Bot'
2218
runs-on: ubuntu-latest
2319
permissions:
2420
contents: read
25-
pull-requests: write
26-
issues: write
21+
pull-requests: read
22+
issues: read
2723
id-token: write
28-
actions: read
2924
steps:
3025
- name: Checkout repository
31-
uses: actions/checkout@v4
26+
uses: actions/checkout@v6
3227
with:
3328
fetch-depth: 1
3429

35-
- name: Run Claude Code
36-
id: claude
37-
uses: anthropics/claude-code-action@v1
30+
- name: Run Automated AI Review
31+
id: automated-review
32+
uses: anthropics/claude-code-action@beta
3833
with:
3934
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
40-
additional_permissions: |
41-
actions: read
35+
direct_prompt: |
36+
## Review this pull request
37+
38+
You are reviewing a PR for **codegraph** — a local code dependency graph CLI that parses
39+
codebases with tree-sitter (WASM), builds function-level dependency graphs in SQLite, and
40+
supports semantic search with local embeddings.
41+
42+
### Phase 1: Root Cause Analysis
43+
Before reviewing code, determine:
44+
- **What problem is this PR solving?** Is it fixing a real issue or hiding symptoms?
45+
- **Is the approach justified?** Are configuration/linting changes relaxing rules to silence errors?
46+
- ⚠️ REJECT if changes silence warnings without fixing underlying issues
47+
- ⚠️ REJECT if test expectations are lowered to make tests pass
48+
- If you cannot determine the root cause, REQUEST MORE INFORMATION
49+
50+
### Phase 2: Configuration Change Detection (HIGH SCRUTINY)
51+
Check for HIGH-RISK changes:
52+
- Biome/linting rules disabled or relaxed
53+
- Test timeouts increased or coverage thresholds lowered
54+
- Build configuration or module resolution modified
55+
- TypeScript strict mode flags disabled
56+
- **If >3 rules are relaxed → REQUEST justification for each**
57+
58+
### Phase 3: Test Integrity
59+
Watch for RED FLAGS:
60+
- Removed or weakened assertions
61+
- Tests made less strict (conditional assertions, skipped validation)
62+
- Test files modified alongside the code they test without clear reason
63+
- `eslint-disable` or workaround comments without justification
64+
- Large PRs (>20 files) mixing unrelated concerns
4265
43-
review:
44-
if: github.event_name == 'pull_request'
66+
### Phase 4: Code Quality
67+
Only after passing Phases 1-3:
68+
- Code quality and best practices
69+
- Potential bugs (especially in tree-sitter extractors, import resolution, SQLite operations)
70+
- Security concerns (command injection in CLI, SQL injection in queries)
71+
- Performance (unnecessary full rebuilds, missing incremental hash checks)
72+
- Test coverage for new functionality
73+
74+
### Rating (STRICT — default to 2-3 stars)
75+
- ⭐ Critical issues, REJECT
76+
- ⭐⭐ Significant concerns, REQUEST CHANGES
77+
- ⭐⭐⭐ Acceptable with minor concerns, APPROVE with conditions
78+
- ⭐⭐⭐⭐ Good quality, well-tested, APPROVE
79+
- ⭐⭐⭐⭐⭐ Exceptional (< 5% of PRs)
80+
81+
### Final Assessment (MANDATORY)
82+
```
83+
## Root Cause Analysis
84+
**Problem Being Solved**: [...]
85+
**Why This Approach**: [...]
86+
**Risk Assessment**: [...]
87+
88+
## Critical Concerns (if any)
89+
[...]
90+
91+
## Final Recommendation
92+
- Rating: ⭐⭐☆☆☆ (X/5)
93+
- Action: [REJECT | REQUEST CHANGES | APPROVE WITH CONDITIONS | APPROVE]
94+
- Reasoning: [...]
95+
```
96+
97+
Be skeptical but fair. Reference exact line numbers. Explain WHY something is problematic.
98+
NEVER default to approval — require the PR to prove its value.
99+
100+
interactive-claude:
101+
if: |
102+
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) ||
103+
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) ||
104+
(github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) ||
105+
(github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')))
45106
runs-on: ubuntu-latest
46107
permissions:
47108
contents: read
48-
pull-requests: write
49-
issues: write
109+
pull-requests: read
110+
issues: read
50111
id-token: write
112+
actions: read
51113
steps:
52114
- name: Checkout repository
53-
uses: actions/checkout@v4
115+
uses: actions/checkout@v6
54116
with:
55117
fetch-depth: 1
56118

57-
- name: Run Claude Code Review
58-
id: claude-review
59-
uses: anthropics/claude-code-action@v1
119+
- name: Run Interactive AI Assistant
120+
id: interactive-claude
121+
uses: anthropics/claude-code-action@beta
60122
with:
61123
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
62-
plugin_marketplaces: 'https://github.com/anthropics/claude-code.git'
63-
plugins: 'code-review@claude-code-plugins'
64-
prompt: '/code-review:code-review ${{ github.repository }}/pull/${{ github.event.pull_request.number }}'
65-
allowed_tools: 'Bash(gh pr *),Bash(gh api *),Bash(git diff *),Bash(git log *),Read,Glob,Grep'
124+
additional_permissions: |
125+
actions: read

0 commit comments

Comments
 (0)