Skip to main content
subagent official · Anthropic

patch-generator — Claude Code subagent: security fixes as a patch

Turns one security finding into a staged change inside a throwaway clone, ready to be handed over as a patch file.

Install into Claude Code · Plugin marketplace All methods and platforms ↓
/plugin install claude-security@claude-plugins-official
Open on GitHub

What patch-generator does

This subagent never edits your working tree. It runs in a scratch clone that the fix job creates, checked out at a chosen patch base — detached, not on a branch. That base can sit ahead of the commit the report was built from, so a recorded line number is a hint at best; the flagged code is found through its snippet and symbol instead.

The change has to address the root cause and stay narrow: only what closing that single finding requires. No drive-by refactors, no dependency bumps. If the honest fix alters observable behaviour, summary must say which behaviour changed. When the code at this revision is no longer exploitable, or the call belongs to the owner, nothing is touched and summary explains why.

Before returning, the agent runs git add -A once inside the workspace so the staged diff covers every changed byte, new files included. Nothing is committed or pushed. An independent verifier inspects the diff and runs the tests, and the patch only leaves the run on a PASS. Dispatch comes from the fix job; there is no manual invocation. The agent installs nothing on its own — no packages, no toolchain — and uses the project's own test command. A suite that will not run in the environment gets reported, not worked around.

What it helps with

  • close one security finding without disturbing the rest of the code
  • produce a patch for review instead of committing straight to the repo
  • find the vulnerable spot by snippet when the line number has drifted
  • check whether the finding still reproduces at the current revision
  • flag a behaviour change in summary for the verifier

Example prompts for the agent

  • Fix the finding in the FINDING block inside WORKSPACE and leave the change staged
  • Locate the flagged code by snippet and symbol, treat the line number as a hint
  • If the finding does not reproduce at this revision, change nothing and explain in summary

How to install patch-generator

1Plugin marketplace

/plugin install claude-security@claude-plugins-official

2Manually: put the files in place

.claude/agents/patch-generator.md

For all projects use ~/.claude/agents/. Claude delegates by the description field or an @-mention

Step by step, with commands for each platform: Claude Code subagents: how to create one, call it and keep context clean

Questions about patch-generator

How do I install patch-generator in Claude Code?

From the marketplace: run /plugin install claude-security@claude-plugins-official, then add the agent file .claude/agents/patch-generator.md.

What does patch-generator do?

It fixes a single security finding inside a scratch clone and leaves the change staged. The fix job then writes that diff out as a patch you read and apply yourself.

Can I invoke it directly?

No, the fix job dispatches it. It refuses to run when the task carries no FINDING block or when WORKSPACE does not look like the clone that was created.

Similar subagents

All subagents for Security →

From the same set145

The whole set →
scan-redactor This Claude Security subagent replaces secret values in completed scan reports with [REDACTED]. Scan jobs dispatch it automatically; it is not for direct invocation. ★ 44,770repo stars scan-loader A restricted helper subagent shipped with the claude-security plugin. It reads one JSON file from a run directory and hands the content back untouched. ★ 44,770repo stars scan-inventory Internal cartographer subagent for the Claude Security scan workflow. It partitions repository directories into discrete review targets and tracks intentionally skipped paths. ★ 44,770repo stars patch-verifier Reviews a security fix in a scratch checkout, checks the staged diff and runs the project’s tests. A fix job dispatches it; it is not meant for direct invocation. ★ 44,770repo stars explore Read-only codebase explorer for Claude Code. Locates files, traces execution flows, and finds symbol callers without modifying code. ★ 44,770repo stars claude-security Scans a repository or its changes, then can turn verified findings into targeted patch files. It runs only as the main agent of a session. ★ 44,770repo stars revise-claude-md Reviews your active session to extract practical codebase learnings and updates CLAUDE.md or .claude.local.md. Helpful after discovering new CLI flags or test quirks. ★ 44,770repo stars new-sdk-app Walks you through a fresh Claude Agent SDK project: picks the language, sets up dependencies, writes a starter file and checks it compiles. ★ 44,770repo stars

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor