Sub topic 3
Can AI-generated code be copyrighted?
This chapter covers how copyright treats code that an AI assistant wrote or helped write. It assumes you have used an AI coding assistant, work with Git and code review, and know in general what open-source licenses are. It builds on the earlier chapters on copyright basics and human authorship. It does not cover differences between countries, which come next. The examples follow the United States approach unless stated otherwise.
This is general education, not legal advice. The law is still changing, and few court decisions address AI-generated code directly.
The working model
Copyright protects original expression created by a human author. Two questions follow for any piece of code:
- Which parts of the code did a human author, meaning the parts where a person made the creative choices?
- Which parts did the tool produce without that kind of human control?
The first set can be protected. The second set may not be protected by anyone. That does not mean it belongs to the AI. It means no one holds a copyright in it, so it may be effectively public domain.
Most real work falls in between. The useful skill is judging where along that range a given change falls.
Generated versus assisted
Two terms carry most of the weight in this area.
- AI-generated means the tool decided the expressive content. You gave a prompt, and the tool produced the code with little or no human creative control over the result.
- AI-assisted means a human made the creative choices, and the tool helped carry them out. Examples are autocomplete for code you were already writing, or a refactor you specified, reviewed, and reshaped.
The line between them is not a fixed percentage of AI-written lines. It depends on how much of the final expression traces to human decisions.
| Scenario | Human creative contribution | Likely copyright position (US view) |
|---|---|---|
| You write a function by hand, and the tool fixes a typo | High | Protected. You are the author. |
| You design the module and write most of it. The tool fills in boilerplate you then edit. | High | Protected. Your selection and edits are yours. |
| You prompt for a full module, then restructure and rewrite substantial parts | Medium | Your human-authored changes and arrangement are likely protected. The untouched generated parts are doubtful. |
| You prompt "write an HTTP retry client" and commit the output unchanged | Low | The generated expression is unlikely to be protected. |
| A script runs prompts in a loop and commits whatever comes out | Very low | Unlikely to be protected. |
What the US Copyright Office has said
The US Copyright Office (USCO) has published guidance and a report on this question. Its main positions, as of writing, are these:
- Prompts alone are generally not enough. Writing a prompt, even a detailed one, does not make you the author of what the model returns. The model fills in expressive details you did not specify, and the same prompt can yield different outputs.
- Human-authored material in the work is protected. If you wrote part of the code, that part is protected.
- Selection, coordination, and arrangement can be protected. If you choose and organize AI outputs and other material in a creative way, the resulting compilation can be protected. The protection covers your arrangement, not the underlying generated pieces.
- Modification can be protected. If you change AI output creatively, the human-authored changes can be protected.
- Using AI as a tool does not by itself defeat protection. The Office distinguishes tools that assist human expression from systems that determine the expression.
Two decisions give the principle a concrete form. In the Zarya of the Dawn registration decision (2023), the USCO protected the human-written text and the human arrangement of a comic. It refused protection for the Midjourney-generated images. In Thaler v. Perlmutter (D.C. Circuit, 2025), the court upheld the refusal to register a work that listed only an AI system as its author. The court confirmed that the Copyright Act requires a human author. That case concerned a work with no human author claimed at all. It does not decide how much human input is enough in a mixed work.
Why code is a special case
Software has some features that change how the analysis plays out.
- Functional constraints limit protection. Copyright does not cover ideas, methods, or functionality. If there is only one sensible way to write something, such as a standard algorithm, or if an API or language dictates the form, there may be little protectable expression in it anyway. This is true of human-written code too.
- Short, conventional snippets are weak candidates for protection. Generated one-liners and boilerplate often have too little originality to be protected, whoever wrote them.
- Code changes constantly. A file may be a mix of human lines, generated lines, and edits layered across many commits. Authorship is rarely a single clean event.
So the question is rarely "is this whole repository copyrighted?" It is usually "is there enough human-authored, original expression here to protect, and can I show it?"
A decision flow
Practical consequences
If some of your code is unprotected, several things follow.
- Others may be able to copy that part freely. A competitor could reuse unprotected generated code without infringing anything. Your license terms may not be enforceable on those parts.
- A license still has a role. Putting an open-source license header on a file does not create copyright that is not there. The license only works for the rights you actually hold.
- Trade secret and contract can still apply. Keeping code confidential, or restricting access by contract, can protect value even where copyright does not. Later chapters cover contracts and confidentiality.
- Registration needs honesty. In the US, when you register a work you generally must disclose AI-generated content that is more than minimal, and you disclaim it. Failing to disclose can put the registration at risk.
Copyright in the human-authored parts also does not clear you of other problems. Generated code can reproduce someone else's licensed code. That is a separate question about infringement and license obligations, covered in the chapter on license contamination.
Showing your contribution
Because the outcome depends on human input, evidence of that input is valuable. Good habits are cheap:
- Commit your own edits separately from raw generated output, so history shows what you changed.
- Record in the commit message that AI assistance was used and that a person reviewed it.
- Keep design notes, tickets, and review comments that show you chose the structure and behavior.
A commit message can record this. The trailer names below are a team convention, not a standard.
Add retry with exponential backoff to HTTP client
The retry loop was drafted with an AI assistant and then rewritten by hand.
I reviewed it for copied code and license notices.
AI-Assisted: yes
AI-Tool: example-assistant
Reviewed-by: Jane Developer <[email protected]>The chapter on provenance records returns to this in detail.
Common errors
- "The AI owns it." Current US law does not recognize AI systems as authors. The result is human authorship or none.
- "I wrote the prompt, so I own the output." A prompt can be protected as writing in its own right. That does not make the output yours.
- "Any edit makes it mine." A trivial change, such as renaming a variable, adds little protectable expression. Substantial, creative changes matter.
- "A license header makes it protected." A header states terms. It does not create rights.
- "Unprotected means safe." Code can be free of copyright yet still reproduce licensed third-party code, leak confidential material, or breach a contract.
- "The rules are the same everywhere." They are not. The next chapter compares the US, UK, and EU.
Exercise
A developer prompts an assistant for a complete CSV-parsing module and commits it unchanged. A week later, the developer rewrites the error handling, restructures the public API, and adds new tests by hand. Which parts are most likely protected by copyright under the US approach, and which are doubtful?
Show answer
The human-written tests, the restructured API design, and the rewritten error handling are most likely protected, because a person made creative choices there. The remaining parts of the original generated module that stayed untouched are doubtful, since a prompt alone generally does not make the prompter the author. The developer should keep the commits separate and note the AI assistance to make the human contribution easy to show.
Exercise
A teammate says, "Our license header says Apache-2.0, so all of this AI-generated file is ours and protected." What is wrong with that statement?
Show answer
A license header states the terms under which the project distributes a file. It does not create copyright. If parts of the file are unprotected generated output, there may be no rights to license in those parts. The file could also contain third-party code that carries its own license obligations.