git-guardrails-claude-code
Set up Claude Code hooks to block dangerous git commands (push, reset --hard, clean, branch -D, etc.) before they execute. Use when user wants to prevent destructive git operations, add git safety hooks, or block git push/reset in Claude Code.
Target: Software development & testing. Automatically collected · unverified.
Excerpt from the author’s documentation
Extracted from a fixed version of SKILL.md in its original language. This is the author’s documentation; installation, compatibility and runtime results have not been verified by this site.
Read the original English text
Topics in the source
- Setup Git Guardrails
- What Gets Blocked
- Steps
- 1. Ask scope
- 2. Copy the hook script
- 3. Add hook to settings
- 4. Ask about customization
- 5. Verify
Sets up a PreToolUse hook that intercepts and blocks dangerous git commands before Claude executes them. git push (all variants including --force) git reset --hard git clean -f / git clean -fd git branch -D git checkout . / git restore . When blocked, Claude sees a message telling it that it does not have authority to access these commands. Ask the user: install for this project only (.claude/settings.json) or all projects (/.claude/settings.json)? The bundled script is at: scripts/block-dangerous-git.sh Copy it to the target location based on scope: Project: .claude/hooks/block-dangerous-git.sh Global: /.claude/hooks/block-dangerous-git.sh Make it executable with chmod +x. Add to the appropriate settings file: Project (.claude/settings.json): Global (/.claude/settings.json): If the settings file already exists, merge the hook into the existing hooks.PreToolUse array. Don't overwrite other settings. Ask if user wants to add or remove any patterns from the blocked list. Edit the copied script accordingly. Run a quick test: Should exit with code 2 and print a BLOCKED message to stderr.
- Source repository
- mattpocock/skills
- Source file
- skills/misc/git-guardrails-claude-code/SKILL.md
- Fixed revision
- 4ae2317ddb22b046e26455e4f9c9b3aaaf62212d
Requirements
- Only the author’s Skill metadata is included. Read the full instructions to check dependencies, licensing and conditions of use.
A small first task
先阅读原作者说明,再决定是否在自己的 AI 工具中使用。
Instructions for your AI tool
- Claude Desktop: resource-specific guide not available yet
- Claude Code: resource-specific guide not available yet
- Cursor: resource-specific guide not available yet
- Codex: resource-specific guide not available yet
Author documentation is not live verification by this site. Without evidence, we do not mark a resource as compatible, safe or free.
Sources and evidence
This record was collected automatically. Its documentation, suitability and runtime behavior have not been manually verified.
Author: Matt Pocock Skills · original repository metadata. Documentation review: Not reviewed. Last source check: 2026-11-10T23:01:40.409Z.
Categories are inferred from names, descriptions and paths. They do not establish compatibility.
License and attribution
MIT. Third-party content and copyright remain with their authors. Refer to the original license and terms.
Original license ↗Synchronization, copying and user-reported success do not mark a resource as runtime-tested.
Limitations and notes
- Collecting metadata does not mean this site has installed, adapted, runtime-tested or security-reviewed the resource.