Skip to content
Agentmart
Submit a tool

git-guardrails-claude-code

Configura hooks do Claude Code para bloquear comandos git perigosos (push, reset --hard, clean, branch -D, etc.) antes que sejam executados.

Skill by hcb2019

IndexedMIT★ 1
Write a review

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/hcb2019-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.

We use your email only for this newsletter. Privacy

About

Configura hooks do Claude Code para bloquear comandos git perigosos (push, reset --hard, clean, branch -D, etc.) antes que sejam executados. Use quando o usuário quiser prevenir operações git destrutivas, adicionar hooks de segurança git ou bloquear git push/reset no Claude Code.

Use cases: agent-building

No 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
Configura hooks do Claude Code para bloquear comandos git perigosos (push, reset --hard, clean, branch -D, etc.) antes que sejam executados. Use quando o usuário quiser prevenir operações git destrutivas, adicionar hooks de segurança git ou bloquear git push/reset no Claude Code.
License
MIT
Instructions
92 lines in SKILL.md · view on GitHub

Before installing

  • Ships executable scripts

Agent Skills spec issues

  • name: "git-guardrails-claude-code" does not match folder "protetor-git"

Files (2)

  • SKILL.md
  • block-dangerous-git.sh · scripts/

SKILL.md (first lines)

# Set Up Git Guardrails

Configure 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 -f` / `git clean -fd`
- `git branch -D`
- `git checkout .` / `git restore .`

When blocked, Claude sees a message stating it is not authorized to access those commands.

## Steps

### 1. Ask about scope

Ask the user: install for **this project only** (`.claude/settings.json`) or **all projects** (`~/.claude/settings.json`)?

### 2. Copy the hook script

The packaged 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 the existing `hooks.PreToolUse` array — do not overwrite other settings.

### 4. Ask about customization

Ask the user whether they want to add or remove patterns from the blocklist. 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 hcb2019/claude-code-skills, MIT.

More from hcb2019/claude-code-skills

Signals

Stars
1
Forks
0
Open issues
0
Last commit (this folder)
Jun 8, 2026 (4 months ago)

From GitHub (fetched Oct 24, 2026).

Details

License
MIT
First seen
Oct 24, 2026
Last checked
Oct 24, 2026

More from hcb2019

Cite this page

git-guardrails-claude-code skill. Agent Mart. https://agentmart.dev/skills/hcb2019-git-guardrails-claude-code (last updated 2026-10-24)