Should AI Agents Write Production Code? A CTO's Rules After Running Agent Teams

Should AI Agents Write Production Code? A CTO's Rules After Running Agent Teams

4 min read
Lance Ennen
Share:
Yes — with a hard definition of done. AI agents can safely author boilerplate, tests, migrations, and well-specified features, but every agent-written change needs review gates scaled to blast radius: financial logic, authentication, and data deletion stay human-owned. The caution is earned — Veracode found security flaws in roughly 45% of AI-generated code — yet AI-native teams already let agents write most of theirs. Here is the merge policy I use running AI coding teams.

What the Data Says

Veracode's GenAI Code Security Report tested over 100 LLMs across 80 coding tasks: AI-generated code introduced risky, known security flaws in 45% of tests, with Java worst (72% failure rate) and cross-site scripting defenses failing in 86% of relevant samples. Their 2026 follow-up found the security rate largely unchanged even as functional quality improved — models got better at working code, not safe code.
Read that carefully: it's an argument for review gates, not abstinence. Humans don't write flawless code either; we built review processes because authorship was never the guarantee. The question isn't whether agents can write production code — mine do, daily — it's what process makes that safe.

My Merge Policy

This is the actual policy my teams run — three tiers, sorted by blast radius:

Tier 1 — Agent-autonomous (merge on green)

Well-specified, reversible, fully covered by existing tests: formatting, dependency bumps with passing CI, test additions, documentation, internal tooling. The agent authors, CI is the reviewer.

Tier 2 — Agent drafts, human reviews

The default for feature work: the agent writes the change and the tests; a human reviews with the same bar as any PR — plus extra attention to injection surfaces and error paths, where the Veracode data says models fail most.

Tier 3 — Human-only

Financial logic, authentication and authorization, data deletion, cryptography, anything compliance-relevant. Agents may propose; humans author and own.

What Agents Are Genuinely Good At

Boilerplate and scaffolding, test coverage expansion, migrations with clear specs, mechanical refactors across many files, and first drafts of well-scoped features. In my practice the leverage is real: agents plan and ship alongside humans, and the process changes that follow matter as much as the code.

Where They Still Fail

Ambiguous requirements (they resolve ambiguity confidently and wrongly), security-sensitive paths (the 45% number), long-range architectural consistency, and knowing when to stop — an agent will happily "fix" its way into a rewrite.

Code Review When the Author Is an Agent

I've been writing about review discipline since long before agents — code reviews and behavior-driven development were how teams communicated intent in 2010, and they still are. What changes with an agent author:
  • Review the spec, not just the diff. The most dangerous agent code perfectly implements the wrong thing.
  • Trust tests less. The agent wrote those too. Review test intent.
  • Label authorship. Agent-authored PRs are marked as such in my teams, so reviewers calibrate — and so accountability stays with the human who merged, which is the actual answer to "who's responsible for an agent's bug."

The Definition of Done for Agent Code

Agent-written code is done when: the spec it implements was human-approved; CI and evals pass; a human reviewed it at the tier its blast radius requires; security-sensitive surfaces got explicit attention; the PR is labeled as agent-authored; and a named human merged it and owns it in production.

FAQ

What percentage of production code can AI write safely? There's no safe percentage — there's a safe process. With tiered review gates, most routine changes can be agent-authored; without them, no percentage is safe.
Should AI-written code be labeled in PRs? Yes. Reviewers calibrate differently, and accountability tracking depends on knowing authorship.
Who is accountable for an agent-written bug? The human who merged it. Agents don't carry pagers; ownership transfers at merge.
Do AI agents make senior engineers unnecessary? The opposite — review judgment and specification quality become the scarce skills. Agents amplify senior engineers and expose weak specs.
How do you test agent-written code? Same suite as human code, plus workflow evals, plus suspicion of agent-written tests: review what they assert, not just that they pass.

Lance Ennen is a technology founder and fractional CTO specializing in AI-agent systems, digital identity, and payments infrastructure. He runs AI coding teams daily and helps startups adopt them safely — see OpenClaw for engineering teams and fractional CTO services. Related: How Should Startups Architect AI Agent Systems?, Autonomous AI Software Teams.