AI-Generated Code and Copyright: 5 Myths, Tested
Is AI-generated code public domain? Does it inherit open source licenses? We test 5 copyright myths and give teams a provenance playbook that works today.

A developer on my old team once asked, half-joking, whether the 400 lines Copilot had just written for him belonged to the company at all. Nobody had a good answer, and the legal counsel we eventually asked gave the worst one: "it's unclear." That question is now sitting on top of the Hacker News front page in the form of a provocation — that all AI-generated code should be open source — and the thread underneath it shows just how badly our collective intuitions about copyright, training data, and authorship map onto what the law actually says. I've spent years both training models and shipping code written with them, so let me take the five beliefs I see repeated most confidently and test each against what we actually know.
Myth 1: "AI-generated code is public domain, full stop"
This is the myth with the most legal scaffolding under it, and it's still only half true. The US Copyright Office has been consistent: copyright protects human authorship, and purely machine-generated material isn't registrable. That position draws on the monkey selfie case (Naruto v. Slater), where the Ninth Circuit held that a macaque couldn't own the photo it took, and it survived a direct challenge in Thaler v. Perlmutter, where courts refused to register artwork listing an AI as sole author. So far, so clean.
But almost nobody ships purely AI-generated software. The Copyright Office's own guidance draws the line that matters in practice: using AI as an assistive tool doesn't defeat copyright in the work as a whole, and a human's selection, arrangement, and modification of AI output can itself be protectable expression. Your 50,000-line application where an agent wrote most of the functions but a human architected the system, chose the boundaries, reviewed and edited the output? That codebase is almost certainly copyrightable as a whole, even if any single generated function, viewed in isolation, might not be. The "it's all public domain" claim collapses the moment a human does anything more than paste a prompt and commit the result.
And the US isn't the world. The UK's Copyright, Designs and Patents Act explicitly grants protection to computer-generated works — attributing authorship to the person who made the arrangements necessary for creation — for fifty years. A handful of other jurisdictions have similar provisions. So the same file can be unprotectable in San Francisco and copyrighted in London. "Public domain, full stop" is not a legal position; it's a slogan that happens to point roughly at one country's doctrine for one narrow case.
Myth 2: "Trained on open source means the output inherits the license"
This is the moral engine of the "make it all open source" argument: models ingested decades of GPL'd, MIT'd, and Creative Commons work — Stack Overflow answers carry CC BY-SA, which legally requires attribution and share-alike — so turning that into proprietary code is license laundering. I have real sympathy for this. My own AGPL code is in those training sets. But as a legal claim, it has already been tested and it mostly lost.
In Doe v. GitHub, the Copilot class action, the court gutted the core theory that model outputs automatically carry the obligations of their training data. The DMCA copyright-management-information claims were largely dismissed, and the open source license claims mostly failed on standing — plaintiffs couldn't show their code was reproduced in the outputs. The judge's reasoning matters for your risk model: a license attaches to a copy. If the model never emits your code, there's no copy, no derivation, and nothing for the license to attach to. Statistical influence isn't copying, any more than a programmer who learned from reading Linux source owes the kernel a license on everything they write afterwards.
Here's the part people skip: the exception is real and it's the one that should keep you up at night. When a model does regurgitate training data near-verbatim — and earlier models did this with recognizable open source files, sometimes stripping the copyright headers — you can absolutely end up shipping a derivative of someone's GPL or AGPL code without knowing it. One commenter in the thread, an author of widely used AGPL systems, described exactly this: a company stripped his notices, got caught, and then had an LLM "clone" his system — buggier, but unmistakably his design. Whether that clone is a derivative work is genuinely unresolved, and it's the sort of question that gets answered expensively, in court, on a case-by-case basis. The blanket rule "output inherits training licenses" is false. The narrow rule "verbatim-ish reproduction is a live liability" is true. Smart teams plan for the second one.

Myth 3: "I wrote the prompt, so I own the code"
Flip the first myth over and you get this one, held just as confidently by people on the other side of the debate. The Copyright Office addressed it directly in its copyrightability report: prompts, by themselves, generally don't provide sufficient human control over the expressive elements of the output to make the prompter an author. The prompt is an instruction; the model makes the expressive choices. Courts have been applying the same logic to image generation for a while, and code isn't different in kind.
Where it gets genuinely interesting is iterative, agentic work. Several practitioners in the discussion described loops where the agent writes code for twenty minutes against hours or days of human testing, real-world feedback, redesign, and re-prompting. That pattern matters legally, because the strongest copyright theory for AI-assisted work isn't authorship of individual lines — it's the human's creative contribution to the work as a whole: selection, coordination, arrangement, and modification. A system shaped through hundreds of directed revision cycles looks a lot more like a compilation authored by a human than like the monkey's selfie. But notice what that implies: your claim to ownership rests on the process, and a process you can't document is a process you can't assert. If your company ever needs to enforce its copyright in that codebase — against an ex-employee, an acquirer's diligence team, a competitor — "trust me, a human was involved" is not evidence. This is why the pragmatic section below exists.
One more wrinkle that rarely comes up: employment and contractor agreements are doing most of the real work here anyway. Work-for-hire doctrine assigns the copyright — whatever copyright exists — to the employer. So the practical ownership question inside a company is usually settled by contract regardless of the authorship metaphysics. The uncomfortable question is what the contract is actually claiming, if pieces of the deliverable turn out to be unownable by anyone.
Myth 4: "Forcing AI code to be open source would fix the fairness problem"
Take the proposal seriously for a moment and it falls apart on contact with reality, for three independent reasons. First, it's self-defeating as a legal mechanism: open source licenses are copyright licenses. They exist to let a rights holder grant permissions on something they own. If AI-generated code is uncopyrightable, there is nothing to license — MIT, GPL, all of it is void for lack of subject matter. The only coherent version of the proposal is a public domain dedication like CC0, and a dedication you can't enforce isn't a mandate, it's a wish.
Second, the scope is unworkable. Open sourcing code is not a state, it's an act — someone has to scrub secrets, strip business logic, write a README, choose a repo. The overwhelming majority of the world's code is proprietary, embarrassingly specific to one company's internal process, and now overwhelmingly AI-assisted. What exactly would it mean to involuntarily publish all of it? Who pays for the sanitization pass that keeps your customer data out of the dump? Nobody proposing this has an answer, because there isn't one. We covered a related failure mode in AI-generated apps shipping without row-level security — the tooling happily produces code that leaks data when it works at all; now imagine mandating that this code be published.
Third, it wouldn't even achieve the stated goal. The grievance is that model vendors captured the commons. Forcing users of the models to publish their output doesn't make the vendors give anything back — it just strips protection from the one party in the chain with the least power. If you believe the training-data bargain was unfair, the remedy aimed at the people who wrote the code being scraped is a remedy aimed at the wrong target. The strongest version of the argument I actually agree with is the moral one, not the legal one: those of us benefiting enormously from a commons-trained tool have an obligation to put value back into the commons. Release libraries. Fund maintainers. Upstream your fixes. But that's an ethic to adopt, not a law that would survive first contact with a legislature.
Myth 5: "Our license scanner already handles this"
If only. License compliance tooling — the FOSSAs and Black Ducks of the world — is built on a provenance assumption that AI quietly breaks. These tools answer the question "what did you include?" by matching your dependencies and vendored files against known packages. They work because human-written code arrives through channels with metadata: package registries, copy-pasted files that retain their headers, vendored directories with LICENSE texts intact. AI-generated code arrives through a channel with no metadata at all. A model can emit thirty lines that are a near-paraphrase of an AGPL utility function, with no header, no attribution, and no package to match against, and your scanner sees original code. The risk isn't in your dependency tree; it's in your source files, where the tooling barely looks.
This is the same blind spot we've hit elsewhere: as with the LiteLLM supply chain incident, the failure wasn't in the code people reviewed but in a channel they trusted implicitly. The fix in both cases is to stop trusting the channel and start recording what flows through it. That's provenance tracking, and it's the thing your team should be doing this quarter regardless of how any court rules — because every plausible legal future (AI code is unprotectable, AI code is protectable if human-directed, verbatim reproduction is infringement) rewards the team that can show its work and punishes the one that can't.

What to actually do: a provenance and hygiene playbook
None of this requires new law or new vendors. It's four habits, all cheap, all defensible under any of the legal futures on the table.
- Mark AI assistance in commit metadata. Git trailers are made for this. An
Assisted-By:trailer costs nothing and builds an auditable record of which code had machine involvement — useful for diligence, for license review, and for demonstrating the human creative process that underpins your copyright claim. - Keep the human loop visible. PR descriptions that say "agent generated, I rewrote the retry logic and the boundary conditions" are legal evidence disguised as good hygiene. The review step is also where you catch the verbatim-regurgitation problem before it ships — we made a similar case in AI code comprehension checks vs tests: the human has to actually engage with the output, not rubber-stamp it.
- Scan for code, not just dependencies. Tools that do snippet-level matching against open source corpora (this is different from SCA dependency scanning) will catch the near-verbatim cases that create real copyleft exposure. Run them on AI-heavy commits, and set your AI tools' built-in duplication filters — Copilot's "block suggestions matching public code" setting — to the strict side.
- Treat copyleft as the boundary. Permissive licenses (MIT, BSD, Apache) pose minimal risk even in a verbatim-reproduction worst case. GPL and especially AGPL are where an accidental derivative gets expensive. If your scanning finds a match against copyleft code, rewrite from the spec, not from the snippet.
The commit-trailer convention is the highest-leverage piece and it's a five-minute setup. A prepare-commit-msg hook can prompt for it, and CI can enforce that the trailer exists when a PR is labeled AI-assisted:
#!/bin/bash
# scripts/check-provenance.sh — run in CI on pull requests
# Fails if a PR labeled "ai-assisted" has commits without an Assisted-By trailer.
set -euo pipefail
BASE="${1:-origin/main}"
missing=$(git log --format='%H %(trailers:key=Assisted-By,valueonly)' "${BASE}..HEAD" \
| awk '{ if ($2 == "") print $1 }')
if [ -n "$missing" ]; then
echo "These commits lack an 'Assisted-By:' trailer:" >&2
echo "$missing" >&2
echo "Add e.g.: git commit --trailer 'Assisted-By: claude-code (reviewed)'" >&2
exit 1
fi
echo "Provenance trailers present on all commits."
The trailer should record the tool and, crucially, that a human reviewed the output — Assisted-By: copilot (reviewed) tells a future auditor a very different story than Assisted-By: copilot alone. Pair this with a short section in your engineering handbook defining what counts as meaningful human contribution in your shop: architecture decisions, test design, non-trivial edits. You're not doing this because a court demanded it. You're doing it because whichever way the law lands, "we tracked it" beats "we have no idea."
The verdict
The law doesn't need to resolve whether AI code is ownable before you act: every plausible outcome rewards the team that documented its process and punishes the one that didn't.
So, tested against the evidence: AI-generated code is not blanket public domain, because human authorship over the work as a whole still counts and jurisdictions disagree. Training on open source doesn't make outputs open source — courts have largely rejected that theory — but verbatim reproduction is a genuine, under-appreciated liability. Prompting doesn't make you an author, though sustained, documented human direction probably does. A mandatory open source regime is incoherent as law and useless as policy. And your license scanner is blind to the exact channel that now produces most of your code. The debate about whether AI code should be free is a good argument to have over beers. The engineering answer doesn't wait for it: track provenance, keep humans visibly in the loop, scan at the snippet level, and treat copyleft as the tripwire. That's true today, and it stays true no matter how the courts eventually rule.


