Generates minimal security fixes using transactional isolation (shadow directories or file backups), applies patches, and verifies them. Use when security findings are successfully reproduced and need patches applied and verified. Don't use for initial vulnerability research or reproduction payload generation.
Works with
AI-first code editor with Composer
Before installing skills in Cursor, ensure your development environment meets these requirements:
node --versionmantis-patchExecute the skills CLI command in your project's root directory to begin installation:
Fetches mantis-patch from google/mantis and configures it for Cursor.
The CLI shows a list of agents. Use arrow keys and space to select Cursor:
Confirm successful installation by checking the skill directory location:
Restart Cursor to activate mantis-patch. Access via /mantis-patch in your agent's command palette.
We perform automated surface-level scans (Gen AI Scanner, Socket, Snyk) during installation. These checks detect common vulnerabilities but do not guarantee complete security. Always review skill source code and verify the publisher's reputation before production use.
Skills execute code in your environment. Always review source, verify the publisher, and test in isolation before production.
Submit your Claude Code skill and start earning
Automate repetitive workflows and reduce manual effort
Example
Generate reports, summarize documents, draft communications
Save 3-5 hours per week on routine tasks
Learn new skills, understand complex topics, get expert guidance
Example
Explain concepts, provide examples, suggest learning resources
Accelerate learning and skill development by 2x
Enhance output quality through reviews, suggestions, and refinements
Example
Review drafts, suggest improvements, catch errors
Improve work quality by 30-40% with less effort
0
total installs
0
this week
307
GitHub stars
0
upvotes
Run in your terminal
0
installs
0
this week
307
stars
| name | mantis-patch |
| description | >- Generates minimal security fixes using transactional isolation (shadow directories or file backups), applies patches, and verifies them. Use when security findings are successfully reproduced and need patches applied and verified. Don't use for initial vulnerability research or reproduction payload generation. |
Security Patching Expert. Generates minimal, correct code fixes, applies them to source code files, and verifies them inside isolated sandboxes before appending logs to long-term memory.
/mantis-patchworkspace/findings/ (reproduced finding JSON files where
patch_status is not "VERIFIED_SECURE").workspace/.mantis_state.json (to track current loop pass).repro_file_path) and command (run_command)
from findings."patch_status",
"patch_diff", re-attack details, and history).workspace/learnings.jsonl.workspace/helpers/append_patch.py.workspace/findings/.patch_status is already "VERIFIED_SECURE"./tmp/mantis-shadow-[id]/) or creates temporary file backups
(target.c.bak-[id]), restoring baseline state upon completion (using
try...finally rollback mechanisms).append_patch.py script once created.Fix successfully reproduced security flaws without breaking standard code behavior.
Execute the patching and verification stage as follows:
Load Findings to Patch: Read the JSON files in the workspace/findings/
directory. Filter for findings where patch_status is NOT
"VERIFIED_SECURE" AND (either repro_status is "reproduced" OR the
finding is an exploit chain, e.g., the title starts with "Exploit Chain:",
or history has an entry from the "chainer" stage, or the
"constituent_findings" property is present and non-empty). If none exist,
notify the user.
Generate and Apply Minimal Patches: For each reproduced security flaw:
Target Agnosticism (Binaries vs Source): If the target is source
code, proceed with generating and applying a code patch as described
below. If the target is a compiled binary or firmware blob without
source code available, do not attempt to modify the binary or write
binary patching scripts. Instead, skip the branch
isolation/modification/diff steps and generate a general, high-level
recommendation for how this issue could be mitigated in a production
environment without requiring deep technical depth. Output this
mitigation string in place of the patch_diff field.
Exploit Chains: If the finding is an exploit chain (identified by
"Exploit Chain:" in the title, or history details, or if the
"constituent_findings" property is present and non-empty), do not
generate a code patch or diff. Instead, identify its sub-findings by
reading the "constituent_findings" array of UUIDs. Monitor the patch
status of these constituent findings (listed on disk as
workspace/findings/<uuid>.json). Important: You must defer
evaluating exploit chains until all individual findings in the batch
have been processed, so that the latest patch statuses of their
constituents are available on disk. Once all constituent findings have
been patched and verified (status "VERIFIED_SECURE"), mark the chain
finding as "VERIFIED_SECURE". If any constituent patch fails, mark the
chain as "VERIFICATION_FAILED". Skip branch isolation, testing, and
re-attack steps for the chain finding itself.
Optional Parallel Trajectory Search: If your framework supports subagents, you may spawn multiple concurrent subagents to design diverse patch implementations. Test all generated patches that successfully secure the code without breaking standard functionality, and select the best patch (e.g., the most minimal, readable, and idiomatic fix) rather than just the first one that works.
Read the original flawed file to grasp function dependencies and structures.
Design a minimal, correct patch to mitigate the security flaw (e.g. adding bound checks, validating sizes, inserting NUL-terminators) without breaking other features.
Transactional Isolation (VCS-Agnostic & Safe): To ensure safety,
reliability, and VCS-agnosticism, do NOT use VCS-based branch operations
(such as git branch, git checkout, or git stash).
You must ensure transactional isolation using a method appropriate for the operating environment. You may choose Option A: Temporary Directory Shadowing (recommended), Option B: File-Level Backups, or design/implement Option C: Alternative Isolation (e.g., namespace isolation, container volumes, or local sandboxes) as long as it fully satisfies the invariants below.
Whichever method you choose, you must guarantee these invariants:
try...finally blocks to restore the original state on failure.Option A: Temporary Directory Shadowing (Recommended)
/tmp or memory./tmp/mantis-shadow-[finding_id]/).Option B: File-Level Backups (Fallback)
*.bak-[current_finding_id]). If found, restore and
delete them.cp target.c target.c.bak-[finding_id]).diff -u --label target.c --label target.c target.c.bak-[finding_id] target.c).Post-Patch Verification Run: (Skip this step for binary-only targets
where no code patch was applied). To confirm the patch works, re-run the
reproducer script inside your isolated execution environment. Use the exact
"repro_file_path" and "run_command" from the reproduction entry to
verify the patch.
@mantis-reproduce --reattack subagent
against the patched code directory to perform this re-attack. The
reproducer agent running with --reattack will write its outcomes
directly into the primary finding's reattack_status,
reattack_file_path, reattack_run_command, and reattack_output
fields on disk, keeping the initial repro_* fields untouched.Extract Patch and Rollback Transaction: (Skip this step for binary-only
targets). Do not leave the codebase in an altered state. Once you have a
final outcome (either VERIFIED_SECURE or you have exhausted your retries):
"patch_diff" field:
diff -u --label target.c --label target.c target.c.bak-[finding_id] target.c)."patch_diff" string.
Do NOT use VCS-specific diff commands.rm -rf /tmp/mantis-shadow-[finding_id]).
Since the original codebase was never modified, no further
restoration is needed.cp target.c.bak-[finding_id] target.c), delete the backup copies (rm target.c.bak-[finding_id]), and delete any net-new files created
during the patching process.Append to Long-Term Memory (Continuous Reviewing Link): For each
security flaw processed, append a single structured JSON line to a workspace
database file named workspace/learnings.jsonl (using append mode). This
allows the strategist (/mantis-plan) to read these historical records in
subsequent passes and avoid proposing fixes for already patched files.
{"title": "[security_flaw_title]", "code_paths": ["[path1:line1]"], "status": "[VERIFIED_SECURE / VERIFICATION_FAILED / ERROR]"}Token-Optimized File Updates: To minimize LLM output tokens, do not
re-emit or manually rewrite the entire JSON object in your output.
Instead, write a reusable helper script (e.g.,
workspace/helpers/append_patch.py) during your first finding update. For
all subsequent findings, do not regenerate the script; simply execute the
existing helper script with the new parameters to append the required
fields.
You must append the following to the existing object:
"patch_status" field (e.g., "VERIFIED_SECURE",
"VERIFICATION_FAILED", or "ERROR")."patch_diff" field containing the unified
diff."reattack_status",
"reattack_file_path", "reattack_run_command", and
"reattack_output" fields."history" array:{
"stage": "patch",
"action": "patched",
"details": "Patch status evaluated as [VERIFIED_SECURE/VERIFICATION_FAILED/ERROR]",
"pass_number": <current_pass_number>,
"timestamp": "<current_iso8601_timestamp>"
}
When complete, notify the user.
Prerequisites
Time Estimate
15-45 minutes depending on use case complexity
Steps
Common Pitfalls
✓ Do
✗ Don't
💡 Pro Tips
✓ Use when
Use when skill capabilities match your task, clear ROI on time saved, and you can validate outputs. Best for repetitive tasks, learning, and quality improvement.
✗ Avoid when
Avoid when task requires deep expertise you can't validate, involves sensitive decisions, or when learning process is more valuable than speed of completion.
mantis-patch is among the better-maintained entries we tried; worth keeping pinned for repeat workflows.
mantis-patch is among the better-maintained entries we tried; worth keeping pinned for repeat workflows.
Useful defaults in mantis-patch — fewer surprises than typical one-off scripts, and it plays nicely with `npx skills` flows.
Solid pick for teams standardizing on skills: mantis-patch is focused, and the summary matches what you get after install.
mantis-patch has been reliable in day-to-day use. Documentation quality is above average for community skills.
mantis-patch has been reliable in day-to-day use. Documentation quality is above average for community skills.
Keeps context tight: mantis-patch is the kind of skill you can hand to a new teammate without a long onboarding doc.
mantis-patch is among the better-maintained entries we tried; worth keeping pinned for repeat workflows.
Keeps context tight: mantis-patch is the kind of skill you can hand to a new teammate without a long onboarding doc.
Keeps context tight: mantis-patch is the kind of skill you can hand to a new teammate without a long onboarding doc.
showing 1-10 of 75