Sub topic 9
Disclosing AI assistance
This chapter assumes you know the basic pull request workflow, have taken part in code review, and have used an AI coding assistant. It builds on the previous chapters on author accountability and review. It covers what disclosure is, what a team should ask authors to disclose, and how to make disclosure easy to do and hard to skip.
What disclosure is for
Disclosure means telling reviewers and the team that an AI tool helped produce a change. It does not shift responsibility. The earlier chapter on accountability set the rule that the author owns the change, whatever tool wrote the lines. Disclosure supports that rule in three ways:
- Review calibration. A reviewer who knows a block of code was generated can look harder for plausible but wrong logic, invented APIs, and missing edge cases.
- Traceability. If a defect or a licensing question appears months later, the team can find which changes involved AI tools and which tool was used.
- Policy compliance. Disclosure shows whether the team's approved-tool list and data-sharing rules are being followed. It also shows where the rules are being ignored.
Disclosure is not a confession. If the team treats it as one, people will stop doing it. The policy should say plainly that using an approved tool in an allowed way is normal, and that the reason to disclose is information, not blame.
Deciding what to disclose
Disclosing every autocomplete suggestion is impractical. A policy needs a threshold. Common options are below.
| Approach | What authors disclose | Strength | Weakness |
|---|---|---|---|
| Disclose everything | Any AI suggestion accepted | Complete record | Noisy, hard to follow, people ignore it |
| Disclose by scope | AI tool used for part or all of a change, with a short description | Practical, readable | Authors must judge what counts as "part" |
| Disclose by area | Only changes in restricted paths such as auth or payments | Low effort | Misses risk elsewhere |
| No disclosure | Nothing | No overhead | Reviewers and auditors have no signal |
Most teams do best with disclosure by scope, combined with a stricter rule for restricted areas. A workable threshold looks like this:
- Always disclose when an AI tool generated a function, a file, a test suite, a migration, a configuration, or any change an agent made on its own.
- Always disclose any AI-assisted change to a path covered by a restricted-use rule, such as authentication or payments code.
- No need to disclose routine inline completion of a few tokens, spell fixes, or using a chat tool to explain existing code without pasting its output into the change.
Write the threshold down with examples. "Substantial" and "meaningful" are vague words. A reviewer and an author will read them differently, and the gap is where disclosure fails.
What a useful disclosure contains
A checkbox that says "AI used" gives a reviewer very little. A useful disclosure answers four questions:
- Which tool? The name and, if the team tracks it, the model or version.
- What scope? Which files, functions, or tests came from the tool.
- How was it checked? What the author did to verify the output, such as reading every line, running tests, or writing new tests.
- Was anything restricted shared? A confirmation that no secrets, customer data, or restricted code went into the tool, in line with the data confidentiality rules.
Putting disclosure in the pull request template
The pull request template is the most reliable place to collect disclosure. It appears for every author at the moment they describe the change, so it needs no extra tool or habit. The example below combines verification and disclosure in one template.
<!-- .github/pull_request_template.md -->
## What changed and why
## How I verified it
- [ ] I read and understand every line in this PR
- [ ] I ran the tests locally
- [ ] New or changed behavior has tests
## AI assistance (per team policy)
- [ ] No AI tool was used
- [ ] AI tool used for part of this change (tool and scope: ____ )
- [ ] No secrets, customer data, or restricted code were shared with the toolThree design choices in this template are worth noting.
First, the disclosure section sits directly under the verification section. The author states what they checked in the same place where they state what the tool did.
Second, "No AI tool was used" is an explicit option. A blank section is ambiguous: the author may have skipped it, or may have used no tool. Requiring a positive answer removes the doubt.
Third, the last checkbox ties disclosure to the data rules. It is a reminder at the moment of submission, not a control. A checkbox cannot prove that no secret was shared. Other controls, covered in the chapter on automated guardrails, back it up.
Other places to record disclosure
The template is the default, but teams use other channels too.
- Commit trailers. A line such as
Assisted-by: ToolNameat the end of a commit message stays attached to the change in history. It survives squash merges only if the squash message keeps it, so check how your merge settings build the final message. - Labels. A pull request label such as
ai-assistedlets you filter and count changes. Labels are easy to query but carry no detail. - Code comments. Use these sparingly. A comment saying "generated by a tool" ages badly and says nothing about whether anyone checked the code. A comment explaining a non-obvious decision is more useful, whoever wrote it.
Here is an example of a commit message with a trailer.
Add retry with backoff to the webhook sender
Retries failed deliveries up to five times with exponential backoff.
Added tests for the timeout and the permanent-failure paths.
Assisted-by: ExampleAssistant (initial draft of retry loop and tests)The trailer names the scope in parentheses. A future reader can see that the retry loop and tests started as tool output, and that the commit message itself was written by a person.
How disclosure changes review
Disclosure only matters if reviewers act on it. The policy should say what a reviewer does differently when a change is marked AI-assisted. Reasonable expectations include:
- Check that every API, function, and package the code uses actually exists and is used correctly. Generated code can invent plausible names.
- Check that tests exercise real behavior and are not assertions that pass regardless of the code.
- Look for code that is more general or more elaborate than the task needed.
- Check that licensing and dependency additions went through the normal approval path.
The reviewer is not expected to review a disclosed change in a different spirit, only with attention to the failure patterns that generated code tends to show. The standard for approval stays the same. See the review chapter for the full checklist.
Limits of disclosure
Disclosure is based on honesty, and a team should know where it falls short.
- It cannot be verified by inspection. Nobody can reliably tell from the diff whether a tool wrote it. Detection tools for AI-written code are unreliable and produce false accusations. Do not build enforcement on them.
- Authors may under-report. If disclosure leads to slower reviews, extra scrutiny, or negative judgment, people will skip it. Watch the incentives.
- Tools differ. Some editors insert suggestions with no visible marker. Others record agent sessions. If your approved tools can log their usage, a team administrator can compare those logs with disclosures, in aggregate, to see whether the policy is being followed.
- Over-disclosure creates noise. If every pull request carries a long disclosure, reviewers stop reading it.
Because of these limits, pair disclosure with controls that do not depend on it: required tests in CI, protected branches, and code owner review for sensitive paths. The CODEOWNERS file below sends changes in sensitive directories to named reviewers, whether or not anyone disclosed AI use.
# .github/CODEOWNERS
# Changes to these paths always need review from the named owners,
# no matter how the code was written.
/auth/ @example-org/security-team
/payments/ @example-org/payments-team
/.github/ @example-org/platform-team
/docs/policies/ @example-org/engineering-leadsDisclosure outside the team
Some disclosure duties come from outside the repository. Check these with your legal or compliance contacts:
- Open-source projects. Many projects publish their own rules on AI-generated contributions. Some require disclosure, and some do not accept such contributions at all. Read the contributing guide before you send a change upstream.
- Customers and contracts. Some contracts restrict the use of AI tools on customer code or require notice. A team that works under such a contract should add a rule to the policy.
- Regulated work. In regulated industries, auditors may ask how code was produced. A consistent disclosure record answers that question.
Common mistakes
- Making the form too long. A five-question disclosure will be answered with default checkmarks. Keep it to the tool, the scope, and the verification.
- Leaving the threshold undefined. If "AI-assisted" is not defined, authors guess, and the record is inconsistent.
- Using disclosure as a penalty. Avoid putting AI use in performance reviews as a negative. Judge the quality of the change and the author's ownership of it.
- Treating the checkbox as proof. A ticked "no secrets shared" box does not mean it is true. Back it with secret scanning and clear data rules.
- Ignoring the data. If nobody ever reads the disclosure record, it is a cost with no return. The last chapters on metrics and feedback return to this point.
Summary
Disclosure gives reviewers and the team the context they need to review well and trace problems later. Define a clear threshold with examples, collect the tool, scope, and verification in the pull request template, and use trailers or labels if you need history you can search. Keep disclosure low-friction and blame-free, and never let it replace controls that work without anyone's honesty.
Exercise
Your team's template has one checkbox, "AI used in this PR," and a reviewer notices that about half of all pull requests leave it blank. Give two likely causes and one change to the template or policy for each.
Show answer
Cause 1: A blank box is ambiguous, so authors who used no tool skip it, and authors who used one cannot tell what counts. Change: add an explicit "No AI tool was used" option and define the disclosure threshold with examples. Cause 2: Authors fear that disclosure leads to extra scrutiny or blame, so they skip it. Change: state in the policy that using approved tools in allowed ways is normal, keep the form short (tool, scope, verification), and make sure reviewers and managers do not penalize disclosure. Optionally, add a CI check that fails when the section is missing entirely, so a blank answer is no longer possible.
Exercise
A change touches /payments/ and was partly written by an agent. The author did not disclose it. Which controls in this chapter still apply, and why does that matter?
Show answer
The CODEOWNERS rule still routes the change to the payments team, and the required CI test job still has to pass, because both work from the paths and the code and do not depend on disclosure. This matters because disclosure relies on honesty and cannot be verified from the diff, so sensitive areas need controls that apply to every change.