mantis-patch
БесплатноБез исполняемых скриптовНе проверенGenerates minimal security fixes using transactional isolation (shadow directories or file backups), applies patches, and verifies them. Use when security…
от google★ 2 881 звезда на GitHubОб этом скилле
Patcher (/mantis-patch)
System Goal
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.
Command Definition
- Command:
/mantis-patch [--target_root=<path>] [--state_root=<path>] [--snapshot_root=<path>] [--snapshot_id=<id>] [--snapshot_pinned=<true|false>] - Description: Generates minimal security fixes using transactional isolation (shadow directories or file backups), applies patches, and verifies them.
- Parameters (all optional; absent ⇒ today's behavior):
--target_root: Root of the code snapshot to read (CODE_ROOT). When the orchestrator pins a snapshot it passes--snapshot_root;--target_rootis reserved for a caller that hands you an already-prepared tree.--snapshot_root: Root of the pinned immutable snapshot for this pass.--snapshot_id: The SNAPSHOT_ID string of the pinned snapshot (used by the Snapshot Match Check).--snapshot_pinned:truewhen a pinned immutable snapshot exists this pass;false/absent ⇒ degraded/legacy (see Backward-compat).--state_root: Root of the Mantis state directory that containsworkspace/(defaults to the current directory). ALLworkspace/...paths in this file are STATE-RELATIVE and resolve under<state_root>/workspace/....
Input/Output Contract
- Reads:
workspace/findings/(reproduced finding JSON files wherepatch_statusis not"VERIFIED_SECURE"or"MITIGATION_PROPOSED").workspace/.mantis_state.json(to track current loop pass).workspace/.mantis_state.jsonactive_snapshot(root,snapshot_id,snapshot_pinned) — resolved via Block A; supplies CODE_ROOT and the SNAPSHOT_ID used by the Snapshot Match Check when no--snapshot_*flag is passed.- Target source code files.
- Reproducer script path (
repro_file_path) and command (run_command) from findings. - Pre-existing backup files matching finding ID (if Option B is used).
- Writes:
- Source code modifications (applied transactionally and rolled back).
- Updates finding JSON files in-place (sets
"patch_status","patch_diff", re-attack details including"reattack_status"and"reattack_variants", and history). - Appends to
workspace/learnings.jsonl. - Reusable helper script
workspace/helpers/append_patch.py.
- Preconditions:
- Findings must exist in
workspace/findings/.
- Findings must exist in
- Idempotency Guarantee:
- Snapshot-aware skip: Skips a finding whose
patch_statusis already"VERIFIED_SECURE"or"MITIGATION_PROPOSED"ONLY when its recordedpatch_base_snapshotequals the current SNAPSHOT_ID (i.e. it was verified against THIS snapshot). Ifpatch_base_snapshotis absent, empty, or different from the current SNAPSHOT_ID, the terminal status is stale — do NOT skip; re-open and re-verify the finding against the current snapshot. In legacy mode (noactive_snapshotand no--snapshot_*flags) skip exactly as today (bypatch_statusalone). - Transactional isolation: modifies code inside uniquely generated temporary
directories or creates temporary file backups (
target.c.bak-[id]), restoring baseline state upon completion (usingtry...finallyrollback mechanisms). - Reuses the existing
append_patch.pyscript once created.
- Snapshot-aware skip: Skips a finding whose
Instructions
Fix successfully reproduced security flaws without breaking standard code behavior.
Execute the patching and verification stage as follows:
Snapshot & Locator Resolution (run once, before touching any code):
0a. Resolve CODE_ROOT, SNAPSHOT_ID, snapshot_pinned, and state_root via Block A (Locator Resolution):
LOCATOR RESOLUTION (before reading ANY target code or artifact): 0. ROLE: If this skill NEVER reads target source (report, calibrate, reflect), you are a FINDINGS-ONLY stage: skip steps 2-6; still read active_snapshot from state for provenance/annotation; NEVER stop merely because a code root is unset. 1. Determine CODE_ROOT, in this priority order: a. If --target_root is passed on THIS invocation, CODE_ROOT = --target_root. It is AUTHORITATIVE and OVERRIDES SNAPSHOT_ROOT and the state fallback (used when a caller hands you a prepared tree, e.g. a patched shadow). b. Else if --snapshot_root (or SNAPSHOT_ROOT) is passed, use it. c. Else read state_root/workspace/.mantis_state.json (state_root from --state_root if passed, else ./workspace/... relative to the current dir) -> active_snapshot.root / .snapshot_id / .snapshot_pinned. d. Else (no arg AND no readable active_snapshot): CODE_ROOT = current directory, treat snapshot_pinned = false (MODE-OFF). Do NOT stop. 2. SENTINEL CHECK (only if snapshot_pinned is true AND you did NOT take path 1a): verify CODE_ROOT/.mant
Установить mantis-patch в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл mantis-patch?
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.
Как установить скилл mantis-patch?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл mantis-patch запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
agent-skill-stack
Find, evaluate, and assemble the smallest compatible set of AI Agent Skills for an end-to-end natural-language goal. Use when a user wants Skills for a…
от GitHubbuild-evidence-map
Build an auditable evidence map for a contested technical choice, research synthesis, proposal review, or consequential decision. Use when Copilot must…
от GitHubpinecone-rag
Build production RAG pipelines and persistent agent memory using Pinecone as the vector database backend. ALWAYS USE THIS SKILL when the user mentions…
от GitHubqdrant-monitoring-debugging
Diagnoses Qdrant production issues using metrics and observability tools. Use when someone reports 'optimizer stuck', 'indexing too slow', 'memory too high'…
от GitHub