xxih/ai-harness-zh/git-guardrails-claude-code
- community
Checking that the SKILL.md file is still in the repository.
设置 Claude Code hook 在执行前拦截危险 git 命令(push, reset --hard, clean, branch -D 等)。当用户想阻止破坏性 git 操作、加 git 安全 hook,或在 Claude Code 里拦 git push/reset 时使用。
Install
npx vskill@latest install xxih/ai-harness-zh/git-guardrails-claude-codeSKILL.md
Setup Git Guardrails
配置一个 PreToolUse hook,在 Claude 执行前拦截危险 git 命令。
拦截什么
git push(所有变体,包括--force)git reset --hardgit clean -f/git clean -fdgit branch -Dgit checkout ./git restore .
被拦截时,Claude 会看到一条说"你没有权限执行这些命令"的消息。
步骤
1. 问范围
问用户:只装本项目(.claude/settings.json)还是所有项目(~/.claude/settings.json)?
2. 复制 hook 脚本
打包脚本在:scripts/block-dangerous-git.sh
按范围复制:
- 项目:
.claude/hooks/block-dangerous-git.sh - 全局:
~/.claude/hooks/block-dangerous-git.sh
用 chmod +x 设可执行。
3. 把 hook 加到 settings
加到对应 settings 文件:
项目(.claude/settings.json):
全局(~/.claude/settings.json):
如果 settings 已存在,把 hook 合并到 `hooks.PreToolUse` 数组——别覆盖其它配置。
4. 问要不要定制
问用户要不要从拦截列表里加/去哪些模式。改复制后的脚本。
5. 验证
快速测试:
应该以 exit code 2 退出,并在 stderr 打印 BLOCKED 信息。
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingreferences/translations/mattpocock-skills/skills/misc/git-guardrails-claude-code/SKILL.md
Popularity
- Repository stars
- 1
- 7-day trend score
- 8
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/xxih/ai-harness-zh/git-guardrails-claude-code)