Sub topic 15
Measuring whether the policy works
This chapter assumes you have a written AI-assisted code policy that has already been rolled out. It also assumes you know pull request workflows and basic CI. A policy that nobody measures tends to drift. Measurement tells you whether the rules reduce risk, and whether they cost more effort than they are worth.
Decide what you want to learn
Start from the policy's goals, not from whatever data is easy to collect. Each goal gets one or two signals.
| Policy goal | Signal | Where it comes from |
|---|---|---|
| Authors own their changes | Share of AI-assisted PRs with the checklist completed | PR template |
| Reviews stay effective | Review time and comments per PR, AI-assisted vs. other | Git host |
| Quality does not drop | Rate of reverted commits and bug reports per change | Git history, issue tracker |
| Guardrails work | CI failures on policy checks, bypass attempts | CI logs, branch protection audit log |
| Data stays protected | Secret-scanner findings, reported incidents | Scanner reports, incident log |
| The policy is usable | Exception requests and developer survey answers | Exception log, survey |
Collect signals you already have
The PR template from the disclosure chapter already records AI use. You can count it with a short script. This example uses the GitHub CLI and jq, and it assumes the template's checkbox text is unchanged.
#!/usr/bin/env bash
# Count merged PRs from the last 30 days and how many declare AI use.
since=$(date -d '30 days ago' +%Y-%m-%d)
gh pr list --state merged --search "merged:>=$since" --limit 500 \
--json number,body > prs.json
total=$(jq 'length' prs.json)
ai=$(jq '[.[] | select(.body | test("\\[[xX]\\] AI tool used"))] | length' prs.json)
echo "Merged PRs: $total"
echo "Declared AI use: $ai"The date -d form works with GNU date on Linux. On macOS, use date -v-30d +%Y-%m-%d instead.
Read the numbers carefully
Metrics can mislead. Keep these points in mind.
- Disclosure counts are self-reported. A falling number may mean people stopped declaring, not that they stopped using the tools.
- Do not rank people by AI use or by lines produced. This pushes developers to hide usage, and it weakens the disclosure rule.
- Compare like with like. Compare AI-assisted and other PRs of similar size and in the same area of the code.
- Small samples are noisy. One revert in a team of five says little. Look at trends over several months.
- Zero incidents is not proof of safety. It can also mean that problems are not being noticed or reported.
Add a human check
Numbers show what happened. They do not show why. Run a short survey every quarter, with questions such as:
- Is the policy clear enough that you know what is allowed?
- Have you needed an exception? Was the process quick enough?
- Which rule costs you the most time for the least benefit?
Pair the survey with a review of the exception log. Many repeated requests for the same exception suggest the rule itself needs changing.
Act on what you find
Set a fixed review time, such as quarterly, and write down one decision for each signal that moved. Examples:
- Checklist completion is low. Make the checklist items shorter, or add a CI check that fails when the AI section is empty.
- Reverts are rising in one directory. Add it to CODEOWNERS or require tests there.
- Many exceptions ask for the same tool. Consider approving it through the tool approval process.
Exercise
Your quarterly data shows that declared AI use dropped by half, while the number of reverted commits did not change. A manager proposes rewarding teams with the highest declared AI use. Is that a good idea, and what would you check first?
Show answer
It is not a good idea. Rewarding declared use mixes up adoption with policy health and gives people a reason to over-report or under-report. The drop is self-reported, so first check whether developers stopped declaring (for example, because the checklist is annoying or they fear judgment). Read the survey answers and sample some merged PRs for signs of AI-generated code. Keep reverts as the quality signal, and keep disclosure as a transparency signal, not a score.