ci: add automated Claude security review on PRs#10
Merged
Conversation
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.
Summary
Adds
.github/workflows/claude-pr-review.yml— an automated security + convention reviewer that posts a single PR comment with findings on every PR event.What it does
On
pull_request: [opened, synchronize, reopened, ready_for_review], Claude (viaanthropics/claude-code-action@v1) runs against the PR diff and posts exactly ONE top-level comment categorizing findings as:Clean PRs get a one-line ✅ confirmation.
Key design choices
release-please[bot]is typeBotand the content is already validated CI)--max-turns 8: caps runaway conversations; a single PR review should need ~3–5 turns--allowedTools "Bash,Read,Grep,Glob": Claude cannot write/edit files (read-only review), cannot spawn subagentscontents: read+pull-requests: write+issues: write— minimum neededThis workflow requires a repo secret
ANTHROPIC_API_KEYto work. Without it, every PR will fail this workflow (noisy but non-blocking — branch protection doesn't require this check).Steps:
gh secret set ANTHROPIC_API_KEY --repo chainbase-labs/agentkeyand pasteOptional: install https://github.com/apps/claude for nicer comment attribution.
Fork PR limitation
pull_requestevent on a public repo does not expose secrets to PRs from forks — this is a GitHub security measure. This means Claude review won't run on fork PRs.Mitigations:
gh pr checkout <N> && git push origin head:review/<N>to trigger a same-repo branch, getting a reviewworkflow_runpattern if external PRs become common. Not doing that now because there's attack surface there.Cost
Per-review cost is roughly token-proportional to diff size. For typical PRs (<500 lines), expect $0.10–$0.50 per review. Large refactor PRs can hit $2+. Tune
--max-turnsor add a max-diff-size gate if costs get out of hand.Test plan
python3 -c "import yaml; yaml.safe_load(...)")ci: ...); commitlint should passAPI_KEY="sk-ant-fake123..."to a file) gets flagged as 🚨 Critical