git-guardrails-claude-code
Installation
SKILL.md
设置 Git 防护栏
设置 PreToolUse 钩子,在 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)?