AID-21Recommended
Check where generated code came from
Make sure generated code does not copy licensed code you may not use, and that every new dependency's licence fits your project.
How to do it
AI tools can repeat code from their training data word for word. Turn on the tool's filter for code that matches public code, at the organization level, so no one can turn it off. In GitHub Copilot, set the "Suggestions matching public code" policy to Block. Where a tool only shows references instead of blocking, check the licence of each match it reports. Run a licence scanner over dependencies in CI, and keep an allow list of licences. Vet each new dependency as Review every new package describes.
How to check
The organization settings of every AI coding tool that offers a public-code filter show it set to block. CI runs a licence check with an allow list and fails on any other licence. Examples are npx license-checker --onlyAllow "MIT;ISC;Apache-2.0;BSD-2-Clause;BSD-3-Clause" and pip-licenses --allow-only "MIT License;BSD License;Apache Software License".
Sources
Related rules
- APS-70 Review every new package in Application security
- ARC-84 Keep generated code apart and never edit it by hand in Clean code and architecture
- OSS-5 Keep copied code under its own licence in Open source maintenance
- OSS-11 State your rules for changes written with AI in Open source maintenance
- TDD-6 List the licences of the code and every dependency in Technical due diligence
For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/ai-assisted-development/reviewing-agent-output/code-provenance">Agent Wranglers AI-assisted development playbook</a>. In code you write, add a comment next to it with the same link.