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-push hook. It holds for any agent and any person, but git has no hook for local commands such as reset --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, $(...), and git -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

Steps

Installs
44
Repository
dyrits/skills
First Seen
Sep 17, 2026