AgentStack
SKILL verified MIT Self-run

Git Guardrails

skill-canvas-xxx-agent-skills-git-guardrails · by ntwrcht

Installs Claude Code PreToolUse hooks that block dangerous git commands before execution. Use when setting up local or global guardrails for git push, force push, reset --hard, clean, branch deletion, checkout ., or restore .

No reviews yet
0 installs
7 views
0.0% view→install

Install

$ agentstack add skill-canvas-xxx-agent-skills-git-guardrails

✓ scanned · ✓ verified — works with Claude Code, Cursor, and more.

Security review

✓ Passed

No 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.

Are you the author of Git Guardrails? Claim this listing to set pricing, connect Stripe payouts, and keep 70% of every sale.
Sign up to claim

About

Git Guardrails for Claude Code

Set up a Claude Code PreToolUse hook that blocks high-risk git commands before Claude executes them.

When to Use

Use this skill when the user wants Claude Code git safety hooks, local project guardrails, global guardrails, or protection from destructive commands such as push, force push, hard reset, clean, branch deletion, checkout dot, or restore dot.

This skill installs Claude Code hooks only. For ordinary repository policy, server-side git hooks, GitHub branch protection, or CI rules, provide separate guidance.

Artifacts

  • Produces: .claude/settings.json (hook entries merged in)
  • Consumes: nothing

Core Rule

Preserve existing Claude settings. Merge hook entries; never overwrite unrelated settings, hooks, or user scripts.

Blocked Commands

The bundled hook blocks:

  • git push, including force-push variants.
  • git reset --hard.
  • git clean -f and git clean -fd.
  • git branch -D.
  • git checkout ..
  • git restore ..

Workflow

  1. Choose scope. Ask for project-only .claude/settings.json or global ~/.claude/settings.json unless the user already specified it.
  2. Copy the hook. Use [scripts/block-dangerous-git.sh](scripts/block-dangerous-git.sh). Copy it to .claude/hooks/block-dangerous-git.sh for project scope or ~/.claude/hooks/block-dangerous-git.sh for global scope.
  3. Make it executable. Run chmod +x .
  4. Merge settings. Add a hooks.PreToolUse entry with matcher Bash and command pointing at the hook. Keep existing hooks and settings.
  5. Customize if requested. Edit the copied script only for requested additions or removals.
  6. Verify. Pipe a blocked command payload into the hook and confirm exit code 2 with a BLOCKED: stderr message.

Settings Snippets

Project command:

"command": "\"$CLAUDE_PROJECT_DIR\"/.claude/hooks/block-dangerous-git.sh"

Global command:

"command": "~/.claude/hooks/block-dangerous-git.sh"

Verification command:

printf '%s\n' '{"tool_input":{"command":"git push origin main"}}' | 

Operating Rules

  • Ask before choosing local versus global scope when unspecified.
  • Read existing settings before editing them.
  • Preserve unrelated JSON keys and hook entries.
  • Do not weaken blocked patterns unless the user explicitly asks.
  • Report the installed path, settings path, and verification result.

Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

Install and usage instructions live in the source repository linked above.

Reviews

No reviews yet — be the first.

Versions

  • v0.1.0 Imported from the upstream source.