Git guard
Security-focused skills for AI coding agents
npx -y skills add thedevappsecguy/sec-skills --skill git-guardAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its author says it does
Copied from the file, not written here
Set up Claude Code hooks to block dangerous git commands before they execute, including `git push`, `git reset --hard`, `git clean`, `git branch -D`, and checkout or restore of the working tree. Use this skill when the user wants to prevent destructive git operations, protect a repo from accidental pushes or resets, add git safety hooks, or make git commands safer.
SKILL.md
2.3 KB, 486 tokens by cl100k_base, as published. Nobody here has run it
Git Guard
Set up a PreToolUse hook that intercepts and blocks dangerous git commands before Claude executes them.
What Gets Blocked
git push, including force variantsgit reset --hardgit clean -fandgit clean -fdgit branch -Dgit checkout .andgit restore .
When blocked, Claude sees a message explaining that it does not have authority to run the command.
Steps
1. Ask scope
Ask whether to install for this project only in .claude/settings.json or for all projects in ~/.claude/settings.json.
2. Copy the hook script
The bundled script is at scripts/git-guard.sh.
Prerequisite: jq must be installed.
Copy it to the target location based on scope:
- Project:
.claude/hooks/git-guard.sh - Global:
~/.claude/hooks/git-guard.sh
Make it executable with chmod +x.
3. Add the hook to settings
Add this to the appropriate settings file.
Project scope:
{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "\"$CLAUDE_PROJECT_DIR\"/.claude/hooks/git-guard.sh"
}
]
}
]
}
}
Global scope:
{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "~/.claude/hooks/git-guard.sh"
}
]
}
]
}
}
If the settings file already exists, merge the hook into the existing hooks.PreToolUse array instead of overwriting other settings.
4. Ask about customization
Ask whether to add or remove any blocked patterns, then edit the copied script accordingly.
5. Verify
Run a quick test:
echo '{"tool_input":{"command":"git push origin main"}}' | <path-to-script>
The script should exit with code 2 and print a BLOCKED message to stderr.
What ships with it: 1 file
509 B alongside SKILL.md, 1 of them executable
scripts/
- git-guard.shruns509 B