AI has changed how fast developers ship. Your AI agent can build a feature in an afternoon, and in one week a bunch of agents can generate more code than a single developer could review in their lifetime.
With agents generating so many features, it's not always feasible to read every line yourself. This doesn't mean you have to stop caring about security though. AI is particularly good at re-running something over and over again. This makes it perfect at catching security vulnerabilities when it knows what to look for.
Make running AI security scans part of your daily workflow. Scan your diff on every commit, so you catch the issue while the fix is still a 2-line change, not a post-merge incident. Then audit the whole app every Sprint.
AI writes code that works, not necessarily code that's safe. This doesn't mean that AI is the enemy but you should treat every PR as guilty until proven innocent.
Veracode's October 2026 GenAI Code Security update found 38% of AI coding tasks still produced vulnerable code. That's better than 45% in 2025, but even the best models, Claude Opus 5.5 and GPT-6-Sol, failed 1 in 4 security tasks.
Figure: Security pass rate is flat (Veracode 2025 AI Security Study)
Some security risks when using AI:
A human review still matters, but a reviewer reading a 1k+ line PR will easily skim over certain security issues. This is another reason why pulling down the changes and testing locally is still an important step for catching issues.
You should be running security scans throughout the whole development process. Scans are cheap, fixing incidents is not.
Use 2 kinds of scan. They complement each other because they look at different things:
/security-review checks only what you've changed, so it's fast enough to run every time---
config:
themeVariables:
xyChart:
plotColorPalette: "#cc4141"
---
xychart-beta
title "Bad (Contrived Data): 1 scan, just before release"
x-axis ["Wk 1", "Wk 2", "Wk 3", "Wk 4", "Wk 5", "Wk 6 SCAN"]
y-axis "Unscanned issues in main" 0 --> 40
bar [6, 12, 19, 25, 31, 37]❌ Figure: Bad example - No scans for 5 weeks, so issues pile up in main. The only scan finds all 37 at once, right before you ship
---
config:
themeVariables:
xyChart:
plotColorPalette: "#333333"
---
xychart-beta
title "Good (Contrived Data): a diff scan every commit, a full audit every Sprint"
x-axis ["Wk 1 SCAN", "Wk 2 SCAN+AUDIT", "Wk 3 SCAN", "Wk 4 SCAN+AUDIT", "Wk 5 SCAN", "Wk 6 SCAN+AUDIT"]
y-axis "Unscanned issues in main" 0 --> 40
bar [1, 0, 1, 0, 1, 0]✅ Figure: Good example - Every commit is scanned, so issues get fixed on the branch. The Sprint audit catches what the diff scans missed, so main stays close to zero
Claude comes pre-built with security scanning tools. Before each commit, run the following command in Claude Code on your feature branch:
/security-review
Claude will review all pending changes on the branch, looking for common attack vectors such as SQL injections, XSS, authentication and authorisation flaws, insecure data handling, and vulnerable dependencies. When it finds something, ask it to fix it in the same session. See Automated security reviews in Claude Code.
We also encourage using Anthropic's AI security reviewer. You can add this to your GitHub repository workflow anthropics/claude-code-security-review
Unlike Claude, Codex requires a plugin to conduct security scans. Install the Codex Security plugin, then ask Codex to review your changes before each commit:
Use $codex-security:security-diff-scan to review the changes from origin/main to HEAD, plus my uncommitted changes, for security regressions.
It'll review each changed file plus the code paths that flow in and out from the change, without turning into a full repository audit. You can also run it from Security -> Scans in the Codex desktop app. See Review code changes for security.
Copilot CLI has its own /security-review command that scans your local changes before you commit. It's currently an experimental feature in public preview, so make sure to turn on experimental mode first. See the GitHub changelog.
Tip: Back up the local scan with a PR check, so a skipped scan still gets caught. The claude-code-security-review GitHub Action runs the same analysis on every PR and comments inline. Pin it to a commit SHA, not @main.
Only run the PR Action on trusted PRs. Its README warns it is not hardened against prompt injection. A PR from a fork can hide instructions in a comment that tell the reviewer to approve it. Require approval before workflows run for outside contributors. See Do you stop pwn requests from running with your GitHub secrets?
A diff scan can't see how your changes fit with the rest of the app. Once a Sprint, or every week on a busy repo, run Cloudflare's open-source security-audit skill over the whole codebase.
Install it:
npx skills add https://github.com/cloudflare/security-audit-skill --skill security-audit
Then ask your AI agent:
security audit this codebase
It maps the architecture and trust boundaries, sends isolated sub-agents to hunt for bugs, then has fresh agents try to disprove every finding. Each finding comes back as confirmed, needs_validation or rejected. Add the confirmed ones to your backlog as PBIs, and check the needs_validation ones by hand.
Runs build on each other. In Cloudflare's test runs, a single run found roughly half of what repeated runs found, which is why it belongs on a regular schedule, not a one-off.
Run it in a sandbox. To prove a finding, the skill wants to build and run your code. It needs an OS-level sandbox with no network access, a clean environment, resource limits, and writes limited to a scratch folder. Without one, it marks the finding needs_validation instead of running anything.
No single tool covers everything. That's why it's so important to layer them.
| Tool | When it runs | What it's best at |
|---|---|---|
Claude Code /security-review (Recommended) | Every commit | Injection, XSS, auth flaws, insecure data handling and vulnerable dependencies in your diff, with fixes in the same session |
Codex Security security-diff-scan | Every commit | The same diff check for teams on Codex |
Copilot CLI /security-review (preview) | Every commit | The same diff check for teams on Copilot |
| Cloudflare security-audit skill (Recommended) | Every Sprint | Whole-app flaws across trust boundaries that no single diff shows |
| claude-code-security-review Action | On every PR | Safety net when someone skips the local scan |
| GitHub code scanning + Copilot Autofix | On every PR | Known vulnerability patterns, with a suggested fix |
| GitHub secret scanning push protection | At git push | Blocks the push when it detects a secret (free on Public Repos) |
An AI scan complements human review and Penetration Testing. It doesn't replace them. Anthropic says the same about its own tool.