[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M75MM0FN33HYA64KV124J2ZV":3,"skill-same:01M75MM0FN33HYA64KV124J2ZV":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":27,"repositoryHtmlUrl":28,"repositoryHomepageUrl":6,"ownerHtmlUrl":29,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":30,"install":31,"resources":44},"01M75MM0FN33HYA64KV124J2ZV","git-guardrails-claude-code",null,"设置 Claude Code 钩子，在危险 Git 命令（push、reset --hard、clean、branch -D 等）执行前将其拦截。当用户想要防止破坏性 Git 操作、添加 Git 安全钩子或在 Claude Code 中阻止 git push\u002Freset 时使用。","devcxl\u002Fmattpocock-skills-zh","devcxl","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F64475363?v=4","01M75MJ7N3BE0AK24Q83ZVY13N","半颗白菜","01M75MJ7P58635MPFAW17AG3SV",541,"MIT","https:\u002F\u002Fgithub.com\u002Fdevcxl\u002Fmattpocock-skills-zh\u002Fblob\u002Fmain\u002Fskills\u002Fmisc\u002Fgit-guardrails-claude-code\u002FSKILL.md",[],[],"2026-11-12 13:55:43",false,"---\nname: git-guardrails-claude-code\ndescription: 设置 Claude Code 钩子，在危险 Git 命令（push、reset --hard、clean、branch -D 等）执行前将其拦截。当用户想要防止破坏性 Git 操作、添加 Git 安全钩子或在 Claude Code 中阻止 git push\u002Freset 时使用。\n---\n\n# 设置 Git 护栏\n\n设置一个 PreToolUse 钩子，在 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. 复制钩子脚本\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. 将钩子添加到设置文件\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如果设置文件已存在，将钩子合并到现有的 `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 钩子，在 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. 复制钩子脚本\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. 将钩子添加到设置文件\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如果设置文件已存在，将钩子合并到现有的 `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","30fc5dbf9380144598f3593e6c1e22c713a52c2a","skills\u002Fmisc\u002Fgit-guardrails-claude-code",48,"https:\u002F\u002Fgithub.com\u002Fdevcxl\u002Fmattpocock-skills-zh","https:\u002F\u002Fgithub.com\u002Fdevcxl","2026-11-13 04:10:40",{"source":8,"skillName":5,"commands":32,"prompt":42,"zipAvailable":43},[33,36,39],{"tool":34,"command":35},"npx","npx skills add devcxl\u002Fmattpocock-skills-zh --skill git-guardrails-claude-code",{"tool":37,"command":38},"bunx","bunx skills add devcxl\u002Fmattpocock-skills-zh --skill git-guardrails-claude-code",{"tool":40,"command":41},"pnpm","pnpm dlx skills add devcxl\u002Fmattpocock-skills-zh --skill git-guardrails-claude-code","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fdevcxl\u002Fmattpocock-skills-zh\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","参考文档",110,"https:\u002F\u002Fgithub.com\u002Fdevcxl\u002Fmattpocock-skills-zh\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\u002Fdevcxl\u002Fmattpocock-skills-zh\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},"01M75MMJXWKRN5DFAYWKNHCG28","writing-for-agents","为智能体编写文档。当你正在创建或编辑技能，或者修改 AGENTS.md \u002F CLAUDE.md 时使用。","https:\u002F\u002Fgithub.com\u002Fdevcxl\u002Fmattpocock-skills-zh\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},"01M75MMHVFN4B6QBPNGQ5GJSDT","wait-what","等等。上一条消息我没理解：重新解释一下。","https:\u002F\u002Fgithub.com\u002Fdevcxl\u002Fmattpocock-skills-zh\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},"01M75MMGNH9G1M7WC7NKP6100Y","to-questionnaire","将你无法完全回答的决策转化为供他人填写的问卷。","https:\u002F\u002Fgithub.com\u002Fdevcxl\u002Fmattpocock-skills-zh\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},"01M75MME5PC8MBS7M6R6RH7VDH","teach","在当前工作区中教会用户一项新技能或概念。","https:\u002F\u002Fgithub.com\u002Fdevcxl\u002Fmattpocock-skills-zh\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},"01M75MMD05VWVMK55W6GEWJNX3","handoff","将当前对话压缩为一份交接文档，供另一个智能体继续工作。","https:\u002F\u002Fgithub.com\u002Fdevcxl\u002Fmattpocock-skills-zh\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},"01M75MMBS30DRYPMC6SADZ7ZTT","grilling","对用户的计划、决策或想法进行层层盘问。当用户想要压力测试自己的思考，或使用任何 'grill' 触发短语时使用。","https:\u002F\u002Fgithub.com\u002Fdevcxl\u002Fmattpocock-skills-zh\u002Fblob\u002Fmain\u002Fskills\u002Fproductivity\u002Fgrilling\u002FSKILL.md",[],[]]