Governed AI Coding Agents: A Guide for Engineering Leaders
If one is not aware of the full architecture, they will implicitly trust the AI's recommendations, and that results in more high-risk AI tells throughout the code. Give the AI scope, specs and an architecture to build inside, and keep a human in the decision seat.
A client's AI-built MVP
In my consulting business, I help founders translate tech into business outcomes. Often, these founders come to me with an AI-assisted built product and ask me to help scale it into viable business value. One story I'd like to share is that of a client's AI-built MVP that he couldn't scale into a reliable digital product.
A client's founder had been building with AI for months, and the whole evolution of his code was built on a back and forth: ask, get something, say not quite, ask again, with the scope never written down anywhere—it was all in his head. So we went through the repo file by file, trying to fit each piece into a defined architecture, and kept finding the same problems. Things like finding scaffolding that did one job but was built in several places, as well as finding data that ran through the same code but duplicated (ever so slightly) in different corners of the app. There was also a robust logging system with some great scaffolding, but that was never set up to actually output anything to the system they built it on (a quick change to writing to stdout solved it). The MVP looked good and was very impressive to investors, but a few clicks into it uncovered some large bugs and an inconsistent experience.
This was not a problem of choosing the right AI model to help. Opus vs Haiku wasn't the issue. It was that nobody had told the AI what the system was supposed to look like in the end, because it only existed in the founder's head, and it was only around what it could do for the user.
So, we rebuilt the repo, kept what earned its place and threw out the rest. I highlight this to showcase how you can cut down technical debt, real costs, time and complexity by using the right approach.
The same story, with a different cast and characters, is in almost every codebase we work with. A founder usually, an AI, and a vague idea of what is to be built.
What I see in almost every codebase
In almost every codebase I work with, the founder or someone on the team is already using AI to write code. There are usually few guardrails, and the work turns into a back and forth with the model over scope that nobody took the time to sit down and ensure consensus. So the agent builds something, the person says that's not quite it, the agent builds something else, and a week later the feature has evolved into something pretty neat but half-baked, and is not what the feature was supposed to do in the first place.
When we speak of teams with better product outcomes using AI, they aren't the ones with the most powerful model or the strictest policy in the org. Instead, they know exactly what they are building before they start. The work is specified, and the spec is shared with the AI. The architecture it works inside reflects the architecture practices the company already has, not whatever the model decides is reasonable that afternoon.
Neuroscience and how AI hacks into our natural workflows
Daniel Kahneman made the idea of two systems of thinking famous in Thinking, Fast and Slow. Two Wharton researchers, Shaw and Nave, have recently proposed a third, which they call System 3, along with a failure they call cognitive surrender (Shaw and Nave, 2026). It's a working paper built on one narrow reasoning task, so I hold it loosely, though it matches what I see in the codebases I work with.
System 1 is the system you use after repeated practice, it is the heuristic you've learned after confirming over and over that an input equals an output. It's low energy and highly effective. System 2 is where you have to say "wait", and you stop and think and reason your way through it. System 3 is a "new" system, external to ourselves, that we've integrated into our thought workflows. It taps into the same heuristic thinking that saves the human energy into a system that feels like us and seems right to us most of the time. It matters for AI coding because for many, AI coding is a hard task that requires years of training to do well. If the AI seems to be able to do it most of the time correctly, it seems like a good tradeoff for a person who has never coded before, and biologically we choose to surrender to this and trust this because it checks all the boxes. It's a built in trait and is why we as humans are so efficient in our thinking habits.
We find that people rely on that third system more often when they know less about the topic, and even if an AI is confidently wrong, the developer doesn't know true from false.
So what does that look like? If you've ever accepted AI output by saying to yourself "yes, looks good, let's see what that looks like in practice" and verifying the output based on the UI flow alone, then you've succumbed to the cognitive surrender arising from deference to System 3.
What it looks like in the code
When I code with AI, I treat the agent like an arrogant principal engineer who thinks his narrow view knows best. You see this through over-engineered designs that look beautiful but do not directly solve the problem at hand nor does it consider current business constraints correctly.
The issue here is if one is not aware of the full architecture, or the product's nuances out in the field, then they will implicitly trust the AI's recommendations, which results in more high-risk AI tells throughout the code. This happens because decisions are made with partial context, but the delivery is so tuned to how we defer to our System 1 thinking, that we give into it, and biologically see that this is correct.
What I changed
Understanding how my brain worked with respect to my AI assistant, I knew how to build governance around my process so that I could decrease the likelihood of deferring to System 3. The change I made was a new directive to provide scope and specs to the AI right away with the actual tasks together with what not to do. Also to provide it an architecture and ensure that the agents built inside that, and catching anything outside of that. We were able to add that into the harness, the standing instructions and guardrails the AI works inside, and made the architecture the ground truth from which every decision should be made (with human review, more on that below).
As mentioned, we manually ported over an AI-assisted codebase into a new repo, building the architecture, spec, and governance as we went. But wouldn't it be great to get that at the outset? I knew I'd do this over and over again, so I built a tool, Ask Jentic. A full sweep of the code with Ask Jentic gives developers the context to make the right decisions, together with their AI. I discovered a lot of redundancy in how the data traveled throughout the application, and together with my AI, with Ask Jentic, I was able to make decisions by using its output as my own input, informing how I would add a feature and eventually refactor the code.
How to codify this workflow
Over the last year, if there is one thing I've witnessed is that governance that sounds like a ban gets ignored (hello, shadow AI), but governance that sounds like permission gets adopted. When access follows an identity, then any agent you set up under this structure can only reach what the user running is allowed to access. Log the agent's actions and add human review into the process. With those measures, your CISO can approve that because they have a ledger of what the agent did (accountability) and can confirm it stayed inside the limits a person would. With the right governance in place, many workflows can be automated, freeing the human to focus on core changes.
Governance can also break down large swaths of changes into smaller ones, which reduces cognitive surrender and makes it easier for the engineer to measure if the AI is writing to spec. You can even spin up another agent that helps ensure this is the case. But then how do you make sure the dev isn't just mindlessly clicking through the flow?
There are a few key things you can do to help guard against cognitive surrender in AI governance. First, ask the reviewer to go through the changes in the PR, and write down exactly what the change is. What is it doing? What is it modifying as a result? Next, even though you can have a checking agent verify the changes against a spec, your checker should have questions for the person to answer to validate the output, leaving decisions with the reviewer. Don't let the AI choose what it "thinks" is most likely correct. Third, ensure the developer was the decision maker. There should never be any "the AI decided" as an accepted result. The AI can suggest, but the developer should decide at the end of the day, as they understand the product nuances more than an AI. Never defer to the AI. Fourth, you should question quick turnaround times for review, or reviews without comments, especially on large PRs. These suggest a "click and surrender" mentality. Finally, now and then, you should plant a known flaw in a test change in order to see whether it gets caught. Definitely tell your team that you are doing this, and then use the experience to learn where attention in the process drops. This is not to blame the team, rather it will highlight where reliance on AI might be adding additional risk into the flow.
Not every repo needs the same rules
One blanket policy either over-restricts, so engineers work around it, or under-restricts, so you have an incident. Put each repo or path in a risk tier, and tie each tier to specific rules in CI/CD so the checks run automatically.
| Tier | What's in it | What agents can do |
|---|---|---|
| Standard | Internal tooling, docs, tests | Open PRs, normal review |
| Elevated | Customer-facing application code | PRs need code-owner review and all status checks |
| Restricted | Auth, payments, infrastructure as code | Mostly read-only, and changes need senior and security review |
| Prohibited | Secrets, key material, compliance-controlled code | No agent access |
Frequently asked questions
What is cognitive surrender?
It's what happens when you accept AI output because it feels like your own thinking and seems right most of the time. System 3 is an external system that taps into the same heuristic thinking that saves the human energy, so biologically we choose to surrender to it and trust it because it checks all the boxes.
How do I tell whether my team is trusting the AI too much?
Question quick turnaround times for review, or reviews without comments, especially on large PRs. These suggest a "click and surrender" mentality. Also ask who decided why a change was built that way, because if the answer is "the AI decided", the developer was deferring and not deciding.
Do we need a dedicated AI governance tool to do this?
Not to start. You can build the basics with your identity provider, standard logging and branch protection: give the agent only the access of the person running it, log its actions, and put a human review into the process. Dedicated tooling helps at scale, but settle the model first, and make sure people have the context.
What is the first control to put in place?
Human review. Require at least one human approver on any AI-generated pull request with branch protection, and ask the reviewer to write down exactly what the change is before they approve it. It's low effort and you can enforce it today, but it only works if the reviewer knows the architecture, which is why I pair it with giving people the full picture of the codebase.
How do we govern agents that run shell commands, not just suggest code?
Treat them the same way. The agent can only reach what the user running it is allowed to access, every command is logged, and anything destructive or privileged asks for confirmation. Put that in place before an agent runs its first unreviewed command.
Notes on AI and engineering teams
I write about AI, engineering leadership and decision science on Substack. It’s free.
Subscribe