[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M71K52M1RXBHYG4D46PPZSC3":3,"skill-same:01M71K52M1RXBHYG4D46PPZSC3":65},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":39,"linkOnly":40,"markdownContent":41,"markdownBody":42,"frontMatter":43,"refName":44,"commitSha":45,"skillDirectory":46,"forksCount":47,"repositoryHtmlUrl":48,"repositoryHomepageUrl":6,"ownerHtmlUrl":49,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":50,"install":51,"resources":64},"01M71K52M1RXBHYG4D46PPZSC3","escalate-recurrence",null,"Triggered when Claude detects the same mistake ≥2× in one session, or the user says \"опять \u002F again \u002F second time \u002F already said\". Interactively codifies the pattern into a rule + hook + wiki entry via option-picker questions. Pure-click flow — no free-text decisions. Writes rule file, generates hook scaffold at user-chosen severity, registers hook in settings.json via update-config. See ~\u002F.claude\u002Frules\u002Frecurrence-escalate.md.","KeiSeiLab\u002FKeiSeiKit","KeiSeiLab","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F283315582?v=4","01M71K2EW81JRFHSGF0T844B32","KeiSei Lab","01M71K2EWXTB52KWC65E55S6M2",7,"Apache-2.0","https:\u002F\u002Fgithub.com\u002FKeiSeiLab\u002FKeiSeiKit\u002Fblob\u002Fmain\u002Fskills\u002Fescalate-recurrence\u002FSKILL.md",[],[19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38],"escalate","escalate recurrence","Rules","session","second","severity","hook","flow","pattern","config","at","update","text","when","free","wiki","settings.json","option","time","click","2026-11-10 10:12:30",false,"---\nname: escalate-recurrence\ndescription: Triggered when Claude detects the same mistake ≥2× in one session, or the user says \"опять \u002F again \u002F second time \u002F already said\". Interactively codifies the pattern into a rule + hook + wiki entry via option-picker questions. Pure-click flow — no free-text decisions. Writes rule file, generates hook scaffold at user-chosen severity, registers hook in settings.json via update-config. See ~\u002F.claude\u002Frules\u002Frecurrence-escalate.md.\n---\n\n# Escalate Recurrence — Interactive Codifier\n\nYou are converting an observed repeating mistake into a permanent guardrail: a rule file, a wiki entry, and (optionally) an enforcement hook. The entire decision chain is AskUserQuestion — the user clicks, you generate.\n\n---\n\n## Phase 0 — Sanity check (do this BEFORE asking anything)\n\n1. State in ONE paragraph what you observed:\n   - The mistake pattern (abstract, not specific instance)\n   - Two or more concrete instances with file:line or tool-call evidence\n   - Your root-cause hypothesis\n2. Grep existing rules for coverage:\n   ```bash\n   grep -rinE \"\u003C3-5 distinctive keywords from the pattern>\" ~\u002F.claude\u002Frules\u002F 2>\u002Fdev\u002Fnull | head -10\n   ```\n3. If an existing rule ALREADY covers the pattern → offer `(A) extend that rule \u002F (B) new sibling rule \u002F (C) cancel` via AskUserQuestion and branch. Do NOT duplicate rules.\n\n---\n\n## Phase 1 — Pure-click decisions (AskUserQuestion, SINGLE call)\n\nEmit all four questions in one `AskUserQuestion` invocation. Use `multiSelect: false`.\n\n```json\n{\n  \"questions\": [\n    {\n      \"question\": \"Codify this pattern as a rule?\",\n      \"header\": \"Rule\",\n      \"multiSelect\": false,\n      \"options\": [\n        {\"label\": \"Yes — write rule file\",   \"description\": \"New file at ~\u002F.claude\u002Frules\u002F\u003Ctopic>.md\"},\n        {\"label\": \"Extend existing rule\",    \"description\": \"Append section to the closest matching rule\"},\n        {\"label\": \"No — session-only\",       \"description\": \"Note in chat, don't persist\"},\n        {\"label\": \"Later — remind me\",       \"description\": \"Skip now, flag in recurrence-log for next session\"}\n      ]\n    },\n    {\n      \"question\": \"Wikify (add to indices)?\",\n      \"header\": \"Wiki\",\n      \"multiSelect\": false,\n      \"options\": [\n        {\"label\": \"Yes — full (RULES.md + MEMORY.md + CLAUDE.md Rules Index)\", \"description\": \"Discoverable from all three entry points\"},\n        {\"label\": \"Partial — RULES.md only\", \"description\": \"Registry entry only, no MEMORY.md pointer\"},\n        {\"label\": \"No\",                       \"description\": \"Rule file exists but not indexed\"}\n      ]\n    },\n    {\n      \"question\": \"Create enforcement hook?\",\n      \"header\": \"Hook severity\",\n      \"multiSelect\": false,\n      \"options\": [\n        {\"label\": \"block (exit 2)\",               \"description\": \"Hard deny. Reserve for data-loss \u002F secret \u002F IP patterns.\"},\n        {\"label\": \"enforce (exit 1)\",             \"description\": \"Error — Claude must fix before retry\"},\n        {\"label\": \"warn (exit 0 + stderr)\",       \"description\": \"Advisory; tool call proceeds. Safest first step.\"},\n        {\"label\": \"remind (UserPromptSubmit)\",    \"description\": \"Passive reminder on every user turn\"},\n        {\"label\": \"No hook\",                      \"description\": \"Rule only, no automation\"}\n      ]\n    },\n    {\n      \"question\": \"Hook event type?\",\n      \"header\": \"Hook event\",\n      \"multiSelect\": false,\n      \"options\": [\n        {\"label\": \"PreToolUse:Bash\",           \"description\": \"Gate on shell commands — cmd-string pattern match\"},\n        {\"label\": \"PreToolUse:Edit|Write\",     \"description\": \"Gate on file modifications — path \u002F content pattern match\"},\n        {\"label\": \"PostToolUse:*\",             \"description\": \"React AFTER a tool call (e.g. auto-rebuild, auto-log)\"},\n        {\"label\": \"UserPromptSubmit\",          \"description\": \"Runs on every user turn — for remind-level hooks\"},\n        {\"label\": \"Stop\",                      \"description\": \"Runs when Claude finishes — for end-of-turn reminders\"},\n        {\"label\": \"N\u002FA — no hook chosen\",      \"description\": \"If previous answer was 'No hook'\"}\n      ]\n    }\n  ]\n}\n```\n\nStore as `R`, `W`, `S`, `E` (rule \u002F wiki \u002F severity \u002F event).\n\nIf `S == \"No hook\"` and `E != \"N\u002FA — no hook chosen\"` → re-ask just the event question with a reminder. Never silently fix user inconsistency.\n\n---\n\n## Phase 2 — Generate artefacts (in memory — do NOT Write yet)\n\nCompose all files the user will see in the diff preview:\n\n### 2.1 — Rule file (if `R` is Yes or Extend)\n\nPath: `~\u002F.claude\u002Frules\u002F\u003Cslug>.md` (slug = kebab-case short pattern name, 2–4 words).\n\nTemplate:\n```markdown\n# RULE — \u003CHuman Pattern Name> (YYYY-MM-DD ADDED)\n\n> \u003Cone-sentence pattern description>.\n\n## Incident\n\n\u003CThe recurrence evidence: 2+ concrete instances with file:line or tool-call refs.>\n\n## The Rule\n\n\u003CActionable rule, imperative voice.>\n\n## Triggers\n\n- \u003CSpecific detectable phrase \u002F pattern 1>\n- \u003CSpecific detectable phrase \u002F pattern 2>\n\n## Enforcement\n\n- Hook: `~\u002F.claude\u002Fhooks\u002F\u003Cslug>-guard.sh` (\u003Cevent>, severity \u003CS>)\n- Bypass: \u003Cbypass env var name, if applicable>\n\n## Why this and not \"remember to check\"\n\n\u003COne sentence on why a hook beats memory for this pattern.>\n\n## Rule lock\n\nYYYY-MM-DD. Never override without explicit user revocation.\n```\n\nFill every `\u003C...>` placeholder from Phase 0 + Phase 1 answers. Literal `{{placeholder}}` is forbidden — the assembler `validator.rs` rejects it.\n\n### 2.2 — Hook scaffold (if `S != \"No hook\"`)\n\nPath: `~\u002F.claude\u002Fhooks\u002F\u003Cslug>-guard.sh`.\n\n**Template per event type:**\n\n`PreToolUse:Bash`:\n```bash\n#!\u002Fbin\u002Fsh\n# \u003Cslug>-guard — \u003Cone-line purpose>\n# Severity: \u003CS>; Event: PreToolUse:Bash\n# Rule: ~\u002F.claude\u002Frules\u002F\u003Cslug>.md\n\ncommand -v jq >\u002Fdev\u002Fnull 2>&1 || exit 0\nset -eu\n\nCMD=$(jq -r '.tool_input.command \u002F\u002F empty')\n[ -n \"$CMD\" ] || exit 0\n\n# Trigger pattern — tighten during dogfooding\ncase \"$CMD\" in\n  *\u003Cpattern-literal>*)\n    echo \"[\u003Cslug>] \u003Creminder text>. See ~\u002F.claude\u002Frules\u002F\u003Cslug>.md\" >&2\n    exit \u003Cexit-code-from-severity>\n    ;;\nesac\nexit 0\n```\n\n`PreToolUse:Edit|Write`:\n```bash\n#!\u002Fbin\u002Fsh\ncommand -v jq >\u002Fdev\u002Fnull 2>&1 || exit 0\nset -eu\n\nFILE=$(jq -r '.tool_input.file_path \u002F\u002F empty')\nCONTENT=$(jq -r '.tool_input.content \u002F\u002F .tool_input.new_string \u002F\u002F empty')\n[ -n \"$FILE\" ] || exit 0\n\ncase \"$FILE\" in\n  *\u003Cpath-pattern>*)\n    printf '%s' \"$CONTENT\" | grep -qE '\u003Ccontent-pattern>' || exit 0\n    echo \"[\u003Cslug>] \u003Creminder>\" >&2\n    exit \u003Cexit-code>\n    ;;\nesac\nexit 0\n```\n\n`UserPromptSubmit`:\n```bash\n#!\u002Fbin\u002Fsh\ncommand -v jq >\u002Fdev\u002Fnull 2>&1 || exit 0\nPROMPT=$(jq -r '.prompt \u002F\u002F empty')\ncase \"$PROMPT\" in\n  *\u003Ctrigger-phrase>*)\n    echo \"[\u003Cslug>] reminder: \u003Ctext>. See ~\u002F.claude\u002Frules\u002F\u003Cslug>.md\" >&2\n    ;;\nesac\nexit 0\n```\n\n**Exit code → severity map:**\n- block → `exit 2`\n- enforce → `exit 1`\n- warn → `exit 0` (but still echo to stderr)\n- remind → `exit 0` (UserPromptSubmit only — echo to stderr)\n\nReplace every `\u003C...>` with the pattern-specific literal extracted from the Phase 0 evidence. Narrow match preferred over broad match — false-positive fatigue kills a hook faster than any bug.\n\n### 2.3 — Wikification diffs (if `W != No`)\n\nCompute the diff lines to add:\n\n**`~\u002F.claude\u002Frules\u002FRULES.md`** (append to table body, keep alphabetical order if easy; otherwise end):\n```\n| \u003Cslug>.md | \u003Cone-line coverage> | Rules Index (added YYYY-MM-DD) | ~\u002F.claude\u002Fhooks\u002F\u003Cslug>-guard.sh |\n```\n\n**`~\u002F.claude\u002Fmemory\u002FMEMORY.md`** (one-liner under `## Rules & Feedback`):\n```\n- [[..\u002F..\u002F..\u002F..\u002Frules\u002F\u003Cslug>]] — \u003Cone-line coverage>\n```\n\n**`~\u002F.claude\u002FCLAUDE.md` Rules Index table** (if `W == \"Yes — full\"`):\n```\n| \u003Cshort topic> | [[\u003Cslug>]] | \u003Cone-line covers> |\n```\n\n### 2.4 — Settings registration (if `S != \"No hook\"`)\n\nCompute the JSON hook entry:\n```json\n{\n  \"matcher\": \"\u003Cevent matcher>\",\n  \"hooks\": [\n    {\n      \"type\": \"command\",\n      \"command\": \"~\u002F.claude\u002Fhooks\u002F\u003Cslug>-guard.sh\",\n      \"statusMessage\": \"\u003Cslug> \u003Cseverity> check...\"\n    }\n  ]\n}\n```\n\nThis gets merged into `~\u002F.claude\u002Fsettings.json` under `hooks.PreToolUse` \u002F `hooks.UserPromptSubmit` \u002F etc.\n\n---\n\n## Phase 3 — Confirm via diff preview (AskUserQuestion — keep it click-only)\n\nShow all generated artefacts inline in ONE message, THEN emit a single `AskUserQuestion`:\n\n```\n=== GENERATED — REVIEW BEFORE WRITE ===\n\n1. New rule: ~\u002F.claude\u002Frules\u002F\u003Cslug>.md\n\u003Cfull content, 30–80 lines>\n\n2. New hook: ~\u002F.claude\u002Fhooks\u002F\u003Cslug>-guard.sh   (severity: \u003CS>, event: \u003CE>)\n\u003Cfull content, 15–30 lines>\n\n3. RULES.md append:\n\u003Cone row>\n\n4. MEMORY.md append:\n\u003Cone line>\n\n5. settings.json merge (PreToolUse \u002F UserPromptSubmit \u002F etc):\n\u003Cjson block>\n```\n\nThen:\n\n```json\n{\n  \"questions\": [\n    {\n      \"question\": \"Write these artefacts + register hook?\",\n      \"header\": \"Confirm\",\n      \"multiSelect\": false,\n      \"options\": [\n        {\"label\": \"Confirm — write all\",   \"description\": \"Phase 4 runs: files written, hook registered via update-config\"},\n        {\"label\": \"Edit rule (1)\",         \"description\": \"Regenerate the rule file with changes you specify\"},\n        {\"label\": \"Edit hook (2)\",         \"description\": \"Regenerate the hook scaffold with changes you specify\"},\n        {\"label\": \"Edit wiki diffs (3-4)\", \"description\": \"Regenerate RULES.md \u002F MEMORY.md entries\"},\n        {\"label\": \"Edit settings (5)\",     \"description\": \"Regenerate the settings.json merge block\"},\n        {\"label\": \"Abort\",                 \"description\": \"Stop — nothing gets written, no files touched\"}\n      ]\n    }\n  ]\n}\n```\n\nOn `Confirm` → Phase 4. On any `Edit \u003CN>` → ask ONE free-text line for what to change in that artefact (unavoidable — arbitrary content edit), regenerate, re-preview. On `Abort` → stop, write nothing, do NOT touch `~\u002F.claude\u002F`.\n\n---\n\n## Phase 4 — Write + register (on confirm only)\n\nExecute in order (each via its right tool — do NOT shell out when a tool exists):\n\n1. `Write` → `~\u002F.claude\u002Frules\u002F\u003Cslug>.md`\n2. If hook: `Write` → `~\u002F.claude\u002Fhooks\u002F\u003Cslug>-guard.sh`, then `Bash` → `chmod +x ~\u002F.claude\u002Fhooks\u002F\u003Cslug>-guard.sh`\n3. `Edit` → `~\u002F.claude\u002Frules\u002FRULES.md` (append the row)\n4. `Edit` → `~\u002F.claude\u002Fmemory\u002FMEMORY.md` (append the line)\n5. `Edit` → `~\u002F.claude\u002FCLAUDE.md` (add Rules Index row) — only if `W == \"Yes — full\"`\n6. If hook: invoke the `update-config` skill with the settings-merge spec. Do NOT directly hand-edit `settings.json` — the skill knows how to merge without clobbering foreign entries.\n7. `Edit` → append one line to `~\u002F.claude\u002Fmemory\u002Frecurrence-log.md` (create if absent):\n   ```\n   YYYY-MM-DD | \u003Cslug> | severity=\u003CS> | event=\u003CE> | pattern=\"\u003Cone-line>\" | instances=\u003CN>\n   ```\n\n---\n\n## Phase 5 — Report\n\n```\n✓ Rule codified:      ~\u002F.claude\u002Frules\u002F\u003Cslug>.md\n✓ Hook registered:    ~\u002F.claude\u002Fhooks\u002F\u003Cslug>-guard.sh   (severity \u003CS>, event \u003CE>)\n✓ Wikified:           RULES.md, MEMORY.md\u003C, CLAUDE.md if full>\n✓ Log entry:          ~\u002F.claude\u002Fmemory\u002Frecurrence-log.md\n\nNext time this pattern triggers, the hook \u003Cblocks | errors | warns | reminds>.\nTo upgrade severity: invoke \u002Fescalate-recurrence again on the same pattern.\nTo disable: remove the entry from settings.json (or set \"enabled\": false).\n```\n\n---\n\n## Rules (apply throughout)\n\n- **Pure click wherever possible.** Only slug and pattern-literal require typing. Everything structural is AskUserQuestion.\n- **Narrow match preferred.** A hook with false-positives gets ignored, then removed. Start narrow, widen on next recurrence.\n- **Start at lowest severity that solves the pain.** Upgrade on re-trigger, never auto-promote.\n- **Never write `{{placeholder}}` literals.** The assembler `validator.rs` rejects them; same hygiene applies here.\n- **No Patching.** A new rule codifies a pattern, it doesn't paper over an existing rule's gap. If the gap is in an existing rule → extend that rule (Phase 1 option \"Extend existing\").\n- **Escape hatch.** Every hook MUST document its bypass mechanism (env var like `\u003CSLUG>_BYPASS=1` or marker string). Without escape, emergency work stalls.\n","# Escalate Recurrence — Interactive Codifier\n\nYou are converting an observed repeating mistake into a permanent guardrail: a rule file, a wiki entry, and (optionally) an enforcement hook. The entire decision chain is AskUserQuestion — the user clicks, you generate.\n\n---\n\n## Phase 0 — Sanity check (do this BEFORE asking anything)\n\n1. State in ONE paragraph what you observed:\n   - The mistake pattern (abstract, not specific instance)\n   - Two or more concrete instances with file:line or tool-call evidence\n   - Your root-cause hypothesis\n2. Grep existing rules for coverage:\n   ```bash\n   grep -rinE \"\u003C3-5 distinctive keywords from the pattern>\" ~\u002F.claude\u002Frules\u002F 2>\u002Fdev\u002Fnull | head -10\n   ```\n3. If an existing rule ALREADY covers the pattern → offer `(A) extend that rule \u002F (B) new sibling rule \u002F (C) cancel` via AskUserQuestion and branch. Do NOT duplicate rules.\n\n---\n\n## Phase 1 — Pure-click decisions (AskUserQuestion, SINGLE call)\n\nEmit all four questions in one `AskUserQuestion` invocation. Use `multiSelect: false`.\n\n```json\n{\n  \"questions\": [\n    {\n      \"question\": \"Codify this pattern as a rule?\",\n      \"header\": \"Rule\",\n      \"multiSelect\": false,\n      \"options\": [\n        {\"label\": \"Yes — write rule file\",   \"description\": \"New file at ~\u002F.claude\u002Frules\u002F\u003Ctopic>.md\"},\n        {\"label\": \"Extend existing rule\",    \"description\": \"Append section to the closest matching rule\"},\n        {\"label\": \"No — session-only\",       \"description\": \"Note in chat, don't persist\"},\n        {\"label\": \"Later — remind me\",       \"description\": \"Skip now, flag in recurrence-log for next session\"}\n      ]\n    },\n    {\n      \"question\": \"Wikify (add to indices)?\",\n      \"header\": \"Wiki\",\n      \"multiSelect\": false,\n      \"options\": [\n        {\"label\": \"Yes — full (RULES.md + MEMORY.md + CLAUDE.md Rules Index)\", \"description\": \"Discoverable from all three entry points\"},\n        {\"label\": \"Partial — RULES.md only\", \"description\": \"Registry entry only, no MEMORY.md pointer\"},\n        {\"label\": \"No\",                       \"description\": \"Rule file exists but not indexed\"}\n      ]\n    },\n    {\n      \"question\": \"Create enforcement hook?\",\n      \"header\": \"Hook severity\",\n      \"multiSelect\": false,\n      \"options\": [\n        {\"label\": \"block (exit 2)\",               \"description\": \"Hard deny. Reserve for data-loss \u002F secret \u002F IP patterns.\"},\n        {\"label\": \"enforce (exit 1)\",             \"description\": \"Error — Claude must fix before retry\"},\n        {\"label\": \"warn (exit 0 + stderr)\",       \"description\": \"Advisory; tool call proceeds. Safest first step.\"},\n        {\"label\": \"remind (UserPromptSubmit)\",    \"description\": \"Passive reminder on every user turn\"},\n        {\"label\": \"No hook\",                      \"description\": \"Rule only, no automation\"}\n      ]\n    },\n    {\n      \"question\": \"Hook event type?\",\n      \"header\": \"Hook event\",\n      \"multiSelect\": false,\n      \"options\": [\n        {\"label\": \"PreToolUse:Bash\",           \"description\": \"Gate on shell commands — cmd-string pattern match\"},\n        {\"label\": \"PreToolUse:Edit|Write\",     \"description\": \"Gate on file modifications — path \u002F content pattern match\"},\n        {\"label\": \"PostToolUse:*\",             \"description\": \"React AFTER a tool call (e.g. auto-rebuild, auto-log)\"},\n        {\"label\": \"UserPromptSubmit\",          \"description\": \"Runs on every user turn — for remind-level hooks\"},\n        {\"label\": \"Stop\",                      \"description\": \"Runs when Claude finishes — for end-of-turn reminders\"},\n        {\"label\": \"N\u002FA — no hook chosen\",      \"description\": \"If previous answer was 'No hook'\"}\n      ]\n    }\n  ]\n}\n```\n\nStore as `R`, `W`, `S`, `E` (rule \u002F wiki \u002F severity \u002F event).\n\nIf `S == \"No hook\"` and `E != \"N\u002FA — no hook chosen\"` → re-ask just the event question with a reminder. Never silently fix user inconsistency.\n\n---\n\n## Phase 2 — Generate artefacts (in memory — do NOT Write yet)\n\nCompose all files the user will see in the diff preview:\n\n### 2.1 — Rule file (if `R` is Yes or Extend)\n\nPath: `~\u002F.claude\u002Frules\u002F\u003Cslug>.md` (slug = kebab-case short pattern name, 2–4 words).\n\nTemplate:\n```markdown\n# RULE — \u003CHuman Pattern Name> (YYYY-MM-DD ADDED)\n\n> \u003Cone-sentence pattern description>.\n\n## Incident\n\n\u003CThe recurrence evidence: 2+ concrete instances with file:line or tool-call refs.>\n\n## The Rule\n\n\u003CActionable rule, imperative voice.>\n\n## Triggers\n\n- \u003CSpecific detectable phrase \u002F pattern 1>\n- \u003CSpecific detectable phrase \u002F pattern 2>\n\n## Enforcement\n\n- Hook: `~\u002F.claude\u002Fhooks\u002F\u003Cslug>-guard.sh` (\u003Cevent>, severity \u003CS>)\n- Bypass: \u003Cbypass env var name, if applicable>\n\n## Why this and not \"remember to check\"\n\n\u003COne sentence on why a hook beats memory for this pattern.>\n\n## Rule lock\n\nYYYY-MM-DD. Never override without explicit user revocation.\n```\n\nFill every `\u003C...>` placeholder from Phase 0 + Phase 1 answers. Literal `{{placeholder}}` is forbidden — the assembler `validator.rs` rejects it.\n\n### 2.2 — Hook scaffold (if `S != \"No hook\"`)\n\nPath: `~\u002F.claude\u002Fhooks\u002F\u003Cslug>-guard.sh`.\n\n**Template per event type:**\n\n`PreToolUse:Bash`:\n```bash\n#!\u002Fbin\u002Fsh\n# \u003Cslug>-guard — \u003Cone-line purpose>\n# Severity: \u003CS>; Event: PreToolUse:Bash\n# Rule: ~\u002F.claude\u002Frules\u002F\u003Cslug>.md\n\ncommand -v jq >\u002Fdev\u002Fnull 2>&1 || exit 0\nset -eu\n\nCMD=$(jq -r '.tool_input.command \u002F\u002F empty')\n[ -n \"$CMD\" ] || exit 0\n\n# Trigger pattern — tighten during dogfooding\ncase \"$CMD\" in\n  *\u003Cpattern-literal>*)\n    echo \"[\u003Cslug>] \u003Creminder text>. See ~\u002F.claude\u002Frules\u002F\u003Cslug>.md\" >&2\n    exit \u003Cexit-code-from-severity>\n    ;;\nesac\nexit 0\n```\n\n`PreToolUse:Edit|Write`:\n```bash\n#!\u002Fbin\u002Fsh\ncommand -v jq >\u002Fdev\u002Fnull 2>&1 || exit 0\nset -eu\n\nFILE=$(jq -r '.tool_input.file_path \u002F\u002F empty')\nCONTENT=$(jq -r '.tool_input.content \u002F\u002F .tool_input.new_string \u002F\u002F empty')\n[ -n \"$FILE\" ] || exit 0\n\ncase \"$FILE\" in\n  *\u003Cpath-pattern>*)\n    printf '%s' \"$CONTENT\" | grep -qE '\u003Ccontent-pattern>' || exit 0\n    echo \"[\u003Cslug>] \u003Creminder>\" >&2\n    exit \u003Cexit-code>\n    ;;\nesac\nexit 0\n```\n\n`UserPromptSubmit`:\n```bash\n#!\u002Fbin\u002Fsh\ncommand -v jq >\u002Fdev\u002Fnull 2>&1 || exit 0\nPROMPT=$(jq -r '.prompt \u002F\u002F empty')\ncase \"$PROMPT\" in\n  *\u003Ctrigger-phrase>*)\n    echo \"[\u003Cslug>] reminder: \u003Ctext>. See ~\u002F.claude\u002Frules\u002F\u003Cslug>.md\" >&2\n    ;;\nesac\nexit 0\n```\n\n**Exit code → severity map:**\n- block → `exit 2`\n- enforce → `exit 1`\n- warn → `exit 0` (but still echo to stderr)\n- remind → `exit 0` (UserPromptSubmit only — echo to stderr)\n\nReplace every `\u003C...>` with the pattern-specific literal extracted from the Phase 0 evidence. Narrow match preferred over broad match — false-positive fatigue kills a hook faster than any bug.\n\n### 2.3 — Wikification diffs (if `W != No`)\n\nCompute the diff lines to add:\n\n**`~\u002F.claude\u002Frules\u002FRULES.md`** (append to table body, keep alphabetical order if easy; otherwise end):\n```\n| \u003Cslug>.md | \u003Cone-line coverage> | Rules Index (added YYYY-MM-DD) | ~\u002F.claude\u002Fhooks\u002F\u003Cslug>-guard.sh |\n```\n\n**`~\u002F.claude\u002Fmemory\u002FMEMORY.md`** (one-liner under `## Rules & Feedback`):\n```\n- [[..\u002F..\u002F..\u002F..\u002Frules\u002F\u003Cslug>]] — \u003Cone-line coverage>\n```\n\n**`~\u002F.claude\u002FCLAUDE.md` Rules Index table** (if `W == \"Yes — full\"`):\n```\n| \u003Cshort topic> | [[\u003Cslug>]] | \u003Cone-line covers> |\n```\n\n### 2.4 — Settings registration (if `S != \"No hook\"`)\n\nCompute the JSON hook entry:\n```json\n{\n  \"matcher\": \"\u003Cevent matcher>\",\n  \"hooks\": [\n    {\n      \"type\": \"command\",\n      \"command\": \"~\u002F.claude\u002Fhooks\u002F\u003Cslug>-guard.sh\",\n      \"statusMessage\": \"\u003Cslug> \u003Cseverity> check...\"\n    }\n  ]\n}\n```\n\nThis gets merged into `~\u002F.claude\u002Fsettings.json` under `hooks.PreToolUse` \u002F `hooks.UserPromptSubmit` \u002F etc.\n\n---\n\n## Phase 3 — Confirm via diff preview (AskUserQuestion — keep it click-only)\n\nShow all generated artefacts inline in ONE message, THEN emit a single `AskUserQuestion`:\n\n```\n=== GENERATED — REVIEW BEFORE WRITE ===\n\n1. New rule: ~\u002F.claude\u002Frules\u002F\u003Cslug>.md\n\u003Cfull content, 30–80 lines>\n\n2. New hook: ~\u002F.claude\u002Fhooks\u002F\u003Cslug>-guard.sh   (severity: \u003CS>, event: \u003CE>)\n\u003Cfull content, 15–30 lines>\n\n3. RULES.md append:\n\u003Cone row>\n\n4. MEMORY.md append:\n\u003Cone line>\n\n5. settings.json merge (PreToolUse \u002F UserPromptSubmit \u002F etc):\n\u003Cjson block>\n```\n\nThen:\n\n```json\n{\n  \"questions\": [\n    {\n      \"question\": \"Write these artefacts + register hook?\",\n      \"header\": \"Confirm\",\n      \"multiSelect\": false,\n      \"options\": [\n        {\"label\": \"Confirm — write all\",   \"description\": \"Phase 4 runs: files written, hook registered via update-config\"},\n        {\"label\": \"Edit rule (1)\",         \"description\": \"Regenerate the rule file with changes you specify\"},\n        {\"label\": \"Edit hook (2)\",         \"description\": \"Regenerate the hook scaffold with changes you specify\"},\n        {\"label\": \"Edit wiki diffs (3-4)\", \"description\": \"Regenerate RULES.md \u002F MEMORY.md entries\"},\n        {\"label\": \"Edit settings (5)\",     \"description\": \"Regenerate the settings.json merge block\"},\n        {\"label\": \"Abort\",                 \"description\": \"Stop — nothing gets written, no files touched\"}\n      ]\n    }\n  ]\n}\n```\n\nOn `Confirm` → Phase 4. On any `Edit \u003CN>` → ask ONE free-text line for what to change in that artefact (unavoidable — arbitrary content edit), regenerate, re-preview. On `Abort` → stop, write nothing, do NOT touch `~\u002F.claude\u002F`.\n\n---\n\n## Phase 4 — Write + register (on confirm only)\n\nExecute in order (each via its right tool — do NOT shell out when a tool exists):\n\n1. `Write` → `~\u002F.claude\u002Frules\u002F\u003Cslug>.md`\n2. If hook: `Write` → `~\u002F.claude\u002Fhooks\u002F\u003Cslug>-guard.sh`, then `Bash` → `chmod +x ~\u002F.claude\u002Fhooks\u002F\u003Cslug>-guard.sh`\n3. `Edit` → `~\u002F.claude\u002Frules\u002FRULES.md` (append the row)\n4. `Edit` → `~\u002F.claude\u002Fmemory\u002FMEMORY.md` (append the line)\n5. `Edit` → `~\u002F.claude\u002FCLAUDE.md` (add Rules Index row) — only if `W == \"Yes — full\"`\n6. If hook: invoke the `update-config` skill with the settings-merge spec. Do NOT directly hand-edit `settings.json` — the skill knows how to merge without clobbering foreign entries.\n7. `Edit` → append one line to `~\u002F.claude\u002Fmemory\u002Frecurrence-log.md` (create if absent):\n   ```\n   YYYY-MM-DD | \u003Cslug> | severity=\u003CS> | event=\u003CE> | pattern=\"\u003Cone-line>\" | instances=\u003CN>\n   ```\n\n---\n\n## Phase 5 — Report\n\n```\n✓ Rule codified:      ~\u002F.claude\u002Frules\u002F\u003Cslug>.md\n✓ Hook registered:    ~\u002F.claude\u002Fhooks\u002F\u003Cslug>-guard.sh   (severity \u003CS>, event \u003CE>)\n✓ Wikified:           RULES.md, MEMORY.md\u003C, CLAUDE.md if full>\n✓ Log entry:          ~\u002F.claude\u002Fmemory\u002Frecurrence-log.md\n\nNext time this pattern triggers, the hook \u003Cblocks | errors | warns | reminds>.\nTo upgrade severity: invoke \u002Fescalate-recurrence again on the same pattern.\nTo disable: remove the entry from settings.json (or set \"enabled\": false).\n```\n\n---\n\n## Rules (apply throughout)\n\n- **Pure click wherever possible.** Only slug and pattern-literal require typing. Everything structural is AskUserQuestion.\n- **Narrow match preferred.** A hook with false-positives gets ignored, then removed. Start narrow, widen on next recurrence.\n- **Start at lowest severity that solves the pain.** Upgrade on re-trigger, never auto-promote.\n- **Never write `{{placeholder}}` literals.** The assembler `validator.rs` rejects them; same hygiene applies here.\n- **No Patching.** A new rule codifies a pattern, it doesn't paper over an existing rule's gap. If the gap is in an existing rule → extend that rule (Phase 1 option \"Extend existing\").\n- **Escape hatch.** Every hook MUST document its bypass mechanism (env var like `\u003CSLUG>_BYPASS=1` or marker string). Without escape, emergency work stalls.\n",{"name":5,"description":7},"main","32e85218a997294f68da27ff3dfd638196186ae5","skills\u002Fescalate-recurrence",8,"https:\u002F\u002Fgithub.com\u002FKeiSeiLab\u002FKeiSeiKit","https:\u002F\u002Fgithub.com\u002FKeiSeiLab","2026-10-11 11:17:46",{"source":8,"skillName":5,"commands":52,"prompt":62,"zipAvailable":63},[53,56,59],{"tool":54,"command":55},"npx","npx skills add KeiSeiLab\u002FKeiSeiKit --skill escalate-recurrence",{"tool":57,"command":58},"bunx","bunx skills add KeiSeiLab\u002FKeiSeiKit --skill escalate-recurrence",{"tool":60,"command":61},"pnpm","pnpm dlx skills add KeiSeiLab\u002FKeiSeiKit --skill escalate-recurrence","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FKeiSeiLab\u002FKeiSeiKit\u002Fblob\u002Fmain\u002Fskills\u002Fescalate-recurrence\u002FSKILL.md",true,[],[66,92,116,143,168,190],{"skillNo":67,"name":68,"nameZh":6,"description":69,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":70,"categories":71,"keywords":72,"publishedAt":39},"01M71K887N78V089XR5BWT0JAV","wave-audit","3-wave parallel audit — Wave 1 discovery (4 agents), Wave 2 verification (4 agents), Wave 3 cross-optimization (1 synthesizer). Each wave runs agents in parallel. Combines security review, runtime analysis, quality check, and constructor pattern into one unified workflow with evidence grading and Go\u002FNo-Go verdict.","https:\u002F\u002Fgithub.com\u002FKeiSeiLab\u002FKeiSeiKit\u002Fblob\u002Fmain\u002Fskills\u002Fwave-audit\u002FSKILL.md",[],[73,74,75,76,77,78,79,80,27,81,82,83,84,85,86,87,88,89,90,91],"wave audit","audit","unified workflow","workflow","analysis","review","verification","security review","grading","go","security","parallel","evidence","runtime","quality check","discovery","Optimization","one","check",{"skillNo":93,"name":94,"nameZh":6,"description":95,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":96,"categories":97,"keywords":98,"publishedAt":39},"01M71K85100JQS4Y10EGCTWQXW","vm-provision","End-to-end VPS provisioning — select provider → plan → provision → harden → verify (ssh-check + firewall-diff hard-gate) → handoff. 6 phases, ≥6 AskUserQuestion calls, defensive-only. Stops if either verification primitive fails.","https:\u002F\u002Fgithub.com\u002FKeiSeiLab\u002FKeiSeiKit\u002Fblob\u002Fmain\u002Fskills\u002Fvm-provision\u002FSKILL.md",[],[99,100,101,102,103,104,105,106,107,108,90,109,110,91,79,111,112,113,114,115],"vm","vm provision","firewall","diff","provider","select","end","calls","only","either","api","hetzner","plan","defensive","verify","intent","line",{"skillNo":117,"name":118,"nameZh":6,"description":119,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":120,"licenseFileUrl":6,"sourceHtmlUrl":121,"categories":122,"keywords":123,"publishedAt":39},"01M71K80ZRH2H5ES83QS97BB91","visual-explainer","Generate beautiful, self-contained HTML pages that visually explain systems, code changes, plans, and data. Use when the user asks for a diagram, architecture overview, diff review, plan review, project recap, comparison table, or any visual explanation of technical concepts. Also use proactively when you are about to render a complex ASCII table (4+ rows or 3+ columns) — present it as a styled HTML page instead.","MIT","https:\u002F\u002Fgithub.com\u002FKeiSeiLab\u002FKeiSeiKit\u002Fblob\u002Fmain\u002Fskills\u002Fvisual-explainer\u002FSKILL.md",[],[124,125,126,127,128,129,130,131,111,132,133,134,135,136,137,138,139,140,141,142],"visual","visual explainer","explainer","project","files","image","you","architecture","generate","present","concepts","table","as","view","for","ascii table","ascii","surf","use",{"skillNo":144,"name":145,"nameZh":6,"description":146,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":147,"categories":148,"keywords":149,"publishedAt":39},"01M71K7VSD5ZWN26QJEC4T0770","video-gen","Use when generating video from frame sequences — FFmpeg extraction, WebP\u002FAVIF conversion, sprite sheets, scroll-synced playback, video encoding\u002Ftranscoding. Covers the full pipeline from video source to web-ready frame sequence or optimized video.","https:\u002F\u002Fgithub.com\u002FKeiSeiLab\u002FKeiSeiKit\u002Fblob\u002Fmain\u002Fskills\u002Fvideo-gen\u002FSKILL.md",[],[150,151,152,153,154,155,156,157,158,32,129,159,160,161,162,163,164,165,166,167],"Video","gen","video gen","ready","pipeline","default","generated","synced","false","conversion","directory","sequences","sequence","source","full","path","webp","target",{"skillNo":169,"name":170,"nameZh":6,"description":171,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":172,"categories":173,"keywords":174,"publishedAt":39},"01M71K7R88RM8ENVCRZHZSMM5T","test-matrix","Use when a project needs testing BEYOND unit tests — fuzzing, property-based, load, E2E, or mutation. Five-phase hub-and-spoke pipeline composes the right mix per language × critical path × CI target, scaffolds configs + corpus + fixtures, wires CI jobs, and defines the crash\u002Fregression triage workflow. Pure-click: every decision except intake is an AskUserQuestion.","https:\u002F\u002Fgithub.com\u002FKeiSeiLab\u002FKeiSeiKit\u002Fblob\u002Fmain\u002Fskills\u002Ftest-matrix\u002FSKILL.md",[],[175,176,177,178,167,38,127,179,154,180,181,182,183,184,185,186,187,142,188,189],"test","matrix","test matrix","unit","regression","mix","intake","testing","decision","ci","tests","e2e","mutation","load","fuzzing",{"skillNo":191,"name":192,"nameZh":6,"description":193,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":194,"categories":195,"keywords":196,"publishedAt":39},"01M71K7N3ZY9FMMH3CSE1H8K5J","test-gen","Use when generating tests for untested code — happy path, edge cases, error handling","https:\u002F\u002Fgithub.com\u002FKeiSeiLab\u002FKeiSeiKit\u002Fblob\u002Fmain\u002Fskills\u002Ftest-gen\u002FSKILL.md",[],[197,151,175,198,167,138,199,185,200,142,32,201,202,203,204,165],"test gen","error","true","edge","file","code","error handling","name"]