A← Index

git-guard

Git hooks that hold coding agents to the same rules as people.

RoleSolo: design & build
TypeDeveloper tool · agent guardrail
StackRust · git hooks
SourcePrivate

IWhy I built it

Several coding agents commit for me at the same time, across many repositories and three git identities: one personal and two for work. Instructions in a prompt are not enough. An agent can forget them, and so can I.

One wrong commit can leak a secret, land on main without review, or carry the wrong author. A wrong author once blocked a client deploy on my personal hosting account. git-guard moves these rules from the prompt into git itself.

IIWhat it blocks

Credentials
pre-commit blocks a staged line that looks like a credential. The match is masked in the output, so the secret does not reach a log.
The base branch
Commits and pushes to the base branch are blocked. Every change goes through a branch and a pull request.
The wrong identity
Each repository gets its identity from its checkout path, then from the owner of its remote. A commit with another email is blocked.
Foreign commits in a push
pre-push blocks pushed commits that another identity authored.

IIIDesign choices

It cannot lapse. Global hook stubs point to the binary. If the binary is missing, the stub blocks the commit instead of letting it through.

It respects each repository. A global hooks path hides a repository's own hooks. After its own check passes, git-guard runs them.

It has explicit escape hatches. A repository that automation commits to sets one config flag. A one-off commit uses an environment variable that prints a warning.

It feeds the other tools. git-guard identity gives the worktree tool and the agent hooks the right identity, and git-guard doctor checks a machine. The binary is about 520 lines of Rust.

SignedArjun