Sub topic 1
Why a team needs an AI-assisted code policy
Prerequisites
This chapter assumes you have:
- A working knowledge of Git and the pull request workflow.
- Experience with code review in a team, as author and reviewer.
- Some hands-on use of an AI coding assistant or chat tool.
- A basic idea of what a CI pipeline does.
You don't need to write any policy text yet. This chapter explains why a policy is worth having and what it has to do. Later chapters cover the risks, the rules, and the enforcement in detail.
The situation most teams are already in
AI coding tools tend to arrive in a team before anyone decides how to use them. A developer tries a chat assistant to explain a stack trace. Another installs an editor extension that completes whole functions. A third lets an agent run shell commands and edit files in the repository. Nobody asked for permission, because nothing seemed to need it.
This leaves the team in a state we can call an implicit policy. Each person has private rules, such as "I never paste customer data" or "I only use it for tests", and those rules differ from person to person. Some are careful and some are not. Nobody can say which is which, because nobody has written the rules down.
A written policy replaces that with shared rules. A policy here is a short, specific document that says what is allowed, what needs extra care, and what is forbidden. It also says who is responsible for what, and which checks run automatically.
What goes wrong without a policy
Problems with AI-assisted code usually come from inconsistency and invisibility, not from the tools themselves. Five failure patterns come up repeatedly.
- Unreviewed plausible code. AI output usually looks right. It compiles, follows naming conventions, and comes with a confident explanation. Reviewers who see polished code may skim it. Authors who did not write it line by line may not have read it closely either. Bugs and insecure patterns then reach the main branch because everyone assumed someone else had checked.
- Data leaving the organization. A developer pastes a failing query, a config file, or a production log into a hosted tool to get help. That text may contain credentials, personal data, or proprietary logic. Whether this is acceptable depends on the tool's terms and settings, and individual developers rarely check those.
- Unclear ownership. When a change breaks production, "the AI wrote it" is not an answer. Without a stated rule, authors and reviewers may each believe the other carried the responsibility.
- Uneven practice. One team member uses an agent with broad permissions on a laptop that holds deployment credentials. Another bans the tools on their own projects. The first creates risk for everyone, and the second gets less benefit than the team could have had.
- Surprise in audits and contracts. A customer, auditor, or open-source project asks whether AI tools touched the code. If the team has no records and no consistent practice, it can only answer "we're not sure".
Chapter 2 examines the risk categories in depth. For now, notice that none of the five is solved by individual skill. Each needs a shared agreement.
What a policy does
A good policy does four jobs.
- Sets boundaries. It separates uses that are fine from uses that need approval or extra care, and from uses that are never acceptable.
- Assigns responsibility. It states that the human who submits a change owns it, whatever tool produced it.
- Makes expectations checkable. Where possible, rules become configuration: required reviews, required tests, restricted paths. A rule that depends only on memory will be forgotten under deadline pressure.
- Gives people a path. It says what to do when something goes wrong, or when a legitimate need doesn't fit the rules.
Notice what is not on the list: it does not try to forbid the tools. A policy that is too strict gets ignored, and people use the tools anyway, out of sight. The aim is to make safe use the easy default.
A map of what the policy connects
The topics in this tutorial form a chain. Risks justify the rules. Rules need owners and review practices. Review practices and tool settings need automation to hold up. Rollout and revision keep the policy alive.
The loop at the end matters. Tools change every few months, so a policy written once and never revisited goes stale. Plan for revision from the start.
Why the rules should be written down
Intermediate developers often feel that a team culture of "use good judgment" is enough. Judgment is necessary, but it is not sufficient, for these reasons:
- Judgment varies with experience. A senior engineer may spot a hallucinated API at a glance. A newer teammate may not, and may not know to be suspicious.
- Judgment degrades under pressure. Near a release, the temptation to accept a suggestion without reading it is strongest.
- Judgment cannot be audited. If a leak happens, "everyone was careful" gives you nothing to investigate or improve.
- New joiners have nothing to learn from. A written policy is onboarding material. Unwritten norms transfer slowly and unevenly.
Writing the policy also forces the team to have conversations that otherwise never happen, such as "Is it OK to paste logs?" and "Who approves a new tool?" Often the discussion is worth as much as the document.
What a policy looks like in practice
You will build the pieces across this tutorial. As a preview, a policy usually ends up as a mix of prose and repository configuration. Here is the outline of a one-page policy, which later chapters will fill in.
# AI-assisted code policy (v1)
## Scope
Applies to all code, tests, scripts, and documentation committed to
repositories owned by this team, however they were produced.
## Principles
1. The author of a change owns it, fully.
2. Restricted data never goes into unapproved tools.
3. Every change meets the same review and test requirements.
## Uses
- Allowed: explaining code, drafting tests, boilerplate, refactoring suggestions.
- Needs care: security-sensitive code, schema migrations, build and deploy config.
- Not allowed: sharing secrets, customer data, or restricted code with unapproved tools.
## Owners and review
Policy owner: engineering leads. Review cadence: every quarter.This outline is only a sketch. It shows the shape: a few principles, three categories of use, a named owner, and a review date. The following chapters explain how to decide each line.
Common objections
You will hear several objections when you propose a policy. Each has a reasonable answer.
| Objection | Response |
|---|---|
| "It will slow us down." | A short policy with automated checks adds little overhead. Rework from an incident usually costs more. |
| "We trust our developers." | The policy does not question trust. It gives trusted people the same facts and the same safety net. |
| "The tools change too fast." | Write principles that outlast tools, and keep tool-specific details in a list that you update often. |
| "We can't enforce it anyway." | Part of it you can. Required reviews, required tests, and protected paths enforce the rules without relying on memory. |
| "Our existing security policy covers this." | It probably covers part of it. Check it for gaps in data sharing, disclosure, and agent permissions. |
Common mistakes when starting
- Copying another company's policy. Their risk profile, tools, and regulators are not yours. Use theirs as a reference, then adapt it.
- Writing a long document nobody reads. One or two pages that people remember beat twenty pages they skip.
- Banning without alternatives. If the approved route is slower or worse than the unapproved one, people take the unapproved one.
- Writing rules with no owner. Every rule needs someone who can interpret it and update it.
- Treating the policy as a one-off. Without a review date, it will be wrong within a year.
Where this chapter fits
This chapter makes the case. It does not define the risks precisely, set the rules, or build the checks. The next chapter classifies the main risks into correctness, security, data, and licensing, so the later rules have something concrete to answer to.
Exercise
A teammate says, "We don't need a written AI policy. Everyone here already uses good judgment." Give three specific reasons from this chapter why that is not enough, and name one rule that you could enforce automatically instead of relying on judgment.
Show answer
Any three of these: judgment varies with experience, so less experienced developers may not spot subtly wrong AI output; judgment degrades under deadline pressure, when people accept suggestions unread; judgment cannot be audited after a leak or outage; new joiners cannot learn unwritten norms quickly. An automatable rule is a required CI test job together with branch protection, so that no pull request merges without passing tests whoever wrote the code. Required reviews from code owners on sensitive paths is another valid answer.
Exercise
Your team has no AI policy. List the five failure patterns this chapter describes, and pick the one that is most likely to apply to your own team, with a one-sentence reason.
Show answer
The five patterns are unreviewed plausible code, data leaving the organization, unclear ownership, uneven practice between team members, and surprise in audits or contracts. The choice of pattern is the learner's own. A good answer names one and ties it to something real, such as "data leaving the organization, because we often paste production logs into chat tools when debugging."