Blog

Team rules for AI-generated code that keep reviews honest

A one-page working agreement for AI-assisted coding: who owns generated code, how big a change can be, what reviewers check and what never goes in a prompt.

Your engineers are already using AI coding assistants. Some use them for autocomplete, some for whole functions, a few for entire pull requests. Output has gone up. So has the size of the review queue, and you've started seeing approvals on 600-line changes that nobody could have read properly in the twelve minutes between them being opened and merged.

You don't need a company-wide AI strategy to fix that. You need a short working agreement your team writes together, so everyone knows what "done" means when part of the code came from a tool. This post gives you a template, the reasoning behind each rule, and a way to introduce it without it feeling like a crackdown.

Why reviews get worse when writing gets faster

Code review was designed around a cost balance: writing code was slow, so the author understood every line, and reviewing it was comparatively quick. An assistant breaks that balance. Writing becomes cheap, reading stays expensive, and the author may understand the change less well than the reviewer assumes.

Three things tend to happen in a team without agreed rules:

  • Changes grow. When generating code is effortless, it's tempting to bundle the refactor, the feature and the tests into one pull request.
  • Ownership blurs. "The assistant wrote that bit" becomes an explanation in review, and later in incident reviews.
  • Review turns into skimming. Generated code is usually tidy and consistently formatted, so it looks reviewed. The mistakes in it are plausible ones: a wrong boundary condition, a deprecated API, a test that asserts what the code does rather than what it should do.

The research is worth knowing. The DORA program's 2024 report found that higher AI adoption was associated with slightly lower software delivery throughput and noticeably lower delivery stability, and the authors suggested larger batch sizes as one possible reason. The 2025 report found the throughput relationship had turned positive, but the negative relationship with stability remained. These are survey-based associations, not proof of cause, but they point at the same place your review queue does: speed of writing isn't the bottleneck you need to protect. Small batches and real review are.

The working agreement

Here's a one-page template. Treat it as a starting point for a team discussion, not a policy to paste in. Each rule is explained below.

How we use AI coding tools

  1. The author owns every line. If your name is on the pull request, you can explain any line in it without rerunning the tool. "The assistant wrote it" is never an answer in review or in an incident.
  2. Small changes. Pull requests stay under about 400 changed lines of non-generated code. Bigger work is split; mechanical changes (renames, formatting, generated files) go in their own pull request.
  3. Say what helped. The description notes where an assistant did substantial work ("tests drafted with an assistant, edited by hand"). This is context for the reviewer, not a confession.
  4. Tests are checked, not trusted. Generated tests must fail when the behavior they cover is broken. The author confirms this for at least the key cases.
  5. Reviewers review the change, not the formatting. We check intent, edge cases, error handling, security and fit with the rest of the system. If you didn't have time to understand it, you don't approve it.
  6. New dependencies are a human decision. No package, library or API version is added because an assistant suggested it, without checking it exists, is maintained and is allowed.
  7. Nothing sensitive in prompts. Only approved tools for company code. Never secrets, credentials, customer data or anything our data policy marks as restricted.
  8. We review this agreement at a retro once a quarter.

The reasoning behind each rule

1. The author owns every line

This is the rule everything else rests on. It's the same principle that applies to any tool or to code copied from elsewhere: accountability stays with the person who ships it. In practice it means the author has read the generated code as carefully as they'd read a colleague's, and can answer "why does this do X?" in review.

A useful test for authors before opening a pull request: could you walk a reviewer through this change on a call, without looking at the assistant's chat history? If not, it isn't ready.

2. Keep changes small

Large changes have always been reviewed worse than small ones. Jason Cohen's Best Kept Secrets of Peer Code Review (2006), drawing on a study of code review at Cisco, reported that reviewers' ability to find defects fell off once they reviewed more than roughly 200 to 400 lines at a time. The exact number matters less than the direction, and it applies with extra force when the author can produce 400 lines in a minute.

Pick a soft limit the team agrees with and make exceptions visible rather than forbidden. Splitting a change is also a chance for the author to understand it: if you can't decide where the seams are, you probably don't know how it works yet.

3. Say what helped

The goal isn't to police tool use. It's to tell the reviewer where to look harder. A line like "the parsing logic was generated and I've added tests for malformed input" changes how a reviewer reads the diff. Keep it short and normal; if disclosing feels risky, people will stop doing it, and you'll lose the signal.

4. Check the tests

Generated tests are the easiest place for false confidence to hide. Assistants are good at writing tests that pass, and a test written by looking at the implementation tends to confirm what the code does, including its bugs. The quick check: break the behavior on purpose (flip a condition, return the wrong value) and confirm a test fails. If none does, the tests aren't testing anything that matters. Teams that already use mutation testing tools can lean on them here.

5. Review for what tools get wrong

Google's published code review guidance says reviewers should approve a change once it definitely improves the overall health of the codebase, even if it isn't perfect. That standard still works, but generated code shifts where reviewer attention is best spent. Formatting and naming are usually fine. Spend the time on:

Look at Typical problem in generated code
Intent Solves a slightly different problem from the ticket
Edge cases Empty inputs, time zones, concurrency, very large values
Error handling Errors swallowed or logged and ignored
Dependencies and APIs Outdated, deprecated or non-existent functions and packages
Security Unvalidated input, string-built queries, secrets in code or logs
Fit Duplicates a helper that already exists elsewhere in the codebase
Tests Assert the implementation, not the requirement

The last line of rule 5 matters most: "If you didn't have time to understand it, you don't approve it." Say it out loud in the team meeting. Approving to be helpful is the habit you're trying to break.

6. Dependencies are a human decision

Assistants sometimes suggest packages that are outdated, abandoned or don't exist at all, and attackers have been known to publish malicious packages under names that look plausible. Checking that a dependency is real, maintained and permitted takes two minutes and is cheap insurance. If your organization has a technology radar or an approved list, point to it here.

7. Nothing sensitive in prompts

Your organization should have a policy on which tools are approved for which kinds of data. If it doesn't, push for one, and in the meantime keep the rule conservative: no secrets, credentials, customer data or restricted material in any prompt, and company code only in tools your security team has approved. Managing AI change in your organization has a simple green-amber-red classification you can borrow.

Licensing and ownership of generated code is a legal question that varies by tool, contract and jurisdiction. Don't invent your own answer; ask whoever handles legal questions for engineering and add their guidance to the agreement.

Watch out for the junior engineer problem

Assistants change how people learn. A junior engineer who generates a working solution has shipped something; they haven't necessarily learned why it works. Over a year, that difference is the difference between someone who grows into a senior engineer and someone who stays dependent on the tool.

You don't fix this with a ban. Some things that work:

  • Ask "why" in review, especially for juniors, and make it routine rather than a test.
  • Pair on the hard parts. Use pairing for debugging and design, where understanding is built.
  • Set occasional no-assistant tasks as learning exercises, agreed openly as practice, not as a rule for production work.
  • Talk about it in one-on-ones. Ask what they've learned recently that they couldn't have looked up. The one-on-ones post has more questions in this spirit.

How to introduce the agreement

Rules handed down by a manager get followed to the letter and no further. Rules the team writes get defended by the team. Run it as a 45-minute session:

  1. Ten minutes: share what's happening. Ask each person how they use assistants now and one thing that went wrong. Go first, and make your own example honest.
  2. Fifteen minutes: walk the template. For each rule, ask: keep, change or drop? Write changes in the doc as you go.
  3. Ten minutes: agree the numbers. The pull request size limit, which tools are approved, what the description note looks like.
  4. Ten minutes: decide how you'll know it's working (see below) and set the review date.

Then add the agreement to your pull request template, so the reminder appears where the work happens rather than in a wiki nobody opens.

How to tell if it's working

Look at the trend over a couple of months, not single numbers, and resist turning any of these into individual targets:

  • Pull request size, median and the largest ten percent.
  • Time from opening to first real review comment. Instant approvals on large changes are the warning sign.
  • Change failure rate or bugs found after release, compared with your baseline.
  • Review comments per change. A sharp fall can mean better code or less reading. Ask which.
  • The team's own view, at the quarterly retrospective: is review better or worse than three months ago?

If stability slips while output rises, tighten the size limit and the review rules before anything else.

Your first step

This week, look at the last ten merged pull requests on your team. For each one, note its size, how long it took from opening to approval, and whether the reviewer left any substantive comment. That ten-minute exercise gives you the evidence to open the conversation, and a baseline to compare against once the agreement is in place. For more on running team practices like this in your first year as a manager, the Practitioner study guide covers the rituals and team metrics behind them.

Working toward PTMP Practitioner?

The free study guide covers every competency area on the PTMP exam, with practical examples.

More from the blog

Practical articles for technical managers at every stage. All posts

  1. How to plan an AI feature your team can ship and maintain

    A planning guide for LLM features: define the job, build an eval set first, cost each request, design for wrong answers and set kill criteria before you commit.

  2. A one-page project brief that keeps scope from creeping

    A one-page project brief template with goals, non-goals and a named decision owner, plus a script for the requests that arrive mid-project.

  3. An internal technology radar your teams actually consult

    How to run an internal technology radar: rings defined as decision rules, a one-page blip write-up, a twice-yearly review, and evidence for moving rings.