Bench / Reading room

Definition

What is AI code governance?

AI code governance is the practice of subjecting changes proposed by an AI coding tool to declared, binding rules before those changes are applied, and recording every ruling as durable evidence. It differs from code review in when it happens and in what it produces: review evaluates code that already landed or is about to merge, while governance adjudicates a change before it touches a file and leaves a verifiable record of the decision.

Holdings

  • Governance acts before a change lands; review reacts after code exists.
  • Three properties separate governance from advice: adversarial challenge, binding authority, and durable evidence.
  • A self-check by the model that wrote the code is an opinion, not governance.
  • Honest governance declares what it does not cover; a tool that hides its gaps is not a governance tool.
  • Bench implements this model for Claude Code as an open-source PreToolUse hook, MIT licensed.

Why AI-written code needs governance

AI coding tools ship code no one argued with. When an agent writes a function, nothing inherent to the tool stops it from swallowing errors silently, leaking credentials, or creeping past the scope of the task. Self-verification is a step forward, but a model checking its own work carries no adversarial pressure, no authority to refuse, and no record that outlives the session.

The volume problem makes this worse, not better. An engineer can meaningfully review a colleague's pull request. The same engineer supervising an agent that proposes dozens of edits per hour rubber-stamps most of them. Governance moves the argument to where the volume is: every single proposed change, adjudicated automatically, before it lands.

The three properties of governance

  1. Adversarial challenge. Someone whose job is to find fault examines the change against the rules. Not a linter matching patterns, and not the authoring model grading itself: an independent examination whose incentive is to surface violations.
  2. Binding authority. The verdict is enforced, not advisory. A change that violates the rules is blocked before it applies, with the reasoning stated. A warning that can be ignored is advice.
  3. Durable evidence. Every ruling is recorded in a form that can be verified later and cannot be quietly edited. If the record can be rewritten, the record proves nothing.

Remove any one of these and the system degrades into something else: challenge without authority is commentary, authority without evidence is arbitrary, and evidence without challenge is a changelog.

Governance, review, and guardrails compared

PropertyCode reviewGuardrails / lintersAI code governance
When it actsAfter code existsBefore or after, pattern-basedBefore the change lands
JudgmentHuman, contextualStatic rules, no argumentAdversarial argument, then a ruling
AuthorityAdvisory until merge gateOften overridableBinding; violations are blocked
RecordPR commentsLogs, if keptTamper-evident ledger
Best forDesign and architecture judgmentKnown bad patterns at scaleHigh-volume AI-authored changes

These are complements. Governance does not replace human review of design decisions, and a linter still catches what a linter catches. Governance covers the layer neither reaches: an enforced, recorded ruling on every AI-proposed change. For a fuller comparison, see AI code review vs AI code governance.

What honest governance admits

Every governance system has a perimeter, and the honest ones declare it. A hook-based system governs the tools it hooks and nothing else: files written through shell commands or third-party plugins can bypass it entirely. Claiming total coverage is the fastest way to make a governance tool untrustworthy. The guarantee worth making is narrower and real: changes made through the governed path were adjudicated and recorded.

How Bench implements it

Bench is an open-source implementation of this model for Claude Code, MIT licensed and built on Python 3.11+. It intercepts Claude Code's file-writing tools through a PreToolUse hook. Each proposed edit is challenged by one model, defended by another, and ruled on by a third against a declared constitution of eight constraints. The verdict, PASS or VETO, binds: a vetoed change never touches the file. Every ruling is appended to a SHA-256 hash-chained ledger, and when the pipeline itself fails, the change is denied. Governance that cannot render a verdict is a wall, not an open gate.

The source, the constitution file, and the full procedure are public: github.com/Nuralyn/Bench.