Security · Blog Post
Claude Code Security Review: Anthropic's security engineer in your CI
AI is writing more of your code; something has to check it with the same sophistication. Anthropic's official GitHub Action reviews every PR for real vulnerabilities — reasoning about what the code does, not pattern-matching what it looks like — and comments on the exact lines.
By Mehadi Hasan 6 min read
What it is
claude-code-security-review is Anthropic's own MIT-licensed security reviewer, shipped in two forms: a GitHub Action that automatically audits every pull request and comments findings on the specific lines, and a /security-review command you run inside Claude Code before the PR even exists. It's the same approach Anthropic uses internally, released as open source.
What distinguishes it from the SAST scanners you've already tried is the analysis model: Claude reads the diff in context — following data flow, understanding intent — rather than matching code against a rulebook. That's how it catches the vulnerabilities rule-based tools structurally can't see: business-logic flaws, authorization gaps, context-dependent injection.
At a glance
The vulnerability classes it hunts: injection (SQL, command, LDAP, XPath, NoSQL, XXE), broken authentication and authorization (privilege escalation, insecure direct object references), data exposure (hardcoded secrets, PII mishandling), cryptographic mistakes, missing input validation, business-logic and race-condition flaws, insecure configuration, unsafe deserialization and code execution, and all three flavors of XSS. Language-agnostic by design.
How it keeps the noise down
Every security team's first question about an AI reviewer is "how much noise?" — and the false-positive filtering is arguably this tool's real feature. After the analysis pass, findings go through a filter that drops the categories that waste reviewer attention:
- Denial-of-service and resource-exhaustion theories
- Rate-limiting recommendations
- Generic "add validation" advice with no demonstrated impact
- Open-redirect findings and similar low-severity classes
What survives is meant to be worth a human's time, each with a plain-English explanation of the attack path. If your threat model differs — maybe DoS does matter for your service — the filtering instructions are a config option, not a constant.
Installation
For the GitHub Action, add one workflow file and an API key secret:
.github/workflows/security.yml
name: Security Review
permissions:
pull-requests: write
contents: read
on:
pull_request:
jobs:
security:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}
fetch-depth: 2
- uses: anthropics/claude-code-security-review@main
with:
comment-pr: true
claude-api-key: ${{ secrets.CLAUDE_API_KEY }}
For the local command, copy security-review.md from the repo's .claude/commands/ folder into your project's .claude/commands/, then run /security-review in any Claude Code session. Useful Action options include exclude-directories, a model override, and custom false-positive filtering instructions.
Using it day to day
The two forms cover the two moments that matter. The /security-review command is the pre-flight check — run it on your working diff before pushing, fix what it finds while the context is still in your head. The Action is the safety net — it reviews every PR uniformly, including the ones written by coding agents at 2am, and leaves line-level comments a reviewer can act on directly.
One deployment note worth taking seriously: the README is explicit that the tool isn't hardened against prompt injection from adversarial PR content. Run it on trusted contributions — pair it with GitHub's "require approval for all external contributors" setting so workflows never execute on unreviewed third-party code.
Pricing
The tool is free and MIT-licensed; you pay for the Claude API tokens each review consumes, via an Anthropic API key with Claude Code usage enabled stored as a repository secret. For a typical team's PR volume that's coffee money — and materially cheaper than the enterprise SAST seat it partially replaces.
My take
There's a neat symmetry in Anthropic shipping the tool that reviews the code its own models increasingly write — and it's the right shape: uniform coverage, semantic depth, line-level actionability, and an unusually honest stance on its own limits. The false-positive filtering is what makes it deployable; an AI reviewer that cried wolf on every PR would be uninstalled within a week.
Treat it as a strong additional layer, not a replacement for your security program: it reviews diffs, not your whole attack surface, and no reviewer — human or AI — catches everything. But as the default answer to "who security-reviews the AI-generated code?", this is the easiest credible answer to deploy today, and it slots cleanly alongside Spec Kit-style structured workflows as the verification half of the loop.
Frequently asked questions
How is this different from a traditional SAST scanner?
Static analyzers pattern-match known bad code shapes; this uses Claude to reason about what the code actually does — so it catches business-logic flaws, privilege escalation paths, and context-dependent injection that rule-based tools miss, and it explains each finding in plain English on the PR.
Will it bury my PRs in nitpicks?
It's deliberately tuned against that: a false-positive filtering pass drops low-impact noise like denial-of-service theories, rate-limiting concerns, and generic "add validation" advice without proven impact. You can customize the filtering instructions if your risk profile differs.
What does it cost to run?
The Action and command are MIT-licensed and free; you pay for Claude API usage per scan. Each PR review needs an Anthropic API key with Claude Code usage enabled, passed as a repository secret.
Can external contributors abuse it with prompt injection?
The README is explicit that the tool is not hardened against adversarial PRs — Anthropic recommends running it on trusted contributions only, using GitHub's "require approval for all external contributors" setting so workflows never run on unreviewed third-party code.