Install
$ agentstack add skill-officialunofficial-skills-git-guardrails-claude-code ✓ scanned · ✓ verified, works with Claude Code, Cursor, and more.
Security review
✓ PassedNo issues found. Passed automated security review. · v0.1.0 How review works →
- ✓ Prompt-injection patterns
- ✓ Secret / credential exfiltration
- ✓ Dangerous shell & filesystem operations
- ✓ Untrusted network calls
- ✓ Known-malicious package signatures
What it can access
- ✓ Network access No
- ✓ Filesystem access No
- ✓ Shell / process execution No
- ✓ Environment & secrets No
- ✓ Dynamic code execution No
From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.
Verified badge
Passed review? Show it. Paste this badge into your README, it links to the public security report.
Reliability & compatibility
Declared compatibility
Compatibility is declared by the source manifest. End-to-end runtime verification is coming, see below.
We're building live execution health for every listing: tool-call success rate, median latency, uptime, and last-checked timestamps, measured, not self-reported. It isn't live yet, so we don't show numbers we can't stand behind.
How agent discovery & health will work →About
Git guardrails for Claude Code
Wire up a PreToolUse hook that inspects every Bash command Claude is about to run and refuses the destructive git operations before they touch the repository.
What the guard refuses
git pushin any form, including--forcegit reset --hardgit clean -fandgit clean -fdgit branch -Dgit checkout .andgit restore .
When a command matches, the hook exits with code 2 and Claude receives a message stating it is not permitted to run that command, so it stops rather than retrying.
Steps
1. Confirm the scope
Ask whether the guard should cover this project only (.claude/settings.json) or every project (~/.claude/settings.json). The answer decides where the script and the hook entry go.
2. Place the hook script
The bundled script lives at [scripts/block-dangerous-git.sh](scripts/block-dangerous-git.sh). Copy it to match the chosen scope:
- Project:
.claude/hooks/block-dangerous-git.sh - Global:
~/.claude/hooks/block-dangerous-git.sh
Then mark it executable with chmod +x.
3. Register the hook in settings
Add the hook to the settings file for the chosen scope.
Project (.claude/settings.json):
{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "\"$CLAUDE_PROJECT_DIR\"/.claude/hooks/block-dangerous-git.sh"
}
]
}
]
}
}
Global (~/.claude/settings.json):
{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "~/.claude/hooks/block-dangerous-git.sh"
}
]
}
]
}
}
When the settings file already exists, merge this entry into the existing hooks.PreToolUse array and leave the rest of the file untouched.
4. Offer to tune the pattern list
Ask whether any patterns should be added or dropped, then edit the DANGEROUS_PATTERNS array in the copied script to match.
5. Confirm it works
Feed a sample command through the script and check the result:
echo '{"tool_input":{"command":"git push origin main"}}' |
A working guard exits with code 2 and prints a BLOCKED line to stderr.
Source & license
This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.
- Author: officialunofficial
- Source: officialunofficial/skills
- License: Apache-2.0
Install and usage instructions live in the source repository linked above.
Reviews
No reviews yet, be the first.
Write a review
Versions
- v0.1.0 Imported from the upstream source.