[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7AR85XADEBWY6WK50ZDDRSJ":3,"skill-same:01M7AR85XADEBWY6WK50ZDDRSJ":57},{"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":24,"commitSha":25,"skillDirectory":26,"forksCount":14,"repositoryHtmlUrl":27,"repositoryHomepageUrl":6,"ownerHtmlUrl":28,"ownerBlogUrl":6,"ownerDescription":29,"updatedAt":30,"install":31,"resources":44},"01M7AR85XADEBWY6WK50ZDDRSJ","git-guardrails-claude-code",null,"配置 Claude Code hook，在危险的 Git 命令（push、reset --hard、clean、branch -D 等）执行前拦截。在用户想防止破坏性 Git 操作、添加 Git 安全 hook，或在 Claude Code 中拦截 git push\u002Freset 时使用。","shenjunjian\u002Fmatt-skill-cn","shenjunjian","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F6848520?v=4","01M7AR6EQAH157Z6EXRJV4QSBG","申君健","01M7AR6ERC1W67CKYK9FBKDQG9",0,"MIT","https:\u002F\u002Fgithub.com\u002Fshenjunjian\u002Fmatt-skill-cn\u002Fblob\u002Fmain\u002Fskills\u002Fmisc\u002Fgit-guardrails-claude-code\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: git-guardrails-claude-code\ndescription: 配置 Claude Code hook，在危险的 Git 命令（push、reset --hard、clean、branch -D 等）执行前拦截。在用户想防止破坏性 Git 操作、添加 Git 安全 hook，或在 Claude Code 中拦截 git push\u002Freset 时使用。\n---\n\n# 配置 Git 护栏\n\n设置一个 PreToolUse hook，在 Claude 执行危险的 Git 命令之前拦截并阻止它们。\n\n## 会拦截什么\n\n- `git push`（所有变体，包括 `--force`）\n- `git reset --hard`\n- `git clean -f` \u002F `git clean -fd`\n- `git branch -D`\n- `git checkout .` \u002F `git restore .`\n\n被拦截时，Claude 会看到一条消息，告知它没有权限使用这些命令。\n\n## 步骤\n\n### 1. 询问作用范围\n\n询问用户：仅安装到**当前项目**（`.claude\u002Fsettings.json`）还是**所有项目**（`~\u002F.claude\u002Fsettings.json`）？\n\n### 2. 复制 hook 脚本\n\n附带脚本位于：[scripts\u002Fblock-dangerous-git.sh](scripts\u002Fblock-dangerous-git.sh)\n\n按作用范围复制到目标位置：\n\n- **项目**：`.claude\u002Fhooks\u002Fblock-dangerous-git.sh`\n- **全局**：`~\u002F.claude\u002Fhooks\u002Fblock-dangerous-git.sh`\n\n用 `chmod +x` 使其可执行。\n\n### 3. 将 hook 加入设置\n\n添加到对应的设置文件：\n\n**项目**（`.claude\u002Fsettings.json`）：\n\n```json\n{\n  \"hooks\": {\n    \"PreToolUse\": [\n      {\n        \"matcher\": \"Bash\",\n        \"hooks\": [\n          {\n            \"type\": \"command\",\n            \"command\": \"\\\"$CLAUDE_PROJECT_DIR\\\"\u002F.claude\u002Fhooks\u002Fblock-dangerous-git.sh\"\n          }\n        ]\n      }\n    ]\n  }\n}\n```\n\n**全局**（`~\u002F.claude\u002Fsettings.json`）：\n\n```json\n{\n  \"hooks\": {\n    \"PreToolUse\": [\n      {\n        \"matcher\": \"Bash\",\n        \"hooks\": [\n          {\n            \"type\": \"command\",\n            \"command\": \"~\u002F.claude\u002Fhooks\u002Fblock-dangerous-git.sh\"\n          }\n        ]\n      }\n    ]\n  }\n}\n```\n\n如果设置文件已存在，把 hook 合并进现有的 `hooks.PreToolUse` 数组——不要覆盖其他设置。\n\n### 4. 询问自定义\n\n询问用户是否要从拦截列表中增删任何模式。据此编辑已复制的脚本。\n\n### 5. 验证\n\n快速测试：\n\n```bash\necho '{\"tool_input\":{\"command\":\"git push origin main\"}}' | \u003Cpath-to-script>\n```\n\n应以退出码 2 结束，并向 stderr 打印 BLOCKED 消息。\n","# 配置 Git 护栏\n\n设置一个 PreToolUse hook，在 Claude 执行危险的 Git 命令之前拦截并阻止它们。\n\n## 会拦截什么\n\n- `git push`（所有变体，包括 `--force`）\n- `git reset --hard`\n- `git clean -f` \u002F `git clean -fd`\n- `git branch -D`\n- `git checkout .` \u002F `git restore .`\n\n被拦截时，Claude 会看到一条消息，告知它没有权限使用这些命令。\n\n## 步骤\n\n### 1. 询问作用范围\n\n询问用户：仅安装到**当前项目**（`.claude\u002Fsettings.json`）还是**所有项目**（`~\u002F.claude\u002Fsettings.json`）？\n\n### 2. 复制 hook 脚本\n\n附带脚本位于：[scripts\u002Fblock-dangerous-git.sh](scripts\u002Fblock-dangerous-git.sh)\n\n按作用范围复制到目标位置：\n\n- **项目**：`.claude\u002Fhooks\u002Fblock-dangerous-git.sh`\n- **全局**：`~\u002F.claude\u002Fhooks\u002Fblock-dangerous-git.sh`\n\n用 `chmod +x` 使其可执行。\n\n### 3. 将 hook 加入设置\n\n添加到对应的设置文件：\n\n**项目**（`.claude\u002Fsettings.json`）：\n\n```json\n{\n  \"hooks\": {\n    \"PreToolUse\": [\n      {\n        \"matcher\": \"Bash\",\n        \"hooks\": [\n          {\n            \"type\": \"command\",\n            \"command\": \"\\\"$CLAUDE_PROJECT_DIR\\\"\u002F.claude\u002Fhooks\u002Fblock-dangerous-git.sh\"\n          }\n        ]\n      }\n    ]\n  }\n}\n```\n\n**全局**（`~\u002F.claude\u002Fsettings.json`）：\n\n```json\n{\n  \"hooks\": {\n    \"PreToolUse\": [\n      {\n        \"matcher\": \"Bash\",\n        \"hooks\": [\n          {\n            \"type\": \"command\",\n            \"command\": \"~\u002F.claude\u002Fhooks\u002Fblock-dangerous-git.sh\"\n          }\n        ]\n      }\n    ]\n  }\n}\n```\n\n如果设置文件已存在，把 hook 合并进现有的 `hooks.PreToolUse` 数组——不要覆盖其他设置。\n\n### 4. 询问自定义\n\n询问用户是否要从拦截列表中增删任何模式。据此编辑已复制的脚本。\n\n### 5. 验证\n\n快速测试：\n\n```bash\necho '{\"tool_input\":{\"command\":\"git push origin main\"}}' | \u003Cpath-to-script>\n```\n\n应以退出码 2 结束，并向 stderr 打印 BLOCKED 消息。\n",{"name":5,"description":7},"main","79daa74053d0a8173c9b7678a8de7987bc73cee2","skills\u002Fmisc\u002Fgit-guardrails-claude-code","https:\u002F\u002Fgithub.com\u002Fshenjunjian\u002Fmatt-skill-cn","https:\u002F\u002Fgithub.com\u002Fshenjunjian","前端开发","2026-08-19 15:58:38",{"source":8,"skillName":5,"commands":32,"prompt":42,"zipAvailable":43},[33,36,39],{"tool":34,"command":35},"npx","npx skills add shenjunjian\u002Fmatt-skill-cn --skill git-guardrails-claude-code",{"tool":37,"command":38},"bunx","bunx skills add shenjunjian\u002Fmatt-skill-cn --skill git-guardrails-claude-code",{"tool":40,"command":41},"pnpm","pnpm dlx skills add shenjunjian\u002Fmatt-skill-cn --skill git-guardrails-claude-code","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fshenjunjian\u002Fmatt-skill-cn\u002Fblob\u002Fmain\u002Fskills\u002Fmisc\u002Fgit-guardrails-claude-code\u002FSKILL.md",true,[45,51],{"path":46,"resourceType":47,"resourceTypeDesc":48,"sizeBytes":49,"sourceHtmlUrl":50},"agents\u002Fopenai.yaml","REFERENCE","参考文档",106,"https:\u002F\u002Fgithub.com\u002Fshenjunjian\u002Fmatt-skill-cn\u002Fblob\u002Fmain\u002Fskills\u002Fmisc\u002Fgit-guardrails-claude-code\u002Fagents\u002Fopenai.yaml",{"path":52,"resourceType":53,"resourceTypeDesc":54,"sizeBytes":55,"sourceHtmlUrl":56},"scripts\u002Fblock-dangerous-git.sh","SCRIPT","脚本",507,"https:\u002F\u002Fgithub.com\u002Fshenjunjian\u002Fmatt-skill-cn\u002Fblob\u002Fmain\u002Fskills\u002Fmisc\u002Fgit-guardrails-claude-code\u002Fscripts\u002Fblock-dangerous-git.sh",[58,65,72,79,86,93],{"skillNo":59,"name":60,"nameZh":6,"description":61,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":62,"categories":63,"keywords":64,"publishedAt":19},"01M7AR8ZSQPSVC5H6QV068JWW4","writing-for-agents","为 agent 写文档。在创建或编辑 skill，或修改 AGENTS.md 或 CLAUDE.md 时使用。","https:\u002F\u002Fgithub.com\u002Fshenjunjian\u002Fmatt-skill-cn\u002Fblob\u002Fmain\u002Fskills\u002Fproductivity\u002Fwriting-for-agents\u002FSKILL.md",[],[],{"skillNo":66,"name":67,"nameZh":6,"description":68,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":69,"categories":70,"keywords":71,"publishedAt":19},"01M7AR8WVSQYDJWM785VHY2204","wait-what","停。上一条消息没落地——重新讲一遍。","https:\u002F\u002Fgithub.com\u002Fshenjunjian\u002Fmatt-skill-cn\u002Fblob\u002Fmain\u002Fskills\u002Fproductivity\u002Fwait-what\u002FSKILL.md",[],[],{"skillNo":73,"name":74,"nameZh":6,"description":75,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":76,"categories":77,"keywords":78,"publishedAt":19},"01M7AR8TE6THPZGTNZWXBTF1ER","to-questionnaire","把你无法独自完全回答的决策变成一份问卷，交给别人填。","https:\u002F\u002Fgithub.com\u002Fshenjunjian\u002Fmatt-skill-cn\u002Fblob\u002Fmain\u002Fskills\u002Fproductivity\u002Fto-questionnaire\u002FSKILL.md",[],[],{"skillNo":80,"name":81,"nameZh":6,"description":82,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":83,"categories":84,"keywords":85,"publishedAt":19},"01M7AR8QH5KCYB8JWJ0YMCAZQP","teach","在本工作区内教用户一项新技能或概念。","https:\u002F\u002Fgithub.com\u002Fshenjunjian\u002Fmatt-skill-cn\u002Fblob\u002Fmain\u002Fskills\u002Fproductivity\u002Fteach\u002FSKILL.md",[],[],{"skillNo":87,"name":88,"nameZh":6,"description":89,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":90,"categories":91,"keywords":92,"publishedAt":19},"01M7AR8P40KPWP498430CHCG3A","handoff","把当前对话压缩成交接文档，供另一个 agent 接手。","https:\u002F\u002Fgithub.com\u002Fshenjunjian\u002Fmatt-skill-cn\u002Fblob\u002Fmain\u002Fskills\u002Fproductivity\u002Fhandoff\u002FSKILL.md",[],[],{"skillNo":94,"name":95,"nameZh":6,"description":96,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":97,"categories":98,"keywords":99,"publishedAt":19},"01M7AR8MKY639QRKXQN6TCKZ1T","grilling","就计划、决策或想法对用户毫不放松地 grilling。在用户想压力测试自己的思考，或使用任何 'grill' 触发短语时使用。","https:\u002F\u002Fgithub.com\u002Fshenjunjian\u002Fmatt-skill-cn\u002Fblob\u002Fmain\u002Fskills\u002Fproductivity\u002Fgrilling\u002FSKILL.md",[],[]]