Skip to content

Commit ca1fc77

Browse files
Improve Claude workflows (#211)
* Use unified review API for code review comments Switch from posting individual inline comments and separate summary to GitHub's Pull Request Review API. All comments now submit together as a single review event, matching native GitHub review flow. * Add review thread management and resolution Enables Claude to maintain conversation continuity by resolving fixed issues and replying to existing threads instead of creating duplicate comments on subsequent reviews. - Fetch existing review threads via GraphQL before each review - Resolve threads when issues are fixed using resolveReviewThread - Reply to existing threads when issues persist - Only create new comment threads for genuinely new issues * Add superpowers workflow to Claude agent Guides Claude through brainstorming, planning, and implementation when invoked via @claude mentions. Uses autonomous Socratic brainstorming, writes temporary planning docs, completes full implementation, then performs self-review at the end for efficiency.
1 parent 4d4714b commit ca1fc77

File tree

2 files changed

+153
-10
lines changed

2 files changed

+153
-10
lines changed

.github/workflows/claude-code-review.yml

Lines changed: 106 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,17 +92,65 @@ jobs:
9292
d. What tests are needed?
9393
e. Does this need documentation updates?
9494
95-
### 6. Execute Review
95+
### 6. Fetch Existing Review Threads
96+
97+
Before creating your review, fetch existing Claude review threads to enable thread continuity:
98+
99+
```bash
100+
# Get PR owner and repo name
101+
OWNER=$(gh repo view --json owner --jq '.owner.login')
102+
REPO=$(gh repo view --json name --jq '.name')
103+
104+
# Fetch all review threads
105+
gh api graphql -f query='
106+
query($owner: String!, $name: String!, $pr: Int!) {
107+
repository(owner: $owner, name: $name) {
108+
pullRequest(number: $pr) {
109+
reviewThreads(first: 100) {
110+
nodes {
111+
id
112+
isResolved
113+
path
114+
line
115+
comments(first: 10) {
116+
nodes {
117+
id
118+
databaseId
119+
body
120+
author { login }
121+
}
122+
}
123+
}
124+
}
125+
}
126+
}
127+
}' -f owner="$OWNER" -f name="$REPO" -F pr=${{ github.event.pull_request.number }}
128+
```
129+
130+
**Parse the response** - structure is:
131+
```
132+
.data.repository.pullRequest.reviewThreads.nodes[]
133+
```
134+
135+
Filter for threads where `comments.nodes[0].author.login` is "claude" or "github-actions[bot]". These are your previous review comments.
136+
137+
**Important notes:**
138+
- `line` can be `null` for file-level comments (not line-specific)
139+
- Use `id` (format: PRRT_xxx) for resolveReviewThread mutations
140+
- Use `databaseId` (format: 2518555173) for comment replies
141+
142+
### 7. Execute Review
96143
97144
Launch superpowers:code-reviewer subagent (Task tool) with the context gathered above:
98145
- Full PR diff from step 3
99146
- Relevant architecture patterns from CLAUDE.md
100147
- Documentation requirements from step 4
101148
- Previous review feedback (if incremental update from step 2)
149+
- Existing review threads from step 6
102150
103151
The code-reviewer will analyze correctness, architecture, testing, and code quality.
104152
105-
### 7. Post Review
153+
### 8. Post Review
106154
107155
**Writing style**:
108156
- Be direct. One clear point per issue.
@@ -111,7 +159,7 @@ jobs:
111159
- If issues found: State the issue, reference location, explain why it matters. Move on.
112160
113161
**Format**:
114-
- **Inline comments** (using `mcp__github_inline_comment__create_inline_comment`): Use for specific line-by-line code issues
162+
- **Inline comments**: Use for specific line-by-line code issues (file path, line number, comment)
115163
- **Main comment**: Summary only - overall assessment, architectural concerns, testing strategy, verdict. Do NOT duplicate inline comments here.
116164
117165
**Main comment - write naturally:**
@@ -121,14 +169,65 @@ jobs:
121169
- New concerns: "New issue: error handling in container.ts doesn't cover..."
122170
- Overall verdict: "Looks good" or "Needs fixes before merge"
123171
124-
**Post inline comments** for specific code issues using `mcp__github_inline_comment__create_inline_comment`
172+
**Handle existing threads before submitting new review:**
125173
126-
**Post your main comment:**
174+
For each thread from step 6, compare with your new findings:
175+
- **Issue is fixed:** Mark for resolution (save thread ID)
176+
- **Issue persists but needs update:** Mark for reply (save comment database ID)
177+
- **Issue no longer relevant:** Mark for resolution
178+
179+
**Submit review as a single cohesive unit:**
180+
181+
1. Get the latest commit SHA:
127182
```bash
128-
gh pr comment ${{ github.event.pull_request.number }} --body "YOUR_REVIEW_HERE" --repo ${{ github.repository }}
183+
COMMIT_SHA=$(gh pr view ${{ github.event.pull_request.number }} --json headRefOid --jq '.headRefOid')
129184
```
130185
186+
2. Create review.json with ONLY NEW issues (don't duplicate existing thread issues):
187+
```json
188+
{
189+
"body": "## Claude Code Review\n\nYour overall assessment here...",
190+
"event": "COMMENT",
191+
"commit_id": "COMMIT_SHA_HERE",
192+
"comments": [
193+
{
194+
"path": "path/to/file.ts",
195+
"line": 42,
196+
"body": "Your inline comment here"
197+
}
198+
]
199+
}
200+
```
201+
202+
3. Post the unified review:
203+
```bash
204+
gh api repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/reviews \
205+
--method POST \
206+
--input review.json
207+
```
208+
209+
4. **Manage existing threads (after review submission):**
210+
211+
Resolve fixed issues:
212+
```bash
213+
gh api graphql -f query='
214+
mutation($threadId: ID!) {
215+
resolveReviewThread(input: {threadId: $threadId}) {
216+
thread { id isResolved }
217+
}
218+
}' -f threadId="THREAD_ID_FROM_STEP_6"
219+
```
220+
221+
Reply to threads that need updates:
222+
```bash
223+
gh api repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/comments/COMMENT_DATABASE_ID/replies \
224+
--method POST \
225+
-f body="Update: Issue has been partially addressed but..."
226+
```
227+
228+
**Important**: This workflow maintains conversation continuity - resolved issues show as "Resolved", ongoing issues have threaded replies, and only new issues create new comment threads.
229+
131230
Always post a NEW comment - never update previous ones. Natural conversation flow.
132231
# See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md
133232
# or https://docs.claude.com/en/docs/claude-code/cli-reference for available options
134-
claude_args: '--allowedTools "Task,Skill,mcp__github_inline_comment__create_inline_comment,mcp__cloudflare-docs__search_cloudflare_documentation,mcp__exa__get_code_context_exa,mcp__exa__web_search_exa,Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*),Bash(gh api:*),Bash(git *)"'
233+
claude_args: '--allowedTools "Task,Skill,Write,mcp__cloudflare-docs__search_cloudflare_documentation,mcp__exa__get_code_context_exa,mcp__exa__web_search_exa,Bash(gh pr view:*),Bash(gh pr diff:*),Bash(gh repo view:*),Bash(gh api:*),Bash(git *)"'

.github/workflows/claude.yml

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,60 @@ jobs:
4141
additional_permissions: |
4242
actions: read
4343
44-
# Custom prompt that ensures Claude reads CLAUDE.md first
4544
prompt: |
4645
REPO: ${{ github.repository }}
4746
ISSUE/PR: #${{ github.event.issue.number || github.event.pull_request.number }}
4847
49-
IMPORTANT: Before starting any work, read the CLAUDE.md file at the root of this repository. It contains critical project conventions, architecture patterns, and development guidelines that you must follow.
48+
## Task Context
5049
51-
After reading CLAUDE.md, proceed with the following task:
5250
${{ github.event.comment.body || github.event.issue.body || github.event.review.body }}
5351
52+
## Workflow Instructions
53+
54+
**STEP 1: Read project conventions**
55+
Read CLAUDE.md at the root of this repository. It contains critical project conventions, architecture patterns, and development guidelines.
56+
57+
**STEP 2: Assess task complexity**
58+
Determine if this task requires planning:
59+
- **Needs planning**: New features, architectural changes, significant refactoring, adding major functionality
60+
- **Direct execution**: Bug fixes, test fixes, investigations, documentation updates, simple one-line changes
61+
62+
**STEP 3: Execute appropriate workflow**
63+
64+
**For tasks needing planning:**
65+
1. Use the brainstorming skill (`superpowers:brainstorming`) to:
66+
- **IMPORTANT**: You are working autonomously (no user to answer questions)
67+
- Use Socratic method on yourself: ask questions, explore answers, consider trade-offs
68+
- The task context above contains all available information
69+
- Explore 2-3 different approaches with pros/cons
70+
- Design the solution covering: architecture, components, data flow, error handling, testing
71+
- Save design to `/tmp/claude-plans/YYYY-MM-DD-<topic>-design.md` (temporary, not committed)
72+
73+
2. Use the writing-plans skill (`superpowers:writing-plans`) to:
74+
- Create detailed, bite-sized implementation plan
75+
- Include exact file paths, complete code examples, verification steps
76+
- Save plan to `/tmp/claude-plans/YYYY-MM-DD-<feature>-implementation.md` (temporary, not committed)
77+
78+
3. Execute the complete implementation:
79+
- Follow TDD for all code changes (write test first, watch fail, implement, verify pass)
80+
- Complete the entire implementation
81+
- Run all tests and verification steps
82+
- **After completion**: Use requesting-code-review skill to review your own work
83+
- Fix any issues found in self-review
84+
- Commit changes following CLAUDE.md git guidelines
85+
86+
**For direct execution tasks:**
87+
- Use test-driven-development for code changes
88+
- Use systematic-debugging for investigations
89+
- Use verification-before-completion before claiming done
90+
- Follow CLAUDE.md conventions
91+
92+
**REMEMBER:**
93+
- If a superpowers skill applies to your task, you MUST use it (not optional)
94+
- Write tests before code (TDD iron law)
95+
- Verify with evidence before claiming completion
96+
- Create commits following CLAUDE.md git guidelines
97+
5498
# Optional: Add claude_args to customize behavior and configuration
5599
# See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md
56100
# or https://docs.claude.com/en/docs/claude-code/cli-reference for available options

0 commit comments

Comments
 (0)