git-guardrails-claude-code
An agent skill by mattpocock, from mattpocock/skills. Tags: access-control, automation, claude-code, git, security.
What it does
Set up Claude Code hooks to block dangerous git commands (push, reset --hard, clean, branch -D, etc.) before they execute. Use when user wants to prevent destructive git operations, add git safety hooks, or block git push/reset in Claude Code.
Install
With the skills CLI, which installs into Claude Code, Codex, Cursor and other agents:
npx skills add mattpocock/skills --skill git-guardrails-claude-code
Or copy the skill folder into Claude Code's skills directory by hand (~/.claude/skills for every project, or .claude/skills inside one):
git clone --depth 1 https://github.com/mattpocock/skills
cp -r skills/skills/misc/git-guardrails-claude-code ~/.claude/skills/git-guardrails-claude-code
Safety box score
Grade B, low risk: 11 of 100 risk points, rated 2026-10-15. The grade rates what the skill and its scripts can reach on the machine of whoever installs it, across eight categories from shell execution to secrets access. How the score works.
This skill installs a local Claude Code pre-tool hook that blocks a short list of dangerous git commands before they run. It only touches Claude config/hooks and executes a small bash script, with the main risks being local file changes, broad global scope if chosen, and some overblocking from substring-based matching.
| Category | Level | Why |
|---|---|---|
| Code & shell execution | 1 (low) | It installs and runs a local hook script (`#!/bin/bash`) and makes it executable with `chmod +x`, but the script only inspects command text and exits. |
| Network access | 0 (none) | No downloads or remote endpoints are used; the files shown contain no `curl`, `wget`, or external network calls. |
| Filesystem reach | 2 (moderate) | It copies a script into `.claude/hooks/block-dangerous-git.sh` or `~/.claude/hooks/block-dangerous-git.sh` and edits `.claude/settings.json` or `~/.claude/settings.json`, which can affect one project or all projects. |
| Secrets & credentials | 0 (none) | The skill does not reference tokens, keys, `.env` files, browser sessions, or other credential stores. |
| Privilege & persistence | 0 (none) | It does not ask for sudo, install services, change shell startup files, or make system-wide OS changes; it only updates Claude-local config. |
| Instruction hijack surface | 0 (none) | There is no prompt injection, hidden text, or instruction to ignore safeguards; the hook uses fixed blocked patterns and plain setup steps. |
| Irreversible actions | 0 (none) | The skill does not push, delete, deploy, or send anything itself; it blocks `git push`, `git reset --hard`, `git clean -f`, and similar commands before execution. |
| Transparency | 0 (none) | All shipped files are plain text shell/markdown/YAML; there are no binaries, base64 blobs, or remotely fetched installers. |
Before installing
- Decide whether you really want global scope (`~/.claude/...`) or project-only scope (`.claude/...`).
- Read `scripts/block-dangerous-git.sh` and confirm the blocked list matches your workflow.
- Verify `bash` and `jq` are available in the environment where Claude Code will run.
- If you already have `.claude/settings.json`, check the merge so existing hooks are not overwritten.
Rated 2026-10-15 by an automated review of 3 files from the skill's repository.
Source
- Repository
- mattpocock/skills (all skills from this repository)
- Path
- skills/misc/git-guardrails-claude-code/SKILL.md
- Branch
- main
- Updated
- 2026-10-05
Related skills
- agentic-actions-auditor — Audits GitHub Actions workflows for security vulnerabilities in AI agent integrations including Claude Code Action, Gemini CLI, OpenAI Codex.
- agents-connect — Use when connecting your agent to external APIs, tools, or services via Gateway, or restricting tool access with Cedar policies.
- agents-harden — Use when preparing your agent for production — IAM scoping, inbound auth (JWT, SigV4), secrets management, cold start optimization, session lifecycle.
- app-platform-sandbox — Create and manage isolated container sandboxes for AI agent code execution.
- aws-auth — Adds user authentication to web and mobile apps with Amazon Cognito (user pools and identity pools) and the AWS Amplify client auth libraries.
- aws-iam — Provides verified corrections for IAM behaviors that AI agents frequently get wrong — policy evaluation edge cases, trust policy gotchas, STS session limits.