2026-10-13 · ← News
When an agent ignores a rule, put it in a pre-commit hook
Instead of adding another instruction to AGENTS.md, Geoffrey Huntley wrote a pre-commit hook that blocks code bypassing his diagnostics library and sends the agent a corrective prompt. It draws a practical boundary between advice for a model and a rule enforced by the system.
The image could not be loaded.
Geoffrey Huntley has described a simple way to contain coding-agent drift. When an agent bypassed his diagnostics library and called observability modules directly, he did not merely add another paragraph to AGENTS.md. He wrote a pre-commit hook that rejects the change and returns a prompt asking the agent for the required correction.
The rule moved from a document into the path to a commit
The hook inspects the git diff for direct calls to observability modules that bypass Huntley's diagnostics layer. A violation fails the commit and gives the agent specific feedback. Huntley says this brought the outcome to ten out of ten.
The example comes from a broader essay based on four episodes of conversations with Josh Wulf about loop engineering. Huntley also describes 48 hours of diagnostics refactoring and argues that instructions alone drift across subsequent model runs. The pre-commit hook turned a variable suggestion into a repeatable check.
Teams need to separate preferences from invariants
AGENTS.md is useful for context, conventions and an explanation of intent. Critical architectural boundaries should not depend on whether a model recalls the right paragraph from a prompt. If an application must use one diagnostics layer, that requirement belongs in static analysis, a test or a hook.
This changes how a development team works with an agent. A human does not need to inspect every line if the system can mechanically reject a forbidden pattern and feed the correction back into the loop. Review can then focus on intent, risk and issues that cannot be expressed as a simple rule.
One regex cannot protect architecture or intent
A hook is only as good as its description of the forbidden behavior. An agent may cross the same boundary through an indirect call, a new wrapper or a configuration change that the check does not recognize. An overly broad rule will instead block legitimate changes and create a queue of false alarms.
Huntley also recommends challenging old skill packs and AGENTS.md because newer models may respond differently to the same instructions. Without evals over real traces, a team cannot know whether it is helping the agent or quietly tuning it downward. A mechanical gate enforces one invariant, not the overall quality of the system.
Escapes caught and missed will show whether the loop works
Teams should track how many violations the hook stopped, how many escaped and how many legitimate commits it blocked by mistake. They should also measure whether the agent fixes the code on its next step or merely searches for another path around the check.
A strong agentic workflow will have several such gates: behavioral tests, architecture rules, security constraints and production telemetry. Instructions guide the model. Executable rules decide what can actually pass.
Lilith's verdict
When an agent bypasses diagnostics, another paragraph in the manual is a sign beside an open window. A pre-commit hook actually shuts the window and sends the culprit back to repair the damage.
I keep the external link at the end. First, a concise explanation here — no hunting across someone else's site.
Original source ↗ ↗