git-guardrails-claude-code
Sets up Claude Code hooks to block dangerous git commands (push, reset --hard, clean, branch -D, etc.) before they execute.
Skill by sgpopov
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/sgpopov-git-guardrails-claude-code
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-claude-code
What's inside
- Skill name
git-guardrails-claude-code- Description
- Sets 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
- 101 lines in SKILL.md · view on GitHub
Before installing
- Ships executable scripts
Files (2)
- SKILL.md
- block-dangerous-git.sh · scripts/
SKILL.md (first lines)
# Setup Git Guardrails
## Overview
Sets up a PreToolUse hook that intercepts and blocks dangerous git commands before Claude executes them.
## When to Use
- The user wants to prevent destructive git operations (push, `reset --hard`, `clean`, `branch -D`) in Claude Code
- A project needs persistent guardrails so the agent can't run irreversible git commands
Skip it if the user only wants a one-off block in the current conversation rather than an installed hook.
## What Gets Blocked
- `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.
## Steps
### 1. Ask scope
Ask the user: 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-git.sh](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`.
### 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-git.sh"
}
]
}
]
}
}
```
**Global** (`~/.claude/settings.json`):
```json
{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "~/.claude/hooks/block-dangerous-git.sh"
}
]
}
]
}
}
```
If the settings file already exists, merge the hook into existing `hooks.PreToolUse` array — don't overwrite other settings.
### 4. Ask about customization
Ask if user wants to add or remove any patterns from the blocked list. Edit the copied script accordingly.
## Verification
After installing, 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 sgpopov/ai-kit, MIT.
More from sgpopov/ai-kit
- 0.588score
ai-visibility
sgpopov
Measure and improve whether AI assistants (ChatGPT, Claude, Gemini, Perplexity, Copilot) recommend a brand, and fix the reasons they do not.
SkillAFreshness: A★ 1Claude Code +9 - 0.581score
implement
sgpopov
Implement work from an existing spec or set of tickets, including testing, independent review, and a commit.
SkillAFreshness: A★ 1Claude Code +9 - 0.547score
log-analyzer
sgpopov
Analyzes application, access, and structured logs for errors, trends, anomalies, and operational evidence.
SkillBFreshness: B★ 1Claude Code +9 - 0.527score
domain-modeling
sgpopov
Build and sharpen a project's domain model.
SkillBFreshness: B★ 1Claude Code +9 - 0.527score
code-review
sgpopov
Conducts multi-axis code review.
SkillBFreshness: B★ 1Claude Code +9 - 0.516score
resolving-merge-conflicts
sgpopov
Use when you need to resolve an in-progress git merge/rebase conflict.
SkillBFreshness: B★ 1Claude Code +9 - 0.502score
to-tickets
sgpopov
Breaks a PRD into independently-grabbable issues using tracer-bullet vertical slices.
SkillCFreshness: C★ 1Claude Code +9 - 0.502score
to-spec
sgpopov
Creates a spec through user interview, codebase exploration, and module design, then submit as a GitHub issue or save as a local markdown file.
SkillCFreshness: C★ 1Claude Code +9 - 0.497score
write-a-skill
sgpopov
Creates new agent skills with proper structure, progressive disclosure, and bundled resources.
SkillCFreshness: C★ 1Claude Code +9 - 0.497score
grill-me
sgpopov
Interviews the user relentlessly about a plan or design until reaching shared understanding, resolving each branch of the decision tree.
SkillCFreshness: C★ 1Claude Code +9 - 0.497score
react-best-practices
sgpopov
Provides React and Remix.js performance optimization guidelines.
SkillCFreshness: C★ 1Claude Code +9 - 0.497score
ubiquitous-language
sgpopov
Extracts a DDD-style ubiquitous language glossary from the current conversation, flagging ambiguities and proposing canonical terms.
SkillCFreshness: C★ 1Claude Code +9
Signals
- Stars
- 1
- Forks
- 0
- Open issues
- 0
- Last commit (this folder)
- Jun 10, 2026 (4 months ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/sgpopov/ai-kit
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from sgpopov
- 0.588score
ai-visibility
sgpopov
Measure and improve whether AI assistants (ChatGPT, Claude, Gemini, Perplexity, Copilot) recommend a brand, and fix the reasons they do not.
SkillAFreshness: A★ 1Claude Code +9 - 0.581score
implement
sgpopov
Implement work from an existing spec or set of tickets, including testing, independent review, and a commit.
SkillAFreshness: A★ 1Claude Code +9 - 0.547score
log-analyzer
sgpopov
Analyzes application, access, and structured logs for errors, trends, anomalies, and operational evidence.
SkillBFreshness: B★ 1Claude Code +9 - 0.527score
code-review
sgpopov
Conducts multi-axis code review.
SkillBFreshness: B★ 1Claude Code +9 - 0.527score
domain-modeling
sgpopov
Build and sharpen a project's domain model.
SkillBFreshness: B★ 1Claude Code +9 - 0.516score
resolving-merge-conflicts
sgpopov
Use when you need to resolve an in-progress git merge/rebase conflict.
SkillBFreshness: B★ 1Claude Code +9
Cite this page
git-guardrails-claude-code skill. Agent Mart. https://agentmart.dev/skills/sgpopov-git-guardrails-claude-code (last updated 2026-10-24)