Skip to content

Commit f7823fc

Browse files
claudeenko
authored andcommitted
fix: clean up review prompt — fix fencing, trim bloat, improve accuracy
- Fix broken nested code fences in Comment Format section (``` inside ```) by using ~~~ for the outer fence - Make AGENTS.md Compliance section dynamic: replace hardcoded generic placeholders with instruction to derive items from actual AGENTS.md - Remove ~55 lines of hypothetical AGENTS.md examples (Security-Focused, Performance-Critical, API Project) that added noise without value - Trim Language-Specific Focus table to TypeScript/JS and SQL only (the only languages in this project) - Remove duplicate PR_NUMBER and CI_RUN_URL definitions from Execution Context (already defined in Phase 1.1) - Make summary posting consistently file-based: use jq to build JSON payload from temp file for both create and update paths, avoiding shell escaping issues with $(cat ...) subshells https://claude.ai/code/session_01HpnShWs5di3uhcDhkXncGr
1 parent 654096c commit f7823fc

File tree

1 file changed

+14
-84
lines changed

1 file changed

+14
-84
lines changed

.github/prompts/code-review-prompt.md

Lines changed: 14 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ You are an expert code reviewer executing in GitHub Actions CI to analyze a pull
2121
> - A `## 🔍 Automated Code Review` heading
2222
> - A metadata table with Commit, Reviewed, and Status rows
2323
> - A `### Findings` section with a severity table or "No issues found."
24-
> - A `### AGENTS.md Compliance` section with checklist items
24+
> - A `### AGENTS.md Compliance` section with checklist items **derived from the actual AGENTS.md rules** (not generic placeholders)
2525
> - A `### Summary` section with prose
2626
> - A footer with the CI run link
2727
@@ -41,18 +41,6 @@ You are running in GitHub Actions via `anthropics/claude-code-action`. You have
4141
- `GITHUB_SERVER_URL` — GitHub server URL
4242
- `GITHUB_EVENT_PATH` — Path to event JSON payload
4343

44-
**PR number extraction:**
45-
46-
```bash
47-
PR_NUMBER=$(jq -r '.pull_request.number' "$GITHUB_EVENT_PATH")
48-
```
49-
50-
**CI run URL:**
51-
52-
```bash
53-
CI_RUN_URL="${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}"
54-
```
55-
5644
-----
5745

5846
## Phase 1: Initialize
@@ -219,7 +207,7 @@ cursor.execute(query, (user_id,))
219207

220208
**Comment Format:**
221209

222-
```
210+
~~~
223211
[ICON] **[Category]: [Brief Title]**
224212
225213
[1-2 sentence explanation of impact/risk]
@@ -228,8 +216,8 @@ cursor.execute(query, (user_id,))
228216
```[language]
229217
[concrete code example]
230218
```
219+
~~~
231220

232-
```
233221
**Volume Limit:** Maximum 10 inline comments per run. Prioritize: Critical > Important > Suggestion.
234222

235223
### 3.3 Update Summary Comment (Always Required)
@@ -259,8 +247,9 @@ SHORT_SHA=$(echo "$GITHUB_SHA" | head -c 7)
259247
REVIEW_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
260248
# STATUS: one of "✅ Approved", "⚠️ Comments", "🚨 Changes Requested"
261249
# CRITICAL_COUNT, IMPORTANT_COUNT, SUGGESTION_COUNT: integer counts
262-
# AGENTS_SECURITY, AGENTS_ARCHITECTURE, AGENTS_TESTING: "✅" or "❌"
263250
# SUMMARY_TEXT: 1-3 sentence prose summary of the review
251+
# COMPLIANCE_LINES: multi-line string of "- ✅/❌ ..." items derived from AGENTS.md
252+
# (use the actual rules you read from AGENTS.md — do NOT use generic placeholders)
264253

265254
cat > /tmp/review-summary.md << ENDOFSUMMARY
266255
<!-- CLAUDE_CODE_REVIEW -->
@@ -282,9 +271,7 @@ cat > /tmp/review-summary.md << ENDOFSUMMARY
282271
283272
### AGENTS.md Compliance
284273
285-
- ${AGENTS_SECURITY} Security requirements
286-
- ${AGENTS_ARCHITECTURE} Architecture patterns
287-
- ${AGENTS_TESTING} Testing standards
274+
${COMPLIANCE_LINES}
288275
289276
### Summary
290277
@@ -297,13 +284,19 @@ ENDOFSUMMARY
297284

298285
**Step 3 — Post or update the comment using the file:**
299286

287+
Build a JSON payload from the file (this avoids shell escaping issues with `$()` subshells):
288+
300289
```bash
290+
jq -n --rawfile body /tmp/review-summary.md '{"body": $body}' > /tmp/review-payload.json
291+
301292
if [ -n "$SUMMARY_ID" ]; then
302293
gh api "repos/${GITHUB_REPOSITORY}/issues/comments/${SUMMARY_ID}" \
303294
-X PATCH \
304-
-f body="$(cat /tmp/review-summary.md)"
295+
--input /tmp/review-payload.json
305296
else
306-
gh pr comment "$PR_NUMBER" --body-file /tmp/review-summary.md
297+
gh api "repos/${GITHUB_REPOSITORY}/issues/${PR_NUMBER}/comments" \
298+
-X POST \
299+
--input /tmp/review-payload.json
307300
fi
308301
```
309302

@@ -366,10 +359,6 @@ fi
366359
|Language |Priority Checks |
367360
|---------------------|----------------------------------------------------------|
368361
|TypeScript/JavaScript|Type safety, async patterns, memory leaks, null coalescing|
369-
|Python |Type hints, exception handling, context managers |
370-
|Java/Kotlin |Null safety, resource management, thread safety |
371-
|Go |Error handling, goroutine leaks, defer usage |
372-
|Rust |Ownership, unsafe blocks, error propagation |
373362
|SQL |Injection risks, missing indexes, N+1 patterns |
374363

375364
-----
@@ -401,65 +390,6 @@ fi
401390

402391
-----
403392

404-
## AGENTS.md Examples
405-
406-
### Security-Focused Project
407-
408-
```markdown
409-
# AGENTS.md
410-
411-
## MUST-PASS Security Requirements
412-
- All user input sanitized via `lib/sanitize.ts`
413-
- Database queries use parameterized statements only
414-
- No secrets in code - use environment variables
415-
- JWT validation required on authenticated endpoints
416-
417-
## Architecture
418-
- Repository pattern for data access
419-
- Services use dependency injection
420-
421-
## Testing
422-
- Unit tests required for new functions
423-
- Integration tests for API endpoints
424-
```
425-
426-
### Performance-Critical Application
427-
428-
```markdown
429-
# AGENTS.md
430-
431-
## REQUIRED Performance Rules
432-
- No N+1 queries - use eager loading
433-
- Pagination required for collections > 100 items
434-
- Cache external API calls (minimum 5min TTL)
435-
436-
## Permitted Patterns
437-
- Lazy loading for images and heavy assets
438-
- Debounced input handlers (300ms default)
439-
440-
## Forbidden
441-
- Synchronous I/O in request handlers
442-
- Loading unbounded datasets into memory
443-
```
444-
445-
### API Project
446-
447-
```markdown
448-
# AGENTS.md
449-
450-
## API Standards (MUST-PASS)
451-
- All endpoints return consistent error format
452-
- Breaking changes require version bump
453-
- Rate limiting on public endpoints
454-
- Request validation via Zod schemas
455-
456-
## Documentation
457-
- OpenAPI spec updated for new endpoints
458-
- README updated for new environment variables
459-
```
460-
461-
-----
462-
463393
## Final Checklist (verify before finishing)
464394

465395
Before completing the review, confirm:

0 commit comments

Comments
 (0)