Geoffrey Huntley's Pre-Commit Hook Enforces Coding Agent Rules
Quoting Geoffrey Huntley
Instructions in AGENTS.md are advisory; a git pre-commit hook turns them into a hard gate the agent cannot bypass, closing the gap between documented and enforced conventions. Developers running Claude Code, Cursor or similar coding agents can adapt this pattern to any team rule they want enforced automatically. It is a concrete alternative to prompt-based guardrails that quietly degrade over time.
Engineer Geoffrey Huntley describes a technique for making coding agents reliably follow project conventions: instead of relying on AGENTS.md instructions, which can drift, he writes a pre-commit hook that inspects the git diff for direct calls to observability modules bypassing his diagnostics library. If the check fails, the commit is blocked and a prompt is injected telling the agent to use the diagnostics library. He reports this moved compliance from inconsistent to ten out of ten. The quote appears in Simon Willison's 13 Oct 2026 post on what work remains once nobody types code by hand.
Quoting Geoffrey Huntley
If the agent isn't using my diagnostics library, I could introspect and update AGENTS.md, but there's still a delta, and it'll drift. Instead, I write a pre-commit hook that checks the git diff for direct calls to observability modules that bypass my diagnostics module. Boom: fail the commit, inject a prompt telling the agent to use the diagnostics library. All of a sudden it's ten out of ten. — Geoffrey Huntley , nobody should type code by hand anymore. here's what's left. Tags: coding-agents , generative-ai , git , agentic-engineering , ai , geoffrey-huntley , llms