# How do you check whether AI-generated code copied open source code?

Source: https://codelifter.com/forum/posts/how-do-you-check-whether-ai-generated-code-copied-open-source-code/
Site: CodeLifter Forum, category Code provenance
Published: 2026-11-26. Updated: 2026-11-26. Replies: 0.

## Question by CodeLifter editors (staff), 2026-11-26

No single tool proves AI-generated code is original, so check in layers. Turn on your assistant's public code matching if it has one, search distinctive lines with GitHub code search and a web search, scan the repository for licence and copyright notices with a tool such as ScanCode, and record what you find before you ship.

## Can an assistant reproduce open source code?

Yes, occasionally, and the vendors say so. GitHub's [responsible use page for inline suggestions](https://docs.github.com/en/copilot/responsible-use/inline-suggestions) says: "While the probability is low, Copilot may generate code suggestions that match code in the training set." Section J.2 of the [GitHub Terms of Service](https://docs.github.com/en/site-policy/github-terms/github-terms-of-service) (effective 27 April 2026) adds that output "may contain material that resembles code or content in the model's training data or that is subject to third-party copyrights or open source license terms", and leaves the licence question with you.

Two kinds of match deserve different worry. Short, common code (a loop to 100, a standard `debounce`, a fetch wrapper) appears in thousands of repositories in near-identical form because there are only so many ways to write it. Long, distinctive code, with unusual names, comments or structure, is more likely to trace back to one source. Spend your checking time on the second kind.

## Which checks catch what?

| Check | What it finds | What it misses |
| --- | --- | --- |
| Copilot public code matching | Accepted suggestions that match public GitHub code, with the file URL and licence | Code you wrote or edited, private code, code outside GitHub, other assistants' output |
| GitHub code search | Exact strings and symbol names in code GitHub indexes | Renamed variables, reformatted code, code hosted elsewhere |
| Web search on a distinctive line | Tutorials, forum answers, blogs, other hosts | Anything not indexed by the search engine |
| ScanCode Toolkit | Licence texts, licence notices and copyright statements in your files | Copied code that arrived without its notice |
| Your provenance record | Where you yourself pasted something from | Anything nobody wrote down |

![Table comparing five checks for copied open source code and what each finds and misses](/forum/img/posts/checks-for-copied-open-source-code-compared.webp "Five checks for copied code and their blind spots, from this article's table")

## How do you read Copilot's matches?

If you use GitHub Copilot, the [public code matching setting](https://docs.github.com/en/copilot/how-tos/manage-your-account/manage-policies) is under your profile picture, **Copilot settings**, **Suggestions matching public code**. Block hides matching suggestions; Allow shows them with references. With Allow, the [find matching code page](https://docs.github.com/en/copilot/how-tos/copilot-in-your-ide/copilot-for-common-tasks/find-matching-code) explains where the references land:

1. In Visual Studio Code, open **View**, then **Output**, and choose **GitHub Copilot Log (Code References)** in the dropdown.
2. In a JetBrains IDE, open **Help**, then **Show Log in Finder/Explorer**, open the log (for IntelliJ IDEA, `idea.log`) and search for `[Public Code References]`.
3. Each entry lists the file and line where you accepted the suggestion, then the matching files on GitHub.com with their licence, or `NOASSERTION` if no licence was found.

`NOASSERTION` does not mean free to use. Code with no licence is under default copyright. The [MIT licence thread](/forum/posts/can-you-put-ai-generated-code-under-the-mit-licence/) covers this feature's index limits in more detail.

## How do you search GitHub for a suspicious block?

GitHub's [code search syntax](https://docs.github.com/en/search-github/github-code-search/understanding-github-code-search-syntax) supports exact strings, symbol names, languages and filters:

1. Pick the most distinctive single line: an unusual comment, an odd variable name, a magic number. Whole functions rarely match exactly after formatting.
2. Search it in quotes, which matches "an exact string, including whitespace": `"maxRetries * backoffFactor + jitterMs"`. Escape inner quotes with a backslash.
3. Narrow it: add `language:javascript`, and `NOT is:fork` to drop copies of the same project.
4. Search the function name as a definition: `symbol:computeBackoffDelay language:typescript`. Symbol search finds definitions only, not calls.
5. Try a regular expression between slashes if the names may have changed: `/backoff.*jitter/`.
6. Open the oldest-looking result and read its `LICENSE` file. The earliest public copy is your best guess at the source, not proof.

Repeat the distinctive line in an ordinary web search; tutorials and forum answers often sit outside GitHub.

## What do you do when you find a match?

You have three options, in rough order of effort:

1. **Comply.** Keep the code and meet its licence: keep the copyright and licence notice, and for permissive licences that is usually enough. Mark the block with `SPDX-SnippetBegin` and `SPDX-SnippetEnd` and its own licence line, as the [SPDX header thread](/forum/posts/how-do-you-add-an-spdx-licence-header-to-a-source-file/) describes.
2. **Replace.** If the licence does not fit your project, delete the block and rewrite the function from its behaviour and tests, without the copy open.
3. **Swap in a dependency.** If the code came from a maintained library, install the library instead of carrying a copy of it.

Record the decision either way, with the source URL and the date you checked; the [provenance record thread](/forum/posts/what-should-a-provenance-record-for-copied-code-include/) lists the fields. The CodeLifter desk article on [snippet licensing](https://codelifter.com/provenance/snippet-licensing/) covers code from Stack Overflow and MDN, which carry their own terms.

## What can these checks not prove?

A clean result means you did not find a match, not that none exists. Private code, code outside the places you searched and reworded copies all pass. AI code detectors answer a different question, whether a model wrote something, not where it came from; the desk article on [AI code detectors](https://codelifter.com/provenance/ai-code-detector/) covers their limits. What you can show is that you checked with reasonable care, and when.

## Short version

- Assistants can occasionally reproduce code from their training data; vendors say so in their own documentation.
- Turn on public code matching where offered and read the reference log for accepted suggestions.
- Search distinctive lines with GitHub code search (`"exact string"`, `symbol:`, `NOT is:fork`) and the web.
- Scan for stray licence and copyright notices with ScanCode.
- On a match, comply, replace or swap in the library, and record what you did.

---
Cite as: CodeLifter Forum, "How do you check whether AI-generated code copied open source code?", https://codelifter.com/forum/posts/how-do-you-check-whether-ai-generated-code-copied-open-source-code/, accessed 2026-11-26.
