Git Guardrails sets up a shell hook on the Bash tool in Claude Code. Each command the agent tries to run is checked against a list of dangerous git patterns, and a match is refused with a message that the agent has no authority to run it.
The skill asks whether to install for one project or all projects, copies the script, merges the hook into the settings file and tests it.
What You Get
- A hook script that blocks git push, reset —hard, clean -f, branch -D, checkout . and restore .
- A settings.json entry at project or user scope
- A customised pattern list if you ask for one
- A test run showing exit code 2 and a BLOCKED message
Common Use Cases
- Stopping an agent from pushing to a remote while you review its work
- Protecting uncommitted changes from a reset or clean
- Adding the same safety net to every project through the global settings
- Tightening or loosening the blocked list for one team
What Makes It Unique
Most safety advice for agents lives in prompts, which a model can ignore. This skill installs a deterministic hook that runs outside the model and exits with code 2, so the command never reaches the shell. The pattern list is a bash array that is easy to read and edit.
Under The Hood
The skill ships a bash script that reads the hook JSON from stdin, extracts the command with jq, and loops over a list of patterns with grep. A match prints a BLOCKED message to stderr and exits with code 2. The skill itself copies that file, runs chmod, edits a settings.json file and runs one echo test against the script. The script needs jq on the machine. Matching is by text pattern, so it checks the command string only.