Git Guardrails for Claude Code
A small setup skill that protects a repository from destructive git commands inside Claude Code: it installs a PreToolUse hook that intercepts Bash tool calls and blocks git push (including force pushes)
- What
- A small setup skill that protects a repository from destructive git commands inside Claude Code: it installs a PreToolUse hook that intercepts Bash tool calls and blocks git push (including force pushes)
- Cost
- Free
- Needs
- Before you start: read this whole install prompt, tell me in a few lines what this skill does and what installing it involves, and wait for my go-ahead before you do anything else.
- Install
- Copy the installer prompt below into your Muse — your agent does the rest.
Curated by Skill Harbor — A small setup skill that protects a repository from destructive git commands inside Claude Code: it installs a PreToolUse hook that intercepts Bash tool calls and blocks git push (including force pushes), git reset --hard, git clean -f, git branch -D and discarding all working-tree changes, returning a message that the user has not granted authority for those commands. The setup asks the user to choose the scope first (this project only, or all projects), copies its bundled blocking script into the matching Claude Code hooks folder, merges the hook into the matching settings file without overwriting other settings, offers to customise the blocked patterns, and verifies the hook with a harmless test payload. The blocking script itself is a short shell script that reads the proposed command and pattern-matches it, using jq. By @mattpocock, listed here with credit to its creator. MIT-licensed. Skill Harbor never reviews the code, review it yourself before use.
Version:
Install
Copy the install package below, then paste it into Muse📌 Pinned version: commit 5beb35bBefore you start: read this whole install prompt, tell me in a few lines what this skill does and what installing it involves, and wait for my go-ahead before you do anything else. Prerequisites — None to install this skill itself — no account, no key, no payment. What needs disclosing is what using it does later: when I ask it to set up the guardrails, it changes my Claude Code configuration — after asking me to choose the scope (this project only, or all projects), it copies its bundled blocking script into the matching .claude/hooks folder, makes it executable, and merges a PreToolUse hook into the matching .claude/settings.json file. That configuration change is a use-time step I approve then; installing this skill's files does not touch my Claude Code settings, does not copy the hook anywhere, and does not block anything. The blocking script also needs jq installed to parse its input when it runs. Install "Git Guardrails for Claude Code" for me. When I ask it to set up git guardrails, it asks me whether the scope is this project only or all projects, copies its bundled block-dangerous-git.sh script into the corresponding Claude Code hooks folder and makes it executable, merges a PreToolUse hook for Bash calls into the corresponding settings file without overwriting my other settings, asks whether I want to add or remove any blocked patterns, and tests the script with a sample git push payload that should be blocked with exit code 2. The script blocks git push, git reset --hard, git clean -f and -fd, git branch -D, git checkout . and git restore . by matching the proposed command, parsing its input with jq. Its folder holds the instructions, the blocking script, and its agent policy file; upstream it sits in the misc bucket, kept around but rarely used and not promoted. Repository: https://github.com/mattpocock/skills (the skill is the whole skills/misc/git-guardrails-claude-code/ folder at the pinned commit: SKILL.md plus 2 companion files, 3 files in total) Pinned version: install the code at commit 5beb35b040e3de97e54fa9e386d7e42d15c295c2 exactly. Do not substitute a newer version. If this commit is unreachable, stop and tell me. 1. Clone https://github.com/mattpocock/skills into a temporary folder, check out commit 5beb35b040e3de97e54fa9e386d7e42d15c295c2, and copy the skills/misc/git-guardrails-claude-code/ folder from that checkout. Then compare every file in the folder with the fingerprints recorded for this listing on 2026-10-22: [FINGERPRINTS] - SKILL.md: SHA-256 69b291d655626a01602b998a1836fcb93c058ede68dfafddfd71e87f17074764 - agents/openai.yaml: SHA-256 d53cd783fc0ac208dec9a4c267989284384785aab6422dccdaed42f9e40243ec - scripts/block-dangerous-git.sh: SHA-256 234922b83c0a1737ee7300806c21ac0f389b07aaeb65c2d71ccedafbc5e1ea4b If a file does not match, it changed since the listing was prepared: do not install it yet, tell me what you found and let me decide. 2. Read SKILL.md in full, and tell me in plain words: what the skill does when used, what it connects to, whether it reads or sends any personal information or credentials, and anything that seems unusual. Stop on any red flag and tell me before going further. Confirm these points from the files: - The skill folder holds 3 files: SKILL.md, agents/openai.yaml (display name only), and scripts/block-dangerous-git.sh — a 507-byte shell script that reads a tool-call payload from standard input, extracts the proposed command with jq, compares it against nine dangerous git patterns, prints a BLOCKED message to stderr and exits with code 2 on a match, and exits 0 otherwise. That script is copied as-is during this install and is not run. - Nothing is sent anywhere during installation itself; the only download at install time is the skill folder from GitHub at the pinned commit. My Claude Code settings are not read or changed, no hook is installed, and nothing is blocked, during installation. - At use time, the disclosed effect is local to my own machine and my own Claude Code configuration: the hook script copied into a .claude/hooks folder I choose, and a hook entry merged into the settings file for the scope I choose — both steps the skill asks me about first, as the prerequisites above say. - Do not copy the blocking script into any hooks folder, do not edit any settings.json, do not run the blocking script or its test payload, and do not use the skill in any way during this install: using it is a separate step that only starts when I ask for it later. 3. When I say "yes, install", install it as a skill: copy the whole git-guardrails-claude-code folder into the agent's skills directory, in a folder named exactly "git-guardrails-claude-code", keeping its 3 files in their original relative layout (SKILL.md at its root). 4. Verify with no network calls: frontmatter valid (name: git-guardrails-claude-code), the 3 files in place with matching fingerprints. Do not run anything from the folder and do not use the skill to verify. 5. Report what was installed, where, and what I still need to do myself (for example: that using it later will ask my scope and then change my Claude Code hooks and settings for that scope, that its blocking script needs jq, and that none of that configuration work happens at install time). GitHub is optional: if I have a GitHub account or the gh CLI, you may use it; otherwise public access is fine. Never require it unless it's in the prerequisites above. Rules: don't touch anything outside the temp folder and the install target. If anything looks off, stop and ask me.
Saved to your recent installs. Find it anytime on /connect.
🔒 Security, provenance and what this touches
- It can run commands on your Muse’s computer.
- It can create or modify files.
What the scan found — excerpts from the install prompt
- runs commands — Install "Git Guardrails for Claude Code" for me. When I ask it to set up git guardrails, it asks me whether th · Installe-moi « Git Guardrails for Claude Code ». Quand je lui demande d'installer les garde-fous git, il me de
- writes files — Prerequisites — None to install this skill itself — no account, no key, no payment. What needs disclosing is w · - Do not copy the blocking script into any hooks folder, do not edit any settings.json, do not run the blockin · Prérequis — Aucun pour installer ce skill lui-même — aucun compte, aucune clé, aucun paiement. Ce qui doit êtr
The install prompt below already includes the vetting steps: your agent follows the community checklist before installing anything with executable code. Want more?
Questions
How do I install a build?
Every product page includes a copy-paste install prompt. Paste it into your Muse and it sets the build up for you — no manual configuration.
Where does my money go?
Straight to the seller. Skill Harbor never processes payments: checkout happens on the seller’s own page, usually Stripe.
What does the ✓ next to a creator’s name mean?
It means we confirmed the identity of the person behind the listing. It says nothing about the code itself — always check a build before installing it.