[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7F48CD3E1J3M372T1BZYSQJ":3,"skill-same:01M7F48CD3E1J3M372T1BZYSQJ":54},{"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":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":33,"commitSha":34,"skillDirectory":35,"forksCount":36,"repositoryHtmlUrl":37,"repositoryHomepageUrl":6,"ownerHtmlUrl":38,"ownerBlogUrl":6,"ownerDescription":39,"updatedAt":40,"install":41,"resources":53},"01M7F48CD3E1J3M372T1BZYSQJ","safe-mode",null,"Prevent destructive operations using Claude Code hooks. Three modes — cautious (warn on dangerous commands), lockdown (restrict edits to one directory), and clear (remove restrictions). Uses PreToolUse matchers for Bash, Edit, and Write.","lza6\u002FArmor-piercing-system-prompts","lza6","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F128880206?v=4","01M7EB3K7WPX5T28EJ2NVHE6EG","Chinese-tingfeng","01M7EB3K97E1KQ16QWKJMFNGX8",11,"MIT","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F05-技能与代理开发\u002Fsafe-mode\u002FSKILL.md",[],[],"2026-11-16 10:05:34",false,"---\nname: safe-mode\ndescription: Prevent destructive operations using Claude Code hooks. Three modes — cautious (warn on dangerous commands), lockdown (restrict edits to one directory), and clear (remove restrictions). Uses PreToolUse matchers for Bash, Edit, and Write.\nuser-invocable: true\nhooks:\n  PreToolUse:\n    - matcher: \"tool == \\\"Bash\\\"\"\n      description: \"Intercept shell commands and check for destructive operations\"\n    - matcher: \"tool == \\\"Edit\\\" || tool == \\\"Write\\\"\"\n      description: \"Enforce directory lockdown when active\"\n---\n\n# Safe Mode\n\nThree levels of protection against destructive operations during AI coding sessions.\n\n> **Note:** These hooks are skill-scoped — they only activate when you invoke `\u002Fsafe-mode`. The global `permission-request.js` hook in hooks.json provides always-on alerting for dangerous commands. Safe-mode adds opt-in blocking and directory restrictions on top of that.\n\n## Modes\n\n### Cautious Mode\n\n```text\n\u002Fsafe-mode cautious\n```\n\nIntercepts Bash commands before execution. Warns on dangerous patterns but does not block — the user decides.\n\n**Flagged patterns:**\n\n| Pattern | Risk |\n|---------|------|\n| `rm -rf` \u002F `rm -r` | Recursive deletion |\n| `DROP TABLE` \u002F `DROP DATABASE` | SQL data loss |\n| `TRUNCATE` | SQL data destruction |\n| `git push --force` \u002F `git push -f` | Remote history rewrite |\n| `git reset --hard` | Local history loss |\n| `git clean -f` | Untracked file deletion |\n| `git checkout .` \u002F `git restore .` | Discard all changes |\n| `chmod 777` | World-writable permissions |\n| `curl` or `wget` piped to a shell | Piped remote execution |\n| `> \u002Fdev\u002Fsda` \u002F `dd if=` | Disk-level operations |\n| `:(){ :\\|:& };:` | Fork bombs |\n| `sudo rm` | Elevated deletion |\n\n**What happens:**\n\n```text\nWARNING: Destructive operation detected\n  Command: rm -rf .\u002Fbuild\n  Pattern: rm -rf (recursive forced deletion)\n  Risk: Permanently deletes .\u002Fbuild and all contents\n\n  Proceed? The command will execute as-is if you continue.\n```\n\nThe warning goes to stderr. Claude sees it and asks for confirmation before proceeding.\n\n### Lockdown Mode\n\n```text\n\u002Fsafe-mode lockdown \u003Cpath>\n```\n\nRestricts Edit and Write operations to a single directory tree. Prevents accidental changes to unrelated code.\n\n**How it works:**\n\n1. Set the allowed path (absolute or relative to repo root)\n2. Every Edit\u002FWrite call checks if the target file is inside the allowed path\n3. Operations outside the path are blocked with an explanation\n\n```text\nLOCKDOWN ACTIVE: Edits restricted to src\u002Fapi\u002F\n\n  Blocked: Edit to src\u002Futils\u002Fhelpers.ts\n  Reason: File is outside the lockdown path (src\u002Fapi\u002F)\n\n  To edit files outside the lockdown, run: \u002Fsafe-mode clear\n```\n\n**Use cases:**\n\n- Focused refactoring of one module without touching others\n- Bug fix in a specific directory while tests run elsewhere\n- Junior developer guardrail — scope the blast radius\n- Code review session — only edit the files under review\n\n**Scope:** Session-scoped. Resets when the session ends.\n\n### Clear\n\n```text\n\u002Fsafe-mode clear\n```\n\nRemoves all restrictions for the current session. Both cautious warnings and lockdown restrictions are disabled.\n\n```text\nSAFE MODE: All restrictions cleared for this session.\n```\n\n## Implementation\n\n### PreToolUse Hook — Bash (Cautious Mode)\n\nThe hook inspects `tool_input.command` before every Bash execution:\n\n```javascript\nconst DANGEROUS_PATTERNS = [\n  { pattern: \u002F\\brm\\s+(-[a-zA-Z]*[rf][a-zA-Z]*\\s|--recursive|--force)\u002F, label: \"rm with -rf flags\" },\n  { pattern: \u002F\\bDROP\\s+(TABLE|DATABASE|INDEX|VIEW)\\b\u002Fi, label: \"DROP SQL statement\" },\n  { pattern: \u002F\\bTRUNCATE\\b\u002Fi, label: \"TRUNCATE SQL statement\" },\n  { pattern: \u002F\\bgit\\s+push\\s+(-[a-zA-Z]*f|--force)\u002F, label: \"git force-push\" },\n  { pattern: \u002F\\bgit\\s+reset\\s+--hard\\b\u002F, label: \"git hard reset\" },\n  { pattern: \u002F\\bgit\\s+clean\\s+-[a-zA-Z]*f\u002F, label: \"git clean -f\" },\n  { pattern: \u002F\\bgit\\s+(checkout|restore)\\s+\\.\u002F, label: \"git discard all changes\" },\n  { pattern: \u002F\\bchmod\\s+777\\b\u002F, label: \"chmod 777\" },\n  { pattern: \u002F\\bcurl\\b.*\\|\\s*(sh|bash)\\b\u002F, label: \"piped remote execution\" },\n  { pattern: \u002F\\bwget\\b.*\\|\\s*(sh|bash)\\b\u002F, label: \"piped remote execution\" },\n  { pattern: \u002F\\bsudo\\s+rm\\b\u002F, label: \"elevated deletion\" },\n];\n```\n\nMatch found → emit warning to stderr. No match → pass through silently.\n\n### PreToolUse Hook — Edit\u002FWrite (Lockdown Mode)\n\nThe hook checks `tool_input.file_path` against the lockdown path:\n\n```javascript\nfunction isInsideLockdown(filePath, lockdownPath) {\n  const resolved = fs.realpathSync(path.resolve(filePath));\n  const allowed = fs.realpathSync(path.resolve(lockdownPath));\n  const rel = path.relative(allowed, resolved);\n  return rel === '' || (!rel.startsWith('..') && !path.isAbsolute(rel));\n}\n```\n\nInside lockdown path → pass through. Outside → block with explanation.\n\n### State\n\nMode state lives in a session-scoped temp file (keyed by session ID to avoid cross-session leaks):\n\n```text\n$TMPDIR\u002Fpro-workflow\u002Fsafe-mode-\u003CsessionId>.json\n{\n  \"mode\": \"lockdown\",\n  \"lockdownPath\": \"\u002FUsers\u002Fdev\u002Fproject\u002Fsrc\u002Fapi\",\n  \"sessionId\": \"abc123\",\n  \"activatedAt\": \"2026-03-28T10:00:00Z\"\n}\n```\n\nCleared by `\u002Fsafe-mode clear`. State persists until explicitly cleared or the temp file is manually removed. Each session has its own state file.\n\n## Combining Modes\n\nCautious and lockdown can run simultaneously:\n\n```text\n\u002Fsafe-mode cautious\n\u002Fsafe-mode lockdown src\u002Fapi\u002F\n```\n\nNow you get:\n- Bash command warnings for destructive operations\n- Edit\u002FWrite restrictions to `src\u002Fapi\u002F` only\n\nClear removes both.\n\n## When to Use\n\n| Situation | Mode |\n|-----------|------|\n| Working on production-adjacent code | Cautious |\n| Focused refactoring of one module | Lockdown |\n| Unfamiliar codebase, feeling cautious | Cautious |\n| Pair programming, limiting AI scope | Lockdown |\n| Done with restrictions | Clear |\n\n## Anti-Patterns\n\n- Leaving lockdown on when you need to edit tests (update the path or clear it)\n- Using safe-mode as a substitute for git branches (branches protect history, safe-mode protects the session)\n- Ignoring cautious warnings repeatedly (if you always proceed, turn it off — false confidence is worse)\n","# Safe Mode\n\nThree levels of protection against destructive operations during AI coding sessions.\n\n> **Note:** These hooks are skill-scoped — they only activate when you invoke `\u002Fsafe-mode`. The global `permission-request.js` hook in hooks.json provides always-on alerting for dangerous commands. Safe-mode adds opt-in blocking and directory restrictions on top of that.\n\n## Modes\n\n### Cautious Mode\n\n```text\n\u002Fsafe-mode cautious\n```\n\nIntercepts Bash commands before execution. Warns on dangerous patterns but does not block — the user decides.\n\n**Flagged patterns:**\n\n| Pattern | Risk |\n|---------|------|\n| `rm -rf` \u002F `rm -r` | Recursive deletion |\n| `DROP TABLE` \u002F `DROP DATABASE` | SQL data loss |\n| `TRUNCATE` | SQL data destruction |\n| `git push --force` \u002F `git push -f` | Remote history rewrite |\n| `git reset --hard` | Local history loss |\n| `git clean -f` | Untracked file deletion |\n| `git checkout .` \u002F `git restore .` | Discard all changes |\n| `chmod 777` | World-writable permissions |\n| `curl` or `wget` piped to a shell | Piped remote execution |\n| `> \u002Fdev\u002Fsda` \u002F `dd if=` | Disk-level operations |\n| `:(){ :\\|:& };:` | Fork bombs |\n| `sudo rm` | Elevated deletion |\n\n**What happens:**\n\n```text\nWARNING: Destructive operation detected\n  Command: rm -rf .\u002Fbuild\n  Pattern: rm -rf (recursive forced deletion)\n  Risk: Permanently deletes .\u002Fbuild and all contents\n\n  Proceed? The command will execute as-is if you continue.\n```\n\nThe warning goes to stderr. Claude sees it and asks for confirmation before proceeding.\n\n### Lockdown Mode\n\n```text\n\u002Fsafe-mode lockdown \u003Cpath>\n```\n\nRestricts Edit and Write operations to a single directory tree. Prevents accidental changes to unrelated code.\n\n**How it works:**\n\n1. Set the allowed path (absolute or relative to repo root)\n2. Every Edit\u002FWrite call checks if the target file is inside the allowed path\n3. Operations outside the path are blocked with an explanation\n\n```text\nLOCKDOWN ACTIVE: Edits restricted to src\u002Fapi\u002F\n\n  Blocked: Edit to src\u002Futils\u002Fhelpers.ts\n  Reason: File is outside the lockdown path (src\u002Fapi\u002F)\n\n  To edit files outside the lockdown, run: \u002Fsafe-mode clear\n```\n\n**Use cases:**\n\n- Focused refactoring of one module without touching others\n- Bug fix in a specific directory while tests run elsewhere\n- Junior developer guardrail — scope the blast radius\n- Code review session — only edit the files under review\n\n**Scope:** Session-scoped. Resets when the session ends.\n\n### Clear\n\n```text\n\u002Fsafe-mode clear\n```\n\nRemoves all restrictions for the current session. Both cautious warnings and lockdown restrictions are disabled.\n\n```text\nSAFE MODE: All restrictions cleared for this session.\n```\n\n## Implementation\n\n### PreToolUse Hook — Bash (Cautious Mode)\n\nThe hook inspects `tool_input.command` before every Bash execution:\n\n```javascript\nconst DANGEROUS_PATTERNS = [\n  { pattern: \u002F\\brm\\s+(-[a-zA-Z]*[rf][a-zA-Z]*\\s|--recursive|--force)\u002F, label: \"rm with -rf flags\" },\n  { pattern: \u002F\\bDROP\\s+(TABLE|DATABASE|INDEX|VIEW)\\b\u002Fi, label: \"DROP SQL statement\" },\n  { pattern: \u002F\\bTRUNCATE\\b\u002Fi, label: \"TRUNCATE SQL statement\" },\n  { pattern: \u002F\\bgit\\s+push\\s+(-[a-zA-Z]*f|--force)\u002F, label: \"git force-push\" },\n  { pattern: \u002F\\bgit\\s+reset\\s+--hard\\b\u002F, label: \"git hard reset\" },\n  { pattern: \u002F\\bgit\\s+clean\\s+-[a-zA-Z]*f\u002F, label: \"git clean -f\" },\n  { pattern: \u002F\\bgit\\s+(checkout|restore)\\s+\\.\u002F, label: \"git discard all changes\" },\n  { pattern: \u002F\\bchmod\\s+777\\b\u002F, label: \"chmod 777\" },\n  { pattern: \u002F\\bcurl\\b.*\\|\\s*(sh|bash)\\b\u002F, label: \"piped remote execution\" },\n  { pattern: \u002F\\bwget\\b.*\\|\\s*(sh|bash)\\b\u002F, label: \"piped remote execution\" },\n  { pattern: \u002F\\bsudo\\s+rm\\b\u002F, label: \"elevated deletion\" },\n];\n```\n\nMatch found → emit warning to stderr. No match → pass through silently.\n\n### PreToolUse Hook — Edit\u002FWrite (Lockdown Mode)\n\nThe hook checks `tool_input.file_path` against the lockdown path:\n\n```javascript\nfunction isInsideLockdown(filePath, lockdownPath) {\n  const resolved = fs.realpathSync(path.resolve(filePath));\n  const allowed = fs.realpathSync(path.resolve(lockdownPath));\n  const rel = path.relative(allowed, resolved);\n  return rel === '' || (!rel.startsWith('..') && !path.isAbsolute(rel));\n}\n```\n\nInside lockdown path → pass through. Outside → block with explanation.\n\n### State\n\nMode state lives in a session-scoped temp file (keyed by session ID to avoid cross-session leaks):\n\n```text\n$TMPDIR\u002Fpro-workflow\u002Fsafe-mode-\u003CsessionId>.json\n{\n  \"mode\": \"lockdown\",\n  \"lockdownPath\": \"\u002FUsers\u002Fdev\u002Fproject\u002Fsrc\u002Fapi\",\n  \"sessionId\": \"abc123\",\n  \"activatedAt\": \"2026-03-28T10:00:00Z\"\n}\n```\n\nCleared by `\u002Fsafe-mode clear`. State persists until explicitly cleared or the temp file is manually removed. Each session has its own state file.\n\n## Combining Modes\n\nCautious and lockdown can run simultaneously:\n\n```text\n\u002Fsafe-mode cautious\n\u002Fsafe-mode lockdown src\u002Fapi\u002F\n```\n\nNow you get:\n- Bash command warnings for destructive operations\n- Edit\u002FWrite restrictions to `src\u002Fapi\u002F` only\n\nClear removes both.\n\n## When to Use\n\n| Situation | Mode |\n|-----------|------|\n| Working on production-adjacent code | Cautious |\n| Focused refactoring of one module | Lockdown |\n| Unfamiliar codebase, feeling cautious | Cautious |\n| Pair programming, limiting AI scope | Lockdown |\n| Done with restrictions | Clear |\n\n## Anti-Patterns\n\n- Leaving lockdown on when you need to edit tests (update the path or clear it)\n- Using safe-mode as a substitute for git branches (branches protect history, safe-mode protects the session)\n- Ignoring cautious warnings repeatedly (if you always proceed, turn it off — false confidence is worse)\n",{"name":5,"hooks":24,"description":7,"user-invocable":32},{"PreToolUse":25},[26,29],{"matcher":27,"description":28},"tool == \"Bash\"","Intercept shell commands and check for destructive operations",{"matcher":30,"description":31},"tool == \"Edit\" || tool == \"Write\"","Enforce directory lockdown when active",true,"main","d69096e239f2a89aabc2cd078c47664a9d3b1e11","05-技能与代理开发\u002Fsafe-mode",3,"https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts","https:\u002F\u002Fgithub.com\u002Flza6","个人vx：Tf00798\r\n个人✈：@TFGY999","2026-10-08 14:29:22",{"source":8,"skillName":5,"commands":42,"prompt":52,"zipAvailable":32},[43,46,49],{"tool":44,"command":45},"npx","npx skills add lza6\u002FArmor-piercing-system-prompts --skill safe-mode",{"tool":47,"command":48},"bunx","bunx skills add lza6\u002FArmor-piercing-system-prompts --skill safe-mode",{"tool":50,"command":51},"pnpm","pnpm dlx skills add lza6\u002FArmor-piercing-system-prompts --skill safe-mode","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F05-技能与代理开发\u002Fsafe-mode\u002FSKILL.md",[],[55,62,67,74,81,88],{"skillNo":56,"name":57,"nameZh":6,"description":58,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":59,"categories":60,"keywords":61,"publishedAt":19},"01M7FFG485KY83TD6HSC4YPCMC","obsidian-clipper-template-creator","Guide for creating templates for the Obsidian Web Clipper. Use when you want to create a new clipping template, understand available variables, or format clipped content.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobsidian-clipper-template-creator\u002FSKILL.md",[],[],{"skillNo":63,"name":57,"nameZh":6,"description":58,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":64,"categories":65,"keywords":66,"publishedAt":19},"01M7FFG0T6AZ0STEJPSB3CX84K","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobsidian-clipper-template-creator-antigravity-awesome-skills-main\u002FSKILL.md",[],[],{"skillNo":68,"name":69,"nameZh":6,"description":70,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":71,"categories":72,"keywords":73,"publishedAt":19},"01M7FFFY0QEM14SKWPDYGMXM2P","python-api","Programmatic Object-Detection-Metrics API guidance for BoundingBox, BoundingBoxes, Evaluator, enums, coordinate conversion, AP\u002FmAP semantics, and source-style import diagnostics.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobject-detection-metrics\u002Fsub-skills\u002Fpython-api\u002FSKILL.md",[],[],{"skillNo":75,"name":76,"nameZh":6,"description":77,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":78,"categories":79,"keywords":80,"publishedAt":19},"01M7FFFVZQZ2GJ0C0TGP7JHD20","file-evaluation","Folder-based PASCAL VOC AP\u002FmAP evaluation from ground-truth and detection text files.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobject-detection-metrics\u002Fsub-skills\u002Ffile-evaluation\u002FSKILL.md",[],[],{"skillNo":82,"name":83,"nameZh":6,"description":84,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":85,"categories":86,"keywords":87,"publishedAt":19},"01M7FFFSFNYSE77SJ6PE1CK2DA","object-detection-metrics","Guides legacy Object-Detection-Metrics PASCAL VOC AP\u002FmAP evaluation from detection text folders and direct Python API classes.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobject-detection-metrics\u002FSKILL.md",[],[],{"skillNo":89,"name":90,"nameZh":6,"description":91,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":92,"categories":93,"keywords":94,"publishedAt":19},"01M7FFFP0GCK1RVXBCPQ8APBMT","nx-workspace-patterns","Configure and optimize Nx monorepo workspaces. Use when setting up Nx, configuring project boundaries, optimizing build caching, or implementing affected commands.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fnx-workspace-patterns\u002FSKILL.md",[],[]]