Can a teacher tell if a student's code was written by AI?
Not reliably from the code alone. Published studies find AI code detectors perform poorly and fail to generalise across languages and tasks, and OpenAI withdrew its text classifier in July 2023 for low accuracy after warning it was unreliable on code. Teachers get firmer evidence from the process: version history, drafts, and asking the student to explain the code.
Cite
CodeLifter Forum, "Can a teacher tell if a student's code was written by AI?", https://codelifter.com/forum/posts/can-a-teacher-tell-if-a-students-code-was-written-by-ai/, accessed 2026-11-12.- CodeLifter editorsStaffStaff, CodeLifter ·
Do AI code detectors work?
An AI code detector is a tool that scores a piece of code on how likely it is to have come from a language model. The research on them is consistent and not encouraging:
- Suh et al. (arXiv 2411.04299, 2024) tested existing detection tools on code and concluded that "they all perform poorly and lack sufficient generalizability to be practically deployed." Their best model reached an F1 score of 82.55, which still means a meaningful share of wrong calls.
- The DroidCollection work (arXiv 2507.10583) built a set of more than a million samples across 7 languages and 43 models, including code written by people and models together, and found that "existing detectors' performance fails to generalise to diverse coding domains and programming languages."
- Watermarking, where a model hides a statistical signal in its output, has its own problem: Lee et al. (arXiv 2305.15060) found existing methods "fail to function appropriately in code generation tasks due to the task's nature of having low entropy." Code that must compile leaves few free word choices to carry a signal.
General text detectors are weaker still on code. OpenAI's AI classifier announcement (31 January 2023) listed among its limits that it "performs significantly worse in other languages and it is unreliable on code", and a note added at the top says that as of 20 July 2023 the classifier "is no longer available due to its low rate of accuracy."
Short assignments make this worse. A function that reverses a string has a handful of correct forms, and a student and a model will often write the same one.
What can each method actually show?
Method What it measures What it cannot show AI code detector A statistical guess about style Who wrote the code; scores vary by language and model MOSS or another similarity checker How alike submissions are to each other Why they are alike, or whether a model was involved Public-code matching (for example Copilot's code referencing) Whether a suggestion matches public code Anything about code the student edited or wrote Version history (git, editor history, drafts) How the work grew over time Whether a pasted block came from a model or a classmate Asking the student to explain or extend the code Whether the student understands it Whether they wrote it, only whether they can work with it The rows near the bottom are the ones that hold up in a conversation with a student, because they rest on evidence the student can see and answer.
What signs do reviewers point to?
Some open source projects list signs they treat as suspect. GNOME's extension review guidelines say that "imaginary API usage, comments serving as LLM prompts, or other indications of AI-generated output will be rejected." Imaginary API usage means calling functions or options that the library does not have. In a classroom the equivalent signs are code that uses methods not taught or not in the language version the course uses, comments that read like instructions to a chatbot, and an import of a package that does not exist (see why AI code imports packages that do not exist).
Treat these as reasons to ask a question, not as findings. A student who reads ahead or copies from documentation produces some of the same signs.
How should a teacher handle a suspicion?
- Write the course rule down first. Say which uses of AI are allowed (explanations, debugging help, none at all) and whether students must disclose them. A rule announced after the fact is hard to apply fairly.
- Ask for process with the submission. Require the git history or the editor's version history, not only the final file. Commits spread over days look different from one commit with the finished program.
- Do not act on a detector score alone. OpenAI's own guidance for its classifier was that it "should not be used as a primary decision-making tool". The research above gives no reason to treat code detectors differently.
- Ask the student to walk through the code. Have them explain a function, predict an output, or make a small change in front of you. That tests the learning goal directly.
- Record what you saw. Keep the history, your questions and the answers, so a later review rests on the same facts.
The CodeLifter article on AI code detectors covers the research in more depth. If you are the student, can you prove you wrote a piece of code yourself? explains what records help, and a detector flagged code written in 2019 as AI covers what to do when a tool flags work that predates these models.
Why does understanding matter more than authorship?
For a course, the question underneath is usually whether the student learned the skill. A January 2026 Anthropic trial with 52 developers learning a new Python library found the group with an AI assistant scored 50% on a follow-up quiz against 67% for those who coded by hand, with the largest gap on debugging questions. An explanation or debugging check tests exactly that, whatever tool produced the first draft. The thread on whether vibe coding is bad for learning covers that study.
Short version
- Code-specific AI detectors perform poorly in published studies and do not generalise across languages and models.
- OpenAI withdrew its text classifier in July 2023 for low accuracy and had already said it was unreliable on code.
- Similarity checkers such as MOSS compare students with each other; they say nothing about models.
- Version history and asking the student to explain or change the code are firmer evidence.
- Set and publish the course's AI rule before the assignment, not after.
Write something first.
Give people something to work with: at least 30 words on what happened and what you tried.
That is too long. Keep it under 6,000 characters.
Write the question as the title, 15 to 140 characters, no links.
Pick a category.
Add a name (2 to 40 characters, no links).
That email address does not look right.
That was quick. Read the thread, then try again.
The form expired. Reload the page and post again.
Something went wrong with the form. Reload and try again.
Please complete the check and post again.
Limit reached for now. Try again later.
This thread is closed to new replies.
This thread no longer accepts replies.
Something went wrong with the form. Reload and try again.
Post a reply or question first (name and email), then this browser can vote, edit and accept answers.
You cannot vote on your own post.
Only the author (within 30 days) or the forum team can do that.
That email already has an account. Use your sign-in link instead.
New accounts are paused for the moment. Try again later.
That was already posted.
2 answers
- CodeLifter editorsStaffStaff, CodeLifter ·
Can MOSS detect code written by ChatGPT or another AI? No, that is not what it measures. MOSS, Stanford's Measure Of Software Similarity, compares the submissions you give it and highlights passages that match between them. Its own page says it "has no way of knowing why codes are similar" and that "it is a misuse of Moss to rely solely on the similarity scores." The page adds that it can automatically eliminate matches to code you expect to be shared, such as libraries or instructor-supplied starter code.
If several students pasted output from the same assistant for the same prompt, their submissions may show up as similar to each other, but MOSS reports that similarity the same way it would for two students who copied from one source. A person still has to look at the highlighted code and decide.
Two practical points from the same page, read on 16 October 2026: results "will contain copies of the code you submitted and these will be accessible to anyone with the result URL", and results are typically deleted after 14 days. Check your institution's rules on sending student work to an outside service before you submit it.
- CodeLifter editorsStaffStaff, CodeLifter ·
Do AI detectors give false positives on student code? They can, and short code is the hardest case. The clearest published numbers come from a vendor describing its own tool. OpenAI's classifier announcement reported that on its English challenge set the classifier correctly flagged 26% of AI-written text and wrongly labelled human-written text as AI-written 9% of the time. It also said the classifier was "very unreliable on short texts (below 1,000 characters)", that human text was sometimes "incorrectly but confidently labeled as AI-written", and that it was unreliable on code. It was withdrawn in July 2023.
Many student exercises are shorter than 1,000 characters. There is also a structural reason, given in the same list of limits: "Text that is very predictable cannot be reliably identified." A correct loop that sums a list is predictable whoever writes it, which is the same low-entropy problem that defeats watermarking for code. A flag on a short, standard solution tells a teacher very little, so treat it as a prompt to look at the student's process, not as a result.