AgentStack
Browse Sign in
Browse Why AgentStack Sell Docs
Sign in
SKILL verified Apache-2.0 Self-run

Git Guardrails Claude Code

skill-officialunofficial-skills-git-guardrails-claude-code · by officialunofficial

Install a Claude Code hook that stops destructive git commands (push, reset --hard, clean, branch -D, and friends) before they run. Use when the user wants to guard against dangerous git operations, add git safety hooks, or block git push/reset inside Claude Code.

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

Install

$ agentstack add skill-officialunofficial-skills-git-guardrails-claude-code

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

View the full security report →

Verified badge

Passed review? Show it. Paste this badge into your README, it links to the public security report.

AgentStack Verified badge Links to your public security report.
[![AgentStack Verified](https://agentstack.voostack.com/badges/verified.svg)](https://agentstack.voostack.com/security/report/skill-officialunofficial-skills-git-guardrails-claude-code)

Reliability & compatibility

Security review passed
0 installs to date
no reviews yet
2mo ago

Declared compatibility

Claude CodeClaude Desktop

Compatibility is declared by the source manifest. End-to-end runtime verification is coming, see below.

Preview Execution monitoring

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 →
Are you the author of Git Guardrails Claude Code? 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

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 push in any form, including --force
  • git reset --hard
  • git clean -f and git clean -fd
  • git branch -D
  • git checkout . and git 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.

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.