Skip to content

The Governance Loop

How Archgate governs AI-assisted development through a continuous loop of prevention, detection, and learning — turning every mistake into a permanent, automated rule.

AI coding agents are fast but ungoverned. Without explicit constraints, they produce code that works but does not conform to your architecture, security policies, or conventions — turning every generated file into a review burden. The governance loop is Archgate’s answer: a continuous cycle that makes correctness happen by construction where possible, and by detection everywhere else.

The loop has three movements. Each one catches what the previous one missed, and the last one feeds back into the first — so the system gets stronger over time rather than drifting.

Architecture Decision Records (ADRs) encode your team’s decisions as durable, versioned documents — and, where the rule is mechanically verifiable, as executable rules. Before an AI agent writes a line of code, it reads the applicable ADRs as context. The Decision and Do’s and Don’ts sections shape what the agent generates, so a large share of compliance is achieved before the first keystroke. This is correctness by construction.

The same documents serve humans. An ADR explains why a decision was made and what trade-offs it carries, so prevention is not a black box — it is a shared, auditable record of intent.

Prevention is never perfect. The detection layer validates the output: the rules attached to each ADR run automatically and report violations with file paths and line numbers. Detection runs in three places:

  • In the editor, after the AI agent makes a change, via the editor plugins.
  • On pre-commit, as a fast local gate before code is staged.
  • In CI, as the hard gate that blocks non-conforming code from merging.

Detection is deterministic, free, and runs in milliseconds. It catches roughly 70–80% of ADR rules without spending a single token. For the subjective remainder — architectural fit, judgment calls a linter cannot make — the reviewer skill applies AI review against the same ADRs.

Every violation that detection catches — and every issue a human reviewer flags — is a signal that the governance base has a gap. The lessons-learned skill reads the session, identifies the pattern, and proposes a new ADR or an extension to an existing one (always delegating the actual writing to the adr-author skill).

The new rule flows back into prevention. The loop closes.

Underneath the loop sit two distinct enforcement mechanisms. They differ in cost, speed, and what they can evaluate:

LayerMechanismCostSpeedBest for
Automated checksLint rules, file assertions, import analysisFreeMillisecondsThe 70–80% of rules a machine can verify
AI reviewThe reviewer skill checks code against ADRsTokensSecondsSubjective quality, architectural fit

The strategic goal is to maximize the first layer over time, reserving AI review for what machines genuinely cannot evaluate. The learning movement is what makes that shift happen — it continuously converts judgment calls into deterministic rules.

The loop describes what happens; two operating modes describe who drives it.

  1. Deterministic mode (CI and pre-commit). No AI involved. archgate check runs in pre-commit hooks and CI pipelines and blocks non-compliant code. This is the hard gate — the same check runs identically on every machine and in every pipeline.

  2. AI-assisted mode (editor plugins). The editor plugins wire the loop into your AI coding agent. The developer agent orchestrates the workflow — read ADRs, write code, validate, capture — invoking the skills at each step.

The critical insight: the CLI commands and the plugin’s tools are passive capabilities. The workflow — the ordering, the gates, the roles — lives in the plugin’s agent and skills. The CLI runs the deterministic checks anywhere, fully offline; the plugins add the AI-assisted half of the loop on top.