Skip to content
Agentmart
Submit a tool

git-guardrails

Set up guardrails that block dangerous git commands (push, reset --hard, clean, branch -D, etc.) before they run.

Skill by netname

IndexedMIT
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/netname-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.

We use your email only for this newsletter. Privacy

About

Set up guardrails that block dangerous git commands (push, reset --hard, clean, branch -D, etc.) before they run. Use when the user wants to prevent destructive git operations, add git safety guardrails, or block git push/reset.

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

What's inside

Skill name
git-guardrails
Description
Set up guardrails that block dangerous git commands (push, reset --hard, clean, branch -D, etc.) before they run. Use when the user wants to prevent destructive git operations, add git safety guardrails, or block git push/reset.
License
MIT
Metadata
upstream: mattpocock/skills · invocation: model · adapted-for: pi · upstream-path: skills/misc/git-guardrails-claude-code · upstream-commit: c55ee46073ed923f86ce59a5eb3b6d895095d1b7
Instructions
63 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)

# Set Up Git Guardrails

The guardrail ships with this package as a Pi extension: `extensions/git-guardrails.ts`. It hooks `tool_call`, and a `bash` call whose command matches a dangerous-git pattern is blocked before it executes, with the reason returned to you. Nothing else is affected.

The extension is inert until the user opts in, so installing this package never changes anyone's git behaviour by surprise. Opting in is writing one small JSON file; the guardrail then applies in that scope. The config file is re-read on every `bash` call, so an opt-in, an `"enabled": false`, or a `patterns` change takes effect immediately; the default pattern list in the sidecar is read once when the session loads, so editing *that* file needs a new session or `/reload`.

## 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, the reason reads: `BLOCKED: '<command>' matches dangerous pattern '<pattern>'. The user has prevented you from running this command.`

## Steps

### 1. Ask scope

Ask the user: opt in for **this project only** or **all projects**?

- **Project**: `.pi/git-guardrails.json` in the repo root.
- **Global**: `~/.pi/agent/git-guardrails.json`.

### 2. Write the opt-in file

Write the chosen file (create `.pi/` if needed):

```json
{
  "enabled": true
}
```

That is the whole opt-in. Leave `patterns` out and the guardrail uses the default list from the skill's own [scripts/block-dangerous-git.sh](scripts/block-dangerous-git.sh), which the extension reads at load time. Add a `patterns` array only if the user wants to replace the default list.

If the file already exists, merge `"enabled": true` into it rather than overwriting other keys.

### 3. Ask about customization

Ask if the user wants to change what is blocked.

- **Add or remove patterns**: edit the `DANGEROUS_PATTERNS` array in [scripts/block-dangerous-git.sh](scripts/block-dangerous-git.sh) — that file is the single source of truth for the default list, and both the extension and the standalone check use it.
- **Per-project override**: put a `patterns` array in that project's `.pi/git-guardrails.json`. When present it replaces the default list for that scope.

Patterns are regular expressions matched anywhere in the command, the same semantics upstream used.

### 4. Verify

Check the pattern list standalone by passing a command to the sidecar:

```bash
bash skills/misc/git-guardrails/scripts/block-dangerous-git.sh "git push origin main"
```

It prints `BLOCKED: …` and exits 1 for a match, and exits 0 for a safe command such as `git status`.

Then confirm the extension is live: ask the user to run a command that should be blocked, or note that the next matching `bash` call in this session is blocked with the reason above.

To turn the guardrail off without deleting the file, set `"enabled": false`; for one session, set `PI_GIT_GUARDRAILS=off`.

From netname/pi-adapted-mp-skills, MIT.

More from netname/pi-adapted-mp-skills

Signals

Stars
0
Forks
0
Open issues
0
Last commit (this folder)
Sep 19, 2026 (1 month ago)

From GitHub (fetched Oct 24, 2026).

Details

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

More from netname

Cite this page

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