The phrase "governance before generation" describes a specific enforcement posture — a choice about where in the AI development pipeline architectural constraints are applied. It is not about whether governance happens. It is about the only enforcement point that can shape AI output rather than react to it.

That distinction — shaping versus reacting — is the structural argument this page develops. The enforcement point is not a scheduling detail. It is the variable that determines whether governance is architectural infrastructure or expensive remediation.

What governance before generation actually means

Every AI coding workflow has a sequence: intent forms, agent runs, output is produced, output is reviewed, output is merged. Governance can be inserted at any point in that sequence. The question is: what happens depending on which point you choose?

Pre-generation enforcement means the governance system fires before the agent writes. The sequence becomes: intent forms, governance evaluates and injects constraints, agent runs with those constraints in context, output is produced already shaped by the constraint. The constraint influenced the proposal; it did not just evaluate it.

Post-generation enforcement — CI linting, PR review, audit tooling — means the governance system fires after the agent has already written. The sequence becomes: intent forms, agent runs (without constraint context), output is produced, governance evaluates the output, violations are flagged or blocked. The constraint evaluated the proposal; it did not shape it.

These produce structurally different outcomes. Pre-generation enforcement reduces violations at source. Post-generation enforcement catches violations after they exist. At human generation speeds, this difference is manageable — the volume of violations is low enough that post-generation catching is workable. At AI generation speeds, the difference compounds.

The enforcement point is the strategic variable. Everything else — the quality of your decision records, the precision of your retrieval, the coverage of your constraints — is multiplied or divided by where enforcement fires. Pre-generation enforcement multiplies; post-generation enforcement divides attention.

Why this problem exists in AI-native development

The enforcement-point problem is not new to software teams. Static analysis, linting, and pre-commit hooks all represent an understanding that catching violations earlier is cheaper than catching them later. The question has always been: how early can you push the enforcement point?

For human developers, the answer was: pre-commit, at most. Human developers can internalize constraints, read documentation, and apply architectural knowledge as they write. Pre-generation enforcement — injecting constraints before the developer types — was not meaningfully possible because the developer was already doing it mentally.

AI agents do not internalize constraints. They generate code based on training distribution, task prompt, and whatever context is present in the active window at generation time. If the constraint is not in that context, the agent does not apply it. It is not failure to comply; it is absence of information. The agent literally does not know the constraint exists unless it is injected.

This creates a structural opportunity that did not exist in human-paced development: the injection point before generation is now a real engineering surface. You can specify exactly what context the agent receives before writing. If architectural constraints are part of that context, they shape the output. If they are absent, the output is unconstrained by your decisions.

Enforcement point What it affects Outcome at AI scale
Pre-generation hook What the AI proposes Violations prevented at source
Pre-commit / CI lint Whether code is staged or merged Violations written, then caught — costs reviewer time
PR review Whether code is merged Violations written, reviewed, disputed, revised — highest cost
Post-merge audit Codebase at rest Violations already in production — remediation required

The table above describes a cost gradient. Every row to the right of pre-generation enforcement represents a stage where the violation already exists as written code and must be undone. The only enforcement point where the violation never exists is pre-generation. Every other point is catching something that already happened.

The common misread: treating post-generation enforcement as equivalent

Teams that have invested in strong CI pipelines and thorough code review often argue that their post-generation enforcement is functionally equivalent to pre-generation governance. The reasoning: if the CI gate catches every violation and blocks every non-compliant merge, then no violations reach production — which is the goal.

This argument holds for violation prevention at the codebase level. It does not hold at the level of review cost, developer feedback loops, or architectural drift velocity.

When the CI gate blocks a violation, someone wrote it, staged it, opened a PR, waited for CI, read the failure, understood the violation, revised the code, and re-submitted. That sequence consumed time at every step. At human generation speeds, that sequence is occasional — most PRs pass, and the violations that fail are edge cases. At AI generation speeds, that sequence fires far more frequently. The AI writes more, it writes faster, and each generation is a fresh draw from a distribution that does not know your architectural constraints unless you inject them.

Post-generation enforcement catches violations after they are written. Pre-generation enforcement prevents them from being written. The CI gate is a necessary fallback. It is not a substitute for pre-generation governance. Teams that treat CI as their primary enforcement layer will find it increasingly expensive as AI generation volume grows.

The second failure mode of post-generation-only enforcement is architectural drift velocity. When violations are caught post-generation, the agent's context does not update. The next generation starts from the same constraint-free state. The agent will produce similar violations again — not because it "learned" the wrong thing, but because its context for the next task does not include the lesson from the previous failure. Pre-generation enforcement injects that lesson into every generation. Post-generation enforcement has to reteach it through CI failures every time.

How this fits the AI SDLC

Pre-generation governance has a specific home in the AI SDLC: the hook layer, positioned between the agent runtime and the tool execution layer. This is the surface where the agent declares what it intends to do before doing it, and the governance system intercepts that intent.

In Claude Code, this is the pre-tool-use hook. Before the agent writes to a file, the hook fires with the file path and the task context. The governance system receives that signal, retrieves the decision records relevant to the file and task, formats them as constraint context, and injects them back into the agent's environment before the write proceeds. The agent writes with full constraint context. The hook is the enforcement point.

# Claude Code hook configuration (settings.json) "hooks": { "PreToolUse": [ { "matcher": "Write|Edit|MultiEdit", "hooks": [ { "type": "command", "command": "mneme inject --file $CLAUDE_TOOL_INPUT_PATH" } ] } ] }

The hook is not a wrapper around the agent. It is a pre-flight interception that surfaces context the agent did not have before the write intent was declared. The sequence: agent declares intent to write → hook fires → Mneme retrieves relevant decisions → decisions are injected → agent writes with constraint context in scope.

For teams using CI as a secondary enforcement layer, Mneme also provides a CI mode that evaluates generated code against the full decision corpus after generation — a confirmation that what reached CI is consistent with what the hook injected before generation. The CI gate is not the primary governance enforcement; it is the audit trail that confirms the pre-generation layer worked.

This two-layer architecture — pre-generation injection as the shaping layer, CI evaluation as the audit layer — is the full implementation of governance before generation. Neither layer alone is sufficient at scale. Together, they create an enforcement surface that operates at both the moment of AI intent and the moment of merge readiness.

Related concepts

Governance before generation is the enforcement posture. Three adjacent concepts describe the components that make it work:

  • Architectural governance — the system that governance before generation implements. Governance before generation is not a product; it is a design principle about where enforcement lives. Architectural governance is the full system: decision records, retrieval, injection, and verification.
  • Deterministic enforcement — the property that pre-generation enforcement must have to be auditable. If the same query against the same decision corpus can produce different constraint injections on different runs, governance is probabilistic and unauditable. Deterministic enforcement ensures the injection is consistent.
  • Claude Code integration — the specific runtime surface where pre-tool-use hooks implement governance before generation for Claude Code users. The integration is the engineering realization of the concept.