setup-git-guardrails
Installation
SKILL.md
Setup git guardrails
Puts a human decision in front of destructive git commands, so the human approves each one instead of the agent running it unchecked. Routine work (commits, pushes to feature branches, dry runs) passes. The setup is agent-agnostic: two layers, and no harness is assumed.
- Portable layer: a git
pre-pushhook. It holds for any agent and any person, but git has no hook for local commands such asreset --hard, so it covers pushes only. - Agent layer: scripts/guard-git.py, a command guard, wired into each harness's own way of intercepting a command. It reads the command text, so it sees chains (
&&,;,|,&),sudo,xargs,command,bash -c,$(...), andgit -C.
Guard levels
Each level includes the one above it.
| Level | Guards |
|---|---|
| 1. Shared history | A push to a protected branch (main, master, the remote's default branch, and any the user adds), a plain force push (-f, --force, a + refspec), a push that deletes or mirrors (--delete, :branch, --mirror, --all, --prune), --no-verify on a push. --force-with-lease and --dry-run pass |
| 2. Local work | reset --hard, clean -f (not a dry run), branch -D, checkout or switch that discards changes (., -- <paths>, -f, --discard-changes), restore on the working tree (--staged alone passes), stash drop and clear, worktree remove --force, reflog expire and delete, gc --prune, prune |
| 3. Strict | Every push, plus rebase, reset in any form, commit --amend, any branch or tag deletion, filter-branch, filter-repo, update-ref |