AI coding policy template for engineering teams (free)
Matt · · Last updated · 8 min read · Guides
A free AI coding policy template: the 8 sections that matter, why each rule is there, how to enforce them and roll it out. Download it as .docx or .md.
On this page
An AI coding policy says which AI tools may touch company code, what data they may see, who reviews their changes and what must pass before a merge. This free template covers that in eight sections that do the work, and this post explains each rule and how to turn it into a setting, so it holds on the day nobody remembers it. This is a starting template, not legal advice.
Why you need one
Most engineering teams already use AI coding tools. Fewer have written down the rules for them. The usual state is a mix: some people use the company's assistant, some use a personal account, a coding agent was set up by one team for one repository, and nobody is sure whether customer data has ever been pasted into a chat window.
A policy fixes that, but only if it is short enough to read and specific enough to enforce. The AI coding policy template tries to be both. It has fifteen short sections: the eight below, plus the frame every policy needs (purpose, scope, definitions, roles, training and when to review it). One definition does a lot of work: the requester, the person who gave the tool its task, is the author of the change. So "the AI wrote it" is never an answer to "who is responsible for this?"
The 8 sections of the policy
1. Approved tools
Section 4 of the template is a table of the tools allowed on company code, what each may be used for, and the most sensitive data each may see. It doesn't ban any tool. Anything not on the list isn't allowed for company code until someone approves it. A ban list is out of date the week after it is written; an approved list fails safe.
The request process asks the questions that matter for an AI tool: what data it sends and where, how long the vendor keeps it, whether it trains models on it, and what the tool can do without a person. If you need more depth, the vendor security questionnaire template has thirty questions, with notes on what a good answer looks like. Every row has an owner, because a rule with no owner gets no updates.
2. Data and secrets
Section 5 defines four data classes, from public to restricted, and which may go into which tool. Secrets and personal data never do. This is the section people break by accident, so back it with a secrets scan in CI and the tool's own data controls.
3. Review requirements
Section 7 says a person reviews every AI-assisted change, the requester isn't the only approver when someone else can review, and an approval applies to one version: an edit means approving again. With agents that last rule matters more than it used to, because a follow-up "small fix" can be bigger than it looks. The human approvals guide covers where a person has to stay in the loop. On GitHub, the review rules map onto branch protection. In a branch protection rule for main, turn on:
| Setting | Policy rule |
|---|---|
| Require a pull request before merging | 6.1: agents never push to main |
| Require approvals | 7.1: a person reviews every change |
| Dismiss stale pull request approvals when new commits are pushed | 7.5: an approval is for one version |
| Require approval of the most recent reviewable push | 7.2: someone else approves |
| Require review from Code Owners | 6.3: protected paths need an owner |
| Require status checks to pass before merging | 8: the quality gates |
| Do not allow bypassing the above settings | Exceptions go through section 13 |
The last one matters more than it looks. Without it, an admin's merge skips every rule above, and admins are often the people setting up agents.
4. Gates
Section 8 lists what must pass before a merge, checked by automation: tests on the exact version, no open finding of high severity or above, no secrets, no disallowed licenses, and optionally a coverage floor and a staging deploy. It ends with a sentence that is easy to miss: a gate that could not run counts as a failure, not a pass. The alternative is a pipeline that is green exactly when it checked least.
If you use AI CodeOps, the release gate checks most of section 8 in one call from CI, and the step fails unless the answer is allowed:
curl -sf -X POST "https://console.aicodeops.dev/api/release/check" \
-H "Authorization: Bearer $WORKSPACE_API_KEY" \
-H "Content-Type: application/json" \
-d "{
\"pullRequestURL\": \"$PR_URL\",
\"blockingSeverity\": \"high\",
\"minCoveragePct\": 80,
\"disallowedLicenses\": [\"AGPL-3.0\"],
\"requireDeployedTo\": \"staging\"
}" \
| jq -e '.allowed == true'
Each field is one line of section 8: blockingSeverity is rule 2, disallowedLicenses is rule 4, minCoveragePct is the optional rule 5 and requireDeployedTo is rule 6. Failing tests block by default, which is rule 1. The 80 and the license list are examples: use your own. Secrets scanning, rule 3, stays a separate step in your pipeline.
5. Licensing
Section 9 asks engineers to check that AI-suggested code isn't copied from a source whose license you can't accept, and to turn on the tool's filter for suggestions that match public code where one exists. New dependencies an AI tool suggests go through the same approval as any other. Code an AI tool writes for the company is company code, and the requester and approver answer for it. The disallowed license list in section 8 is where this becomes a check.
6. Security
Section 6 limits what coding agents may do. They work on branches and never push to main, never hold production credentials, can't deploy to production, and need a code owner's approval to change the paths that matter. Section 11 covers incidents: a suspected data leak into a tool is reported the same day, and an incident caused by an AI-assisted change gets a blameless postmortem.
Section 6.3 lists the paths agents may not change without their owners' approval. The matching CODEOWNERS file looks like this:
# Policy 6.3: paths a coding agent must not change alone.
* @your-org/maintainers
/.github/workflows/ @your-org/platform
/infra/ @your-org/platform
/src/auth/ @your-org/security
/migrations/ @your-org/data
package.json @your-org/platform
/.github/CODEOWNERS @your-org/maintainers
Order matters: GitHub's code owners docs say "the last matching pattern takes the most precedence" (checked on 24 October 2026), so the catch-all goes first. The last line protects the file itself, so a pull request can't remove its own reviewers. The CODEOWNERS starter has a longer version with comments.
In AI CodeOps, the same limits are a workspace policy: rules that allow an action, hold it for a person's approval, or deny it. Sections 6.3 and 6.4 become:
[
{ "id": "policy-6-3-ci", "action": "diff.apply", "resource": ".github/workflows/**", "decision": "ask" },
{ "id": "policy-6-3-infra", "action": "diff.apply", "resource": "infra/**", "decision": "ask" },
{ "id": "policy-6-3-migrations", "action": "diff.apply", "resource": "migrations/**", "decision": "ask" },
{ "id": "policy-6-4-no-prod", "action": "release.deploy", "resource": "production", "decision": "deny" }
]
The strictest matching rule wins, so adding a rule can never loosen another. The policy rules reference lists every action and what it matches. Start it in log-only mode: every decision is recorded but nothing is blocked, so you can see what the rules would have stopped before you enforce them.
7. Audit
Section 10 asks you to keep, for each change, the task, the tool, the requester and approver, the findings, the test results and the deploy. Most teams have these spread across five systems. In AI CodeOps they are in the audit log and, per change, in a signed evidence pack that anyone can verify without an account. The audit and access page covers both, and the regulated teams page covers how they fit together for teams in regulated industries.
8. Exceptions
Section 13 says an exception is requested in writing, with the reason, the risk and an end date (the template suggests no more than 90 days), and is recorded and reviewed when it ends. "Do not allow bypassing the above settings" in branch protection is what makes this section real: without it, an admin's merge is an unrecorded exception.
What the template leaves out
It doesn't name tools: which assistant or agent is right depends on your stack, contracts and data. It doesn't set a coverage number or a severity threshold, because a floor that fits a payments service is wrong for a prototype. It doesn't try to be a full AI governance framework; model risk and AI inside your product are separate questions with their own owners. And it isn't legal advice. Contracts, regulation and intellectual property belong with your legal team, who should read your version before it takes effect.
How to roll it out
A policy that arrives as a surprise gets ignored. This order works better:
- Fill in the tool table first. List what people already use, and approve what you can. Starting from reality makes the rest credible.
- Share the draft with the engineers who use the tools most. They know which rules would block real work, and which ones they would happily follow.
- Turn on the settings in log-only or advisory mode where you can. Look at what would have been blocked. Fix the rules that are wrong.
- Publish the policy and enforce the settings on the same day. The document says why; the settings make it true.
- Put the review date in the calendar. The template says every six months, and whenever you adopt a new kind of tool.
Reviewers will also need to know what to look for once the policy says every change gets a human review. The AI code review checklist is 25 checks for agent-written code, and the quality gates guide explains the gate side.
Download the template
The AI coding policy template is free, licensed CC BY 4.0: copy it, change it and use it. Download it as .docx or .md from the page. Have your security team read your version as well as legal. This is a starting template, not legal advice.
Key takeaways
- An AI coding policy only works if each rule becomes a setting: branch protection, code owners, CI gates and agent permissions.
- Approve tools by list, not by ban, so a new tool starts outside the policy.
- The person who wrote the task is the author of the change, and can't be its only approver.
- A gate that couldn't run is a failure, and an approval is for one version.
- Give every rule an owner and a review date, and start the settings in log-only mode before you enforce them.
Frequently asked questions
What should an AI coding policy include?
At least approved tools, data and secrets rules, review requirements, quality gates, licensing, security limits for coding agents, audit records and an exceptions process. The template covers these, plus scope, roles, incidents and training.
Should an AI coding policy ban tools?
An approved list works better than a ban list. Anything not on the list isn't allowed for company code until someone approves it, so a new tool starts outside the policy instead of slipping through.
Is this AI coding policy template legal advice?
No. It is a starting template, not legal advice. Have your legal and security teams read your version before it takes effect.