AI Security Workflows: Automated Vulnerability Management
AI Security Workflows: Automated Vulnerability Management

You've heard the worry: AI agents write less secure code. They grab any version of any package. They skip the vulnerability checks. They're not as careful as humans.
The worry isn't baseless. But it misses something important.
AI doesn't just create security risks. It can eliminate them at scale.
The recent React Server Components vulnerability hit millions of projects. Developers everywhere scrambled to patch their codebases by hand. What if your codebase could patch itself instead?
That's not science fiction. That's what happens when you treat security as an engineering problem instead of a one-off task.
Two layers of security
Security vulnerabilities come from two sources: the code you write and the packages you import. Each needs a different approach, and both can be automated.

Code-level vulnerabilities are the bugs you introduce: SQL injection, XSS, insecure authentication flows, hardcoded secrets. These require understanding your specific codebase.
Dependency vulnerabilities are inherited from packages: a compromised npm package, a CVE in a transitive dependency, an outdated library with known exploits. These require tracking external databases.
Most developers handle both reactively. Something breaks, someone notices, everyone scrambles. AI agents are good at exactly this kind of systematic, repeatable work.
Code-level security with Claude Code
Claude Code ships with a built-in /security-review command. It's not a fancy linter. It's a full security audit that reads context, spots patterns, and fixes what it finds.
/security-review
The command itself isn't the interesting part. What matters is what it represents: a reusable workflow.
Think about your current development process:
- Build the feature
- Write tests
- Run tests
- Deploy
Now add one step:
- Build the feature
- Write tests
- Run tests
- Run security review
- Deploy
Security review becomes part of your verification pipeline. Not an afterthought when something goes wrong. A gate that every change passes through.
Claude Code's security review catches:
- SQL injection vulnerabilities
- Cross-site scripting (XSS) risks
- Insecure authentication patterns
- Hardcoded credentials and secrets
- Path traversal vulnerabilities
- Insecure deserialization
- OWASP Top 10 issues
When it finds something, it doesn't just report. It can fix. The agent understands the codebase well enough to apply patches that actually work.
Dependency auditing by language
Every modern package manager now includes vulnerability scanning. A lot of developers miss this.
Here's the command for your ecosystem:
| Language | Command |
|---|---|
| JavaScript/TypeScript | npm audit or pnpm audit |
| Python | pip-audit |
| Java (Maven/Gradle) | dependency-check --scan . |
| .NET | dotnet list package --vulnerable |
| Ruby | bundle audit check |
| Go | govulncheck ./... |
| PHP | composer audit |
| Rust | cargo audit |
Each command reads your lockfile, compares against vulnerability databases, and lists affected packages with fix versions.
The output is structured. Structured output is parseable. Parseable output can be automated.
Building self-healing pipelines
This is where AI turns security from a burden into an advantage.
Consider this workflow:
# 1. Run the audit npm audit --json > audit-report.json # 2. Have Claude Code parse and fix # (Claude reads the JSON, identifies fixable issues, applies patches) # 3. Run tests to verify fixes don't break anything npm test # 4. Commit if tests pass git add . && git commit -m "security: patch vulnerabilities"
This can run as a GitHub Action. On a schedule. Automatically.
name: Security Patch on: schedule: - cron: '0 6 * * 1' # Every Monday at 6am workflow_dispatch: jobs: security-patch: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Run security audit run: npm audit --json > audit-report.json continue-on-error: true - name: Apply fixes with Claude Code run: | claude --print "Review audit-report.json and apply safe fixes. Run tests after each fix. Only commit fixes that pass tests." - name: Create PR if fixes applied run: | if [ -n "$(git status --porcelain)" ]; then git checkout -b security-patch-$(date +%Y%m%d) git add . git commit -m "security: automated vulnerability patches" gh pr create --title "Security Patches" --body "Automated fixes" fi
The pipeline runs weekly. Finds vulnerabilities. Applies fixes. Runs tests. Opens a PR if everything passes.
Your codebase heals itself.
Why this works
AI agents fit this kind of work because:
It's systematic. Security scanning follows predictable patterns. Run command, parse output, apply fix, verify. No creativity required.
It's repeatable. The same workflow works every time. Monday's audit uses the same logic as Thursday's audit.
It's comprehensive. An agent will check every dependency, every file, every pattern. It won't skip the boring parts.
It's fast. What takes a developer hours of context-switching takes an agent minutes of focused execution.
The worry that AI produces insecure code assumes AI runs without guardrails. Build security into the workflow and AI becomes the most consistent security engineer on your team.
Practical implementation
Start simple. Add /security-review to your development workflow. Run it after every feature, before every PR.
Then automate dependency scanning. Pick the audit command for your language. Run it in CI. Fail builds that introduce new vulnerabilities.
Finally, add the self-healing pipeline. Weekly scheduled runs. Automated fixes. Auto-created PRs. Let the system maintain itself.
Remember that React vulnerability that sent everyone scrambling? Projects with automated security pipelines had PRs waiting the same day the CVE was announced. No manual intervention required.
The engineering mindset
Security isn't a checkbox. It's not something you do once and forget. It's a continuous process that most teams treat as an interruption.
AI flips this. Security becomes infrastructure. Something that runs in the background. Something that handles itself.
You still need to review the PRs. You still need to understand what's changing. But the grunt work, the scanning, the patching, the testing, that happens automatically.
Build repeatable workflows. Create durable pipelines. Let the system handle the systematic work so you can focus on the interesting problems.
This isn't replacing human judgment. It's augmenting judgment with tireless automation.
Your codebase doesn't have to be a security liability. With the right workflows, it becomes self-defending.

Matthew Fontana
Staff Engineer at Airbnb · ex-Spotify, ex-UPS · 13 yrs in enterprise software
I build agentic developer platforms inside large engineering orgs, and I'm available to build them inside yours.