How to tell if code was written by ChatGPT, Claude or Copilot
AI assistants now write a large share of the code students and candidates hand in. Some of it is permitted, some of it is not, and almost none of it leaves a source to match. This guide sets out the signs that actually distinguish generated code, how much weight each one deserves, what an AI code detector adds on top of a careful read, and how to reach a conclusion you can defend.
Checks every file against classmates, the web and AI, in 65+ languages.
Why AI-generated code is hard to spot
Copied code has a source. Find the source and you can put the two files side by side, line for line. Generated code has no source. ChatGPT, Claude, Gemini and Copilot write new text every time, so a plagiarism search that looks for matches online or between classmates will usually come back empty even when every line came from a model.
That leaves two kinds of evidence: how the code is written, and whether the author understands it. Both are real evidence, and both are softer than a match. The practical consequence is that you are always weighing probabilities, and the discipline is in not letting one striking detail carry more weight than it can bear.
It also helps to be precise about the question. "Did a model write this?" is rarely what matters. What matters is whether the work breaks the rules that applied to it. A course that allows AI with disclosure, an interview that bans it, and a contract that says nothing about it each turn the same code into a different case.
The signals, ranked by what they are worth
Reviewers who have read a lot of generated code tend to converge on the same list. What separates a sound judgement from a hunch is knowing which items are weak alone and which are hard to explain away.
| Signal | Strength | Why |
|---|---|---|
| Code uses methods, libraries or syntax the course has not covered, and the author cannot explain them | Strong | The gap between the code and the author's understanding is the clearest evidence there is. |
| A sudden change in style or quality against the author's earlier work | Strong | People change gradually. A jump from week four to week five is worth a conversation. |
| Solves a slightly different problem than the one set | Strong | Models answer the prompt they were given. A student who pasted half the specification gets code for half the specification, often fluently. |
| Leftover conversational text: "Here is the updated function", "Note: you may need to" | Strong | Rare, but almost impossible to explain any other way. |
| Defensive handling the task did not need: input validation, broad exception catching, edge cases nobody asked about | Moderate | Models are trained to be thorough. Beginners rarely are, unless taught to be. |
| A docstring or comment on every function, in the same register | Weak | Common in generated code, and also in the work of conscientious students. |
| Textbook variable names and very regular formatting | Weak | Formatters and linters produce exactly this. Many courses require them. |
| "It is too good for this student" | Not evidence | Students improve, get help that is allowed, and sometimes are simply better than expected. |
A useful habit is to write down which signals you saw before you form a view. A case that rests on three weak signals is still a weak case. A case with one strong signal and a student who cannot explain the code is a strong one.
Chat assistants, autocomplete and agents leave different traces
"AI-written" covers three quite different ways of working, and they leave different evidence.
Chat assistants
ChatGPT, Claude and Gemini in a chat window. The author pastes a task and copies back a complete answer. The result tends to be whole functions or whole files in one consistent voice, with explanatory comments and tidy structure. This is the easiest kind to spot, because the whole file shares the habits.
Inline completion
Copilot, Cursor and similar tools suggest the next lines as the author types. The result is a blend: the author's structure with generated stretches inside it. The signal is patchier, and a per-file score understates it. More in detecting Copilot and Cursor code.
Coding agents
Tools that edit a whole project from an instruction. Large, consistent changes across many files at once, often with tests and a README the assignment never required. Commit history, if you have it, shows big atomic changes rather than incremental work.
Generated, then disguised
The author asks the model to "write it like a beginner", or rewrites the output by hand. This is the hardest case. The structural habits fade, and the conversation with the author becomes the main evidence.
What an AI code detector adds
A human reviewer is good at noticing one striking thing and poor at weighing a hundred small ones consistently across a class of two hundred. That is the job a detector does. Rather than look for a watermark, which most code does not carry, a detector trained on code looks at how the code is written: its structure, its naming, its comment patterns, how it handles errors, and many features no reviewer would think to count. It returns a likelihood that the file was generated.
Three properties separate a detector you can use from one you cannot:
- It shows its reasons. A number alone cannot be checked. Codequiry lists the reasons behind each AI result and marks the passages that drove it, so you can read them and agree or disagree.
- It is trained on code, not prose. Text detectors applied to code produce nonsense, because code is formulaic by nature. This is also why Codequiry does not run its code detector on essays; see AI detectors for essays.
- It sits beside a source search. Generated code sometimes does match something, because a model reproduced a well-known solution or a classmate shared the same output. A check that searches classmates, the web, GitHub and Stack Overflow and also runs AI detection shows you both pictures together.
Codequiry's AI detection is built to flag code from GPT models, Claude, Gemini, Copilot, Grok and other large language models across the languages it checks. For how these scores are produced and how often they are wrong, read how AI detectors work. For why no detector can reliably name the model, see detecting code by Claude, ChatGPT, Codex or Gemini.
Check a file for AI-written code
An AI likelihood for every file, the reasons behind it, and a search for copied code in the same run.
A review you can defend
- Start from the rules. Read what the assignment or interview allowed. If AI use was permitted with disclosure, look for the disclosure before looking at the code.
- Check for copying first. A match against a classmate or a public repository is much stronger evidence than any AI score, and it changes the question.
- Read the AI result with its reasons. Treat a high likelihood as a reason to look closer. Read the flagged passages and decide whether the reasons hold for this code.
- Compare with earlier work. The same author's previous submissions are the best baseline you have. Style, naming and the kinds of mistakes they make are usually consistent.
- Look at process evidence. Commit history, autosaves, drafts and lab session logs show code being built over time, or arriving all at once.
- Talk to the author. See the next section.
- Write down what you relied on. If the case goes further, the record of which evidence you weighed matters more than the score.
The conversation that settles most cases
Ten minutes with the author resolves more AI cases than any tool. Done well, it is fair to an honest student and very difficult for a dishonest one. A structure that works:
- Ask them to walk through the code. Not "did you write this?", which invites a yes, but "talk me through how this function works".
- Ask about decisions. Why this data structure? What else did you try? What broke along the way?
- Ask for a small change. Add a case, change a rule, fix a planted bug. An author makes the change quickly in the code they know. Someone who pasted it has to read it as a stranger would.
- Ask about the unusual parts. The library call the course never covered, the edge case nobody asked about. Authors remember why they did those things.
Keep it a conversation rather than an interrogation, and accept a good answer. A student who explains every line and changes it on the spot has almost always written it, whatever a score says.
Where the evidence stops
No method, human or automated, can tell with certainty whether a model wrote a given file. A careful human can write code that reads as generated; generated code can be reworked until it reads as human. An AI result is a likelihood about style, and a conversation is evidence about understanding. Neither is a confession. Decisions should rest on the whole picture, made under a written policy, with the student given the evidence and a chance to respond.
If you are setting that policy, the collaboration policy template has wording for AI use and disclosure, and preventing plagiarism in programming assignments covers assignment designs that make undisclosed AI use harder and less tempting.
Frequently asked questions
Can you tell if code was written by ChatGPT?
Often, but not with certainty. Code from chat assistants has recognisable habits: uniform comments on every block, defensive checks the task never asked for, textbook naming, and a polish that does not match the author's other work. An AI code detector weighs many of these signals at once and gives a likelihood. The strongest confirmation is still asking the author to explain and change the code.
Is there a ChatGPT code detector that works on Claude, Gemini and Copilot too?
Detectors that look at how code is written, rather than for a hidden mark, are not tied to one product. Codequiry's AI detection is built to flag code from GPT models, Claude, Gemini, Copilot, Grok and other large language models, and reports a likelihood for each file with the reasons behind it.
Do comments prove code was AI-generated?
No. Thorough comments are a habit of AI assistants, but they are also a habit of careful students and of anyone taught to comment every function. Comments are one signal among many and weak on their own.
Can AI-generated code be detected after it has been edited?
Partly. Renaming variables and reformatting rarely remove the structural habits a detector looks at. Heavy rewriting, by hand or by asking the model to imitate a beginner, lowers the signal, sometimes below what any detector can see. That is why a low score is not a clean bill of health.
Does AI-generated code show up in a plagiarism check?
Usually not as a match. Generated code is new text, so there is rarely a source to find. It needs a separate check that looks at how the code is written. A full check runs both: a search for copied code and AI detection.
What should I do if I think a student used AI?
Check your course policy first, since many courses now permit some AI use with disclosure. Then look at the evidence on the page, compare with the student's earlier work, and talk to them. Ask them to walk through the code and make a small change. Never act on a detector score alone.
Is it plagiarism to use ChatGPT for code?
It depends on the rules of the course or employer. Where AI use is not allowed, or is allowed only with disclosure, submitting generated code as your own is an integrity violation. Where it is allowed, it is not.
See how the code was written
AI detection with reasons, alongside a search of classmates, the web, GitHub and Stack Overflow.
Start a check Pay as you go with credits. Comparing files is free.