Claude PR review bot: four-category scorecard comment on every PR#80
Merged
Conversation
On PR open/push, fetches the diff, asks claude-sonnet-4-6 for a four-category scorecard (syntax/smells/bugs/security), and upserts one sticky comment per PR. Hardened relative to the original sketch: pull_request trigger only (secrets never reach fork PRs), fork PRs skipped via if-guard, concurrency cancels superseded runs, diff cap raised to 200k chars with a visible truncation notice, diff wrapped as untrusted data against prompt injection, API errors fail the step. Requires the ANTHROPIC_API_KEY repo secret (admin needed to add it). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Code review overview
Syntax ErrorsNo issues found. Code Smells
Bugs
Security Vulnerabilities
|
The bot's own first review caught this: gh api --paginate emits each page as a separate JSON document, so json.loads breaks once a PR accumulates more than one page of comments. Use --slurp (pages wrapped in one array) and flatten. Comment body now goes via --input - on stdin instead of an argv -f flag. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds an automated code-quality gate: on every PR open/push, Claude reviews the diff and posts a scorecard comment (Syntax Errors / Code Smells / Bugs / Security Vulnerabilities, each 1-10 with findings).
Files
.github/workflows/review.yml— trigger + permissions.github/scripts/review.py— fetch diff viagh api, callclaude-sonnet-4-6, upsert one sticky comment per PRSecurity / hardening (deliberate choices)
pull_request, neverpull_request_target: GitHub withholds secrets from fork PRs underpull_request, so untrusted code can never readANTHROPIC_API_KEY. Fork PRs are skipped cleanly by anif:guard. Please treat any future switch topull_request_targetas an alarm bell (pwn-request secret-exfiltration class).concurrencycancels the in-flight review when a new push supersedes it.<diff>tags and declared untrusted data (prompt-injection hygiene).Setup required before this works
Add repository secret
ANTHROPIC_API_KEY(Settings → Secrets and variables → Actions). Cost is roughly $0.01–0.05 per review at Sonnet pricing.Tests
tools/tests/test_pr_review_script.py(4 tests) covers the pure functions: truncation boundary and sticky-comment lookup.🤖 Generated with Claude Code