Team Lead Mindset

Rules for AI-Assisted Coding on a Team

The author owns every line, what to allow, reviewing generated code harder, agent permissions, helping juniors, measuring honestly and a one-page policy.

Lesson 1514 min read#ai-assistants#policy#code-review

On this page

  1. Words used in this lesson
  2. The principle: the author owns the code
  3. What to allow
  4. Review generated code harder, not softer
  5. Security risks
  6. Growing juniors in the age of assistants
  7. Measuring the effect honestly
  8. A one-page team policy (template)
  9. Interview questions
  10. Key takeaways
  11. What's next

In one line: AI coding assistants change how code is produced, not who is responsible for it. A good team policy is short: the author owns every line they commit, generated code gets read and tested like any other, secrets and private data stay out of prompts, agents get the least power they need, and you measure results honestly without a scoreboard.

Sooner or later a team member asks, "Can I use an AI assistant for this?" Or a pull request arrives with 600 lines the author cannot explain. A lead needs a calm, written answer before that happens. This lesson gives a lead's view: what to allow, what to review harder, the risks, how to help juniors, how to measure effects honestly, and a one-page policy you can adapt.

This lesson is about team habits and judgement, not about any one product. Tools, features and terms of service change quickly, so I name no products. Read the earlier lessons of this series for the thinking tools used here: review habits, Lesson 3, laws and biases, Lesson 7 (Goodhart's Law matters for measuring) and a security mindset, Lesson 14. For the technical side of building with models see Securing LLM applications, AI Engineering Lesson 0 and prompt injection and safe tools, Lesson 1.

What I read / checked. This lesson has no code, so I ran nothing. What I read directly: Google's public code-review standard in google/eng-practices (earlier in this series, Lesson 3), and, through the AI Engineering series, the OWASP GenAI Top 10 for LLM applications pages on the official OWASP repository (the risk names Improper Output Handling, Excessive Agency and Supply Chain). What I did not do: I did not read any vendor's usage terms or privacy policy, and I did not review studies on how much AI assistants change productivity or code quality. Findings in this area are mixed and change fast, and I cite no numbers. Everything else is common practice and my own opinion. Your law, your contracts and your customers' terms decide what is allowed; ask your legal and security people.

Words used in this lesson

  • AI coding assistant means a tool that suggests or writes code, tests or explanations from your prompt and your code.
  • Agent (here) means an assistant that can also take actions: edit files, run commands, call tools. Power brings risk.
  • Prompt is the text and code you send to the tool.
  • Accountability means that a named person answers for the result.
  • Provenance means where something came from. For code: who wrote it, from what source, under what licence.
  • Licence is the legal terms for using someone's code.
  • Least privilege means giving a tool only the access it needs for the task.

The principle: the author owns the code

Google's code-review standard has a simple idea at its centre: reviewers should approve a change once it definitely improves the overall health of the code. Whoever submits a change is saying "this makes the system better". That sentence does not change when a tool typed the lines. So the first rule of a policy is:

If you commit it, you own it. You must be able to explain what it does, why it is right, and how it was tested. "The assistant wrote it" is never an answer in a review or an incident.

Everything else follows from this. If the author owns the code, then the author must read it, test it and be ready to change it.

What to allow

Decide in advance and write it down. A sensible, cautious start (adapt it):

UseSuggested stanceWhy
Explaining unfamiliar code, errors, commandsAllowLow risk, high learning value
Drafting tests and test dataAllow, with reviewCheck that the tests can fail (see below)
Boilerplate and repetitive editsAllow, with reviewEasy to check
Writing new business logicAllow, with extra careSubtle bugs look plausible
Security-sensitive code (auth, crypto, payments, input parsing)Allow only with a second reviewer who knows the areaPlausible but wrong code is expensive
Pasting customer data, secrets, keys or internal documents into a toolNot allowed unless your security team approved that exact tool and settingData leaves your control
Agents that run commands or change many filesAllow only in a sandbox, with limited permissions, on a branchSee "agents" below

The right columns differ by company. Some legal teams forbid certain tools entirely. Ask first.

Review generated code harder, not softer

Generated code has a specific danger: it is fluent. It looks clean and confident even when it is wrong. A few review habits help:

  1. Keep changes small. Google's guide says small changes are reviewed faster and more carefully, and have fewer bugs; it suggests about 100 lines is usually fine and about 1,000 is usually too large. An assistant makes big changes easy, so a lead must hold the line: split it.
  2. Read every line as if a stranger wrote it. The author's first job is to review the output before anyone else sees it.
  3. Tests first, or at least tests that can fail. Ask: "Show me the test failing, then passing." A test written by the same tool from the same code may only repeat the code's mistake.
  4. Check the details that look right: off-by-one errors, missing error handling, wrong time zones, invented function names or options, outdated library usage, silently swallowed exceptions.
  5. Do not accept new dependencies without the package checks from Lesson 1. Assistants sometimes suggest packages that do not exist or are not what you expect. A fake package name that someone registered later is a supply-chain risk (OWASP lists Supply Chain among its LLM risks).
  6. Watch for copied code and licences. You cannot always see where a suggestion came from. Ask your legal team what your policy is, and do not paste large unexplained blocks.
  7. Review the tests too. Generated tests are often shallow: they assert what the code does, not what it should do.

"It passes the tests" is weaker than usual. If the tool wrote both the code and the tests, a pass tells you they agree with each other. It does not tell you either one is right.

Security risks

Two risks come up again and again in the OWASP list for LLM applications, and both apply to your developers' tools and to products you build:

  • Improper output handling. Treating model output as trusted. Code from a model should be treated like code from the internet: read it, run it in a safe place, and never pipe it straight into a shell, a database or production.
  • Excessive agency. Giving a model more power than the task needs. An agent that can read your whole disk, use your cloud credentials and push to the main branch is a large risk if it is tricked by text in a file or a web page (see prompt injection).

Practical rules for a team:

  1. No secrets in prompts or in files an agent can read. Use secret managers and keep .env files out of agent reach.
  2. Least privilege for agents. A separate workspace or container, a read-only token where possible, no production credentials, and a branch that cannot merge without human review.
  3. Human approval for risky actions: deleting data, changing infrastructure, publishing packages, sending messages to customers.
  4. Treat content the agent reads as untrusted. A README, an issue or a web page can contain instructions aimed at the tool.
  5. Log what the agent did so a review can see commands and changes.

Growing juniors in the age of assistants

The risk for a junior is not that they will use a tool. It is that they will stop building understanding. A lead can protect learning without banning anything:

  • Ask them to explain the change in their own words in the pull request. If they cannot, the review is a teaching moment, not a rejection.
  • Use "what have you tried, and what do you think the options are?" (Lesson 9) before offering an answer, whether the answer comes from you or from a tool.
  • Give some tasks to do without the assistant, on purpose, like practising scales on an instrument. Say why.
  • Pair on one tricky piece and read generated code together.
  • Praise good questions and good tests, not volume of code.

Measuring the effect honestly

Leaders will be asked: "Is it working?" Be careful.

  • Goodhart's Law (Lesson 7): when a measure becomes a target, it stops being a good measure. If you reward "lines of code" or "number of pull requests", an assistant will help you win the number and lose the quality.
  • Use the team-level delivery measures from Lesson 4 (how often you ship, lead time, failure rate, time to recover) and look at them before and after a change, over months, with other changes in mind. A rise in speed with a rise in failures is not a win.
  • Ask people. A short, regular survey ("What does the assistant help with? Where does it waste time?") is cheap and often more useful than a dashboard.
  • Watch review load and rework: if reviews get longer and more bugs come back, the assistant may be moving the cost to reviewers.
  • I did not review published studies, and results differ by task, team and tool. Do not quote a percentage to your manager unless you read the source yourself.

A one-page team policy (template)

MD
# Using AI assistants on <team name>Status: draft | accepted    Owner: <name>    Review date: <date, in 3 months>## Principles1. You own what you commit. You can explain it and you tested it.2. Generated code gets the same review as any code, and more care in   security-sensitive areas.3. Private data and secrets never go into prompts or agent-readable files.## Allowed- <explaining code, drafting tests, boilerplate, ...>## Needs a second reviewer- <auth, payments, crypto, input parsing, migrations, ...>## Not allowed- Pasting customer data, secrets, keys or internal documents into tools  that security has not approved.- Merging changes you cannot explain.## Agents- Sandbox or container, least privilege, no production credentials.- A human approves deletes, infrastructure changes, publishing, messages.## Tools- Approved tools and settings: <list, with the link to security's decision>.- To ask for a new tool: <how>.## Review- Keep changes small. Show the test failing, then passing.- Say in the pull request description if a tool wrote a large part.## Measuring- We look at team delivery measures over time. We do not rank people by  output counts.

Review it in three months. This area changes quickly and a policy that never changes will be wrong.

Interview questions

Should developers on your team use AI coding assistants? (Must know)

Yes, within clear rules, and I would write the rules down with the team. The core is that the author owns what they commit: they must read it, test it and be able to explain it. Private data and secrets do not go into prompts, agents get least privilege, and security-sensitive code gets a second reviewer. I would review the policy after a few months because the tools change fast.

A pull request has 800 lines and the author cannot explain part of it. What do you do? (Must know)

I do not approve it, and I do not punish the person. I ask them to split it into small changes, read each part, and explain it in their own words. Where they cannot, we pair on it and either understand it or delete it. Small changes get better reviews and fewer bugs, so I hold to that rule even more when a tool can produce a big change in seconds. The goal is to keep the author accountable and to teach.

How do you review code that an assistant wrote? (Senior signal)

Like any code, with more suspicion about details that look right: error handling, edge cases, invented functions or options, outdated library use and tests that only repeat the code. I ask for a test that fails before the fix and passes after. I check new dependencies carefully, because suggested packages can be wrong or malicious. If the tool wrote both code and tests, a pass tells me less than usual.

What are the security risks of AI assistants and agents? (Senior signal)

Data leaving the company through prompts, untrusted model output being run or merged without checks (improper output handling), agents with too much power (excessive agency), and bad dependencies. Text in files or web pages can also try to instruct an agent. My controls are: no secrets or customer data in prompts, approved tools only, agents in a sandbox with least privilege and no production credentials, human approval for risky actions, and logging of agent actions.

How do you measure whether the assistants help? (Senior signal)

I use team-level delivery measures over several months (frequency, lead time, failure rate, recovery time) alongside review load and rework, and I ask the team directly. I avoid per-person counts like lines or pull requests, because of Goodhart's Law: the number would improve and the quality would not. I also state plainly that I have not reviewed the published studies, and I would read the sources before quoting any number.

How do you help juniors learn when a tool can write the code? (Senior signal)

I make understanding the thing that is reviewed. They explain the change in their own words in the pull request. I ask what they tried and what the options are before I give answers. Some practice tasks are done without the assistant, openly, to build skill. We read generated code together and I praise good questions and tests rather than the amount of code.

An engineer wants to give an agent write access to production. What do you say? (Trap)

No, not as asked. I explain the risk in plain words: the agent can be tricked by text it reads, or just be wrong, and production mistakes are costly. I offer a safer path: a sandbox or staging copy, read-only access where needed, a branch that needs human approval to merge, and human approval for deploys and data changes. If they have a strong case for more access, we write it down as a decision with the risks, and involve security.

How do you handle the licence and provenance question for generated code? (Senior signal)

I do not know the answer in general, and it depends on the tool, its settings and the law, so I ask legal and security to decide the team policy. In the meantime I set practical rules: no large unexplained blocks, keep the author accountable, run our normal dependency and licence checks, and record in the pull request when a tool wrote a large part. I do not guess about legal questions.

Key takeaways

  • The author owns every line they commit, whoever or whatever typed it.
  • Write a short policy: what is allowed, what needs a second reviewer, what is never allowed, how agents are limited.
  • Generated code is fluent, not necessarily right. Keep changes small, read every line, and ask for tests that fail first.
  • Keep secrets and private data out of prompts. Give agents least privilege, a sandbox and human approval for risky actions.
  • Protect junior learning: explain in your own words, ask what they tried, and practise some tasks without the tool.
  • Measure team results over time, not per-person output counts. Do not quote numbers you did not read in the source.
  • Review the policy every few months, because tools and rules change.

What's next

Next: Scaling teams, ownership and on-call, Lesson 16. Practise: copy the policy template, fill in the "Allowed", "Needs a second reviewer" and "Not allowed" lists for your own team in 30 minutes, and ask two teammates what they would change.

Published by Jainik · Last updated · How these lessons are made

Keep learning

Related lessons

Part of the study guide

Related series