AI code governance

AI code governance in loop engineering

Most of the code in a modern repo is now written by an agent, reviewed by a person who didn’t write it, and merged under time pressure. The review step was designed for a world where a human typed every line. It no longer fits.

Loop engineering is the practice that grew up around this. AI code governance is what keeps it from producing code nobody can stand behind.

What loop engineering is

Loop engineering is the work of designing and running the cycle an AI coding agent goes through: prompt, generate, check, fix, repeat. The engineer’s job moves from writing code to shaping that cycle. Which rules the agent gets. Which checks run before a change is accepted. What gets recorded when it is.

The loop runs in Cursor, Claude Code, Windsurf, Lovable, Replit and wherever else an agent can edit files and open pull requests. Every one of those surfaces is a place where code enters your repo without a person reading it first.

What AI code governance means

AI code governance is the set of standards, checks and records that decide whether AI-generated code is fit to ship, and that prove the decision was made.

It answers 4 questions:

  1. What standards does this code have to meet?

  2. Was it checked against them before it was accepted?

  3. What was the result, and was anything fixed?

  4. Can I show that record to an auditor, a customer or a security team 6 months from now?

Code review alone doesn’t answer them. A reviewer can approve a change and leave no trace of what was checked. A model can review its own output and give a different opinion on the second run.

Key aspects

Governance inside the loop, not after it

A check that runs the day after the merge is a report. A check that runs while the agent is still editing is a control. The agent gets the finding, fixes it, and the corrected code is what reaches the pull request.

Deterministic checks

The same code against the same rule has to give the same verdict every time. That’s what makes a result defensible. An LLM asked to review a file will give a good answer, then a slightly different one, then a third. You can’t build a compliance record on that.

A standard the whole organization shares

Skills files and rules files in each developer’s IDE are useful, and they drift. Governance needs a single set of rulesets that every agent, every developer and every pipeline checks against, owned centrally.

An external record

Every check, every finding and every fix registered outside the agent’s context, with which client called it and when. The agent’s chat history is not an audit trail.

Coverage of the stacks you actually run

JavaScript, TypeScript, Python, PHP, the frameworks on top of them, the prompts that drive the agent. Governance that covers one language is a gap, not a policy.

Why it matters

Three things have changed at once.

Volume

An agent can produce a week of code in an afternoon. Review capacity hasn’t grown to match, so more changes ship with less scrutiny.

Accountability

When an agent introduces a SQL injection or leaks a secret, the person who accepted the change is still responsible. “The model wrote it” is not a defense a CISO or a regulator accepts.

Compliance

ISO 27001, SOC 2 and the EU AI Act all expect evidence that code was checked against a defined standard. Agent-generated code without a record of checks is a finding waiting to happen.

The cost of getting this right is small. A check that runs in the loop takes seconds. The cost of getting it wrong is a production incident traced back to code that nobody reviewed and nobody can explain.

How Norma runs the loop

The Norma MCP loop: prompt, get rulesets, generate code, livecheck, fix, register, then pull request.

Norma sits inside the loop as an MCP server. The agent fetches the rulesets for the repo’s stack before it writes, runs a Livecheck on what it wrote, applies the fixes, and registers the outcome in an audit trail that lives outside the agent. Same code, same rule, same verdict, every run.

Watch it in under two minutes

The risks of ungoverned AI code, how the loop works, and how to set it up with Norma in three steps.

Read the transcript

Coding agents now write a big share of the code that ships. Without governance, that code carries real risks. Passwords and keys left in the source. Insecure patterns. Code that drifts from your architecture. And no record of what anyone checked. Loop engineering deals with this inside the agent's own loop. The agent takes a goal, plus the context of your repo and your rules, and writes the code. Then Norma checks every file against those rules. If a check fails, the agent gets the finding, fixes the code, and checks again. The rules are fixed, so the same code always gets the same answer. What comes out of the loop is working code, plus a record of what was checked, what failed, and what got fixed. Setting it up takes a few minutes. Create a free Norma account, then add the Norma MCP server to your agent: Claude Code, Cursor, Windsurf, or any other MCP client. You sign in once, from the agent. Next, ask the agent to link your repository to Norma. From then on, it checks each file as it writes it, fixes what Norma flags, and records the result. Then install the Norma GitHub App. Every pull request gets a comment listing any new issues, so code written outside the agent gets checked too. Your agents keep their speed. And you get code you can stand behind, with the evidence to prove it.

Set it up in your agent

Three ways Norma covers your code: MCP server in the agent loop, GitHub App on every pull request, and VS Code extension in the editor.

MCP clients

Cursor, Claude, Claude Code, Windsurf, Lovable, Replit and Codex. The endpoint is api.qualityclouds.ai/mcp with OAuth; your client opens the sign-in for you, no API key to manage.

Claude Code

claude mcp add --transport http norma https://api.qualityclouds.ai/mcp

claude mcp add --transport http norma https://api.qualityclouds.ai/mcp

Cursor and other clients that use an mcp.json

{ "mcpServers": { "norma": { "url": "https://api.qualityclouds.ai/mcp" } } }

{ "mcpServers": { "norma": { "url": "https://api.qualityclouds.ai/mcp" } } }

Inside Claude, Norma is also in the connectors directory; search for it there and connect in two clicks. Or install through Smithery.

Then link a repo and let the agent work

Link this repository to Norma, get the rulesets for its stack, and check every file you change before opening a pull request.

Link this repository to Norma, get the rulesets for its stack, and check every file you change before opening a pull request.

GitHub

Install the Norma GitHub App. It checks every pull request when it opens and posts the findings as a review comment, covering the code that never passes through an agent loop: contractors, teams that haven’t adopted MCP, agents nobody told you about. It asks for one permission, read and write on pull requests, so it can read the change and post the comment. It cannot push code or merge.

VS Code

Install Norma: AI Code Governance from the Marketplace, also on Open VSX for Cursor and VSCodium. Livecheck runs on the active file, findings land in the Problems panel, and Fix with AI hands the finding to your editor’s AI chat.

Questions about governing code generation

Can I govern what an agent generates, or only what it has already written?

Both, and the first is where the gain is. Give the agent the rulesets for the repo’s stack before it starts, so it writes to the standard. Then check the output before the change is accepted. Norma exposes rulesets through MCP so the agent reads them at the start of the loop and checks against them at the end.

My LLM already has my skills and rules files. Isn’t that governance?

It’s the first half. Skills and rules files tell the model what the standard is, and they work well for that. They don’t tell you whether the output met it. The model reads the rule, writes the code, and nothing checks the result against the rule or writes that result down. Governance needs the check and the record on top of the instructions. Keep your skills files; add a deterministic check that verifies the output against the same standard.

My LLM already does the code review. Why add another check?

Because the review is the model grading its own work, and the grade changes between runs. Ask it twice and you get two opinions. A deterministic check gives the same verdict every time, and it’s recorded outside the agent’s session. The LLM review is still useful for judgment calls; the check is what you can show to an auditor.

Where in the loop should the check run?

Before the pull request is opened. At that point the agent can still fix the finding and the corrected code is what reaches review. A check at merge time is late; a check after merge is a report.

How do I stop rules drifting between developers?

Keep the rulesets in one place and have every agent fetch them, rather than copying rules files into each IDE. Local skills and rules files are fine as a supplement; they shouldn’t be the source of truth.

Does governance slow the agent down?

A Livecheck on a file takes seconds. The agent applies fixes in the same loop, so the time is recovered at review, where a human would otherwise have to find and explain the same problem.

What counts as an audit trail for AI-generated code?

A record, held outside the agent’s session, of which code was checked, against which rules, with what result, what was fixed, and which client made the call. Chat history and commit messages don’t meet that bar.

Does it cover prompts as well as code?

It should. Prompts and agent instructions decide what gets generated, so they need standards too. Norma includes a ruleset for prompts alongside the code rulesets.

What if my stack isn’t supported?

Norma detects the stack automatically and today covers JavaScript, TypeScript, Python, PHP and frameworks including React, Node, Vite, FastAPI, SQLAlchemy, Supabase and Adobe Magento, with more in development. If yours isn’t listed, talk to us about what’s next.

Try Norma free

The free tier is permanent, with 1 certificate per month. It’s freemium, not a trial that expires. Sign up, connect your agent, and it checks its own code from the next prompt onward. Onboarding includes a read-only demo repository that doesn’t use your scan quota, so you can watch a full run before pointing Norma at real code.