git-guardrails
Set up Claude Code hooks to block dangerous Git commands (push, reset --hard, clean, branch -D, etc.) before they execute.
Skill by petemcw
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/petemcw-git-guardrails
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: agent-building
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
- Runs as
- Shell scripts
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/git-guardrails
What's inside
- Skill name
git-guardrails- Description
- 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.
- License
- MIT
- Instructions
- 94 lines in SKILL.md · view on GitHub
Before installing
- Ships executable scripts
Files (2)
- SKILL.md
- block-dangerous-commands.sh · scripts/
SKILL.md (first lines)
# Git Guardrails
Sets up a `PreToolUse` hook that intercepts and blocks dangerous Git commands before Claude executes them.
## What Gets Blocked
- `git push` (all variants including `--force`)
- `git reset --hard`
- `git clean` with any force flag (`-f`, `-fd`, `-xfd`, `--force`)
- `git branch -D`, and `--delete` combined with `--force`
- `git checkout .` / `git checkout -- .` / `git restore .`
The script checks each command in a chain (`cd x && git push`) and sees through git's global options (`git -C dir push`, `git --no-pager push`). Text that merely mentions a command, like `echo "git push"`, is allowed. It needs `jq`, and blocks everything if `jq` is missing rather than silently allowing it. It is a guardrail against accidents, not a security boundary: `bash -c "git push"` is not inspected.
When blocked, Claude sees a message telling it that it does not have authority to access these commands.
## Steps
### 1. Ask Scope
Ask the user's preference: install for **this project only** (`.claude/settings.json`) or **all projects** (`~/.claude/settings.json`)?
### 2. Copy the Hook script
The bundled script is at: [scripts/block-dangerous-commands.sh](scripts/block-dangerous-commands.sh)
Copy it to the target location based on scope:
- **Project**: `.claude/hooks/block-dangerous-commands.sh`
- **Global**: `~/.claude/hooks/block-dangerous-commands.sh`
Make it executable with `chmod +x`.
### 3. Add Hook to Settings
Add to the appropriate settings file:
**Project** (`.claude/settings.json`):
```json
{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "\"$CLAUDE_PROJECT_DIR\"/.claude/hooks/block-dangerous-commands.sh"
}
]
}
]
}
}
```
**Global** (`~/.claude/settings.json`):
```json
{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "~/.claude/hooks/block-dangerous-commands.sh"
}
]
}
]
}
}
```
If the settings file already exists, merge the hook into the existing `hooks.PreToolUse` array. Don't overwrite other settings.
### 4. Ask About Customization
Ask the user if they want to add or remove any patterns from the blocked list. Edit the copied script accordingly.
### 5. Verify
Run a quick test:
```bash
echo '{"tool_input":{"command":"git push origin main"}}' | <path-to-script>
```
Should exit with code `2` and print a `BLOCKED` message to stderr.From petemcw/farseer, MIT.
More from petemcw/farseer
- 0.570score
prototype
petemcw
Build a throwaway but polished prototype that answers a design question.
SkillAFreshness: AClaude Code +9 - 0.570score
illustrations
petemcw
Generate hand-drawn, Xiaohei-style in-article illustrations, or a shot list of where an article needs them.
SkillAFreshness: AClaude Code +9 - 0.567score
architecture-decision-records
petemcw
Capture architectural decisions made during coding sessions as structured ADRs.
SkillAFreshness: AClaude Code +9 - 0.567score
triage
petemcw
Move issues through a state machine of issue roles, categorize, verify, interview if needed, and write agent-ready briefs.
SkillAFreshness: AClaude Code +9 - 0.565score
interviewer
petemcw
Question the user relentlessly about a plan, decision, or an idea to uncover hidden assumptions, risks, and edge cases.
SkillAFreshness: AClaude Code +9 - 0.565score
repo-setup
petemcw
One-time interactive setup to configure a repository for autonomous development.
SkillAFreshness: AClaude Code +9 - 0.561score
farseer
petemcw
Plan a new project or a chunk of work too big for one agent session as a shared map of decision tickets on your issue tracker, then resolve them one at a time…
SkillAFreshness: AClaude Code +9 - 0.558score
humanize
petemcw
Cut out AI tells from any writing.
SkillAFreshness: AClaude Code +9 - 0.555score
orchestrate
petemcw
Execute implementation plans with parallel TDD workers.
SkillAFreshness: AClaude Code +9 - 0.555score
planner
petemcw
Create structured implementation plans for autonomous TDD development.
SkillAFreshness: AClaude Code +9 - 0.544score
domain-modeling
petemcw
Build and sharpen a project's domain model.
SkillAFreshness: AClaude Code +9 - 0.538score
teach
petemcw
Teach the user a new skill or concept, within this workspace.
SkillAFreshness: AClaude Code +9
Signals
- Stars
- 0
- Forks
- 0
- Open issues
- 0
- Last commit (this folder)
- Oct 15, 2026 (13 days ago)
- Last release
- Oct 15, 2026 (13 days ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/petemcw/farseer
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
Same skill elsewhere
Copies of this SKILL.md published by others; search shows only one of them.
More from petemcw
- 0.570score
prototype
petemcw
Build a throwaway but polished prototype that answers a design question.
SkillAFreshness: AClaude Code +9 - 0.570score
illustrations
petemcw
Generate hand-drawn, Xiaohei-style in-article illustrations, or a shot list of where an article needs them.
SkillAFreshness: AClaude Code +9 - 0.567score
triage
petemcw
Move issues through a state machine of issue roles, categorize, verify, interview if needed, and write agent-ready briefs.
SkillAFreshness: AClaude Code +9 - 0.567score
architecture-decision-records
petemcw
Capture architectural decisions made during coding sessions as structured ADRs.
SkillAFreshness: AClaude Code +9 - 0.565score
repo-setup
petemcw
One-time interactive setup to configure a repository for autonomous development.
SkillAFreshness: AClaude Code +9 - 0.565score
interviewer
petemcw
Question the user relentlessly about a plan, decision, or an idea to uncover hidden assumptions, risks, and edge cases.
SkillAFreshness: AClaude Code +9
Cite this page
git-guardrails skill. Agent Mart. https://agentmart.dev/skills/petemcw-git-guardrails (last updated 2026-10-24)