False positives in AI code detection

Every AI detector, for code or for prose, will sometimes flag work a person wrote. The detectors that do this least are the ones designed to, and the institutions that handle it well are the ones that planned for it before the first disputed case. This guide explains why honest code gets flagged, which code is most exposed, and how to run a process in which a false positive costs a short conversation rather than a student's record.

Checks every file against classmates, the web and AI, in 65+ languages.

Why honest code gets flagged

An AI code detector does not find a source. It looks at how code is written and estimates how likely a model wrote it. Generated code has characteristic features: consistent structure, conventional naming, thorough comments, defensive error handling, idiomatic use of the language. Those features are also the features of good code. Some human code has them for entirely honest reasons, and some of that code will score high.

This is not a defect that better engineering will eventually remove. Generated code is trained to resemble good human code, so the two distributions overlap, and any threshold drawn between them misclassifies some cases on each side. The design choice is which side to protect. For decisions about people, the side to protect is the honest author.

Code most at risk of a false flag

SituationWhy it resembles generated code
Very short programsTwenty lines leave little room for individual style. The conventional solution is also the one a model writes.
Textbook algorithmsBinary search, linked lists and sorting have canonical forms that students learn and models reproduce.
Code following a lecture exampleThe instructor's own style, copied as taught, may itself read as polished and conventional.
Formatter and linter outputTools such as Black, Prettier and clang-format remove the irregularities that mark human code.
IDE-generated boilerplateConstructors, accessors, equals and toString are machine-written, but not by an AI assistant.
Experienced studentsSomeone who has programmed professionally writes clean, documented, defensive code in week one.
Permitted AI-assisted editsA student allowed to ask an assistant to explain or tidy their code may end up with sections that read as generated.

Knowing this list is the most effective protection there is. When a flagged file falls into one of these categories, the bar for any further step should rise.

What a low error rate means in a real class

Suppose a detector wrongly flags 1 in 200 human-written files. In a course of 250 students submitting 8 assignments, that is 2,000 files and about 10 false flags over a term, spread across different students. Most instructors will meet at least one false positive every term.

The base rate matters as well. If few students actually used AI against the rules, the false flags are a larger share of all flags. The reasoning is set out in full in how AI detectors work. The conclusion for practice is simple: a flag is where a review starts, every time.

Handling a disputed flag

  1. Start from the policy. What AI use was permitted, and how was disclosure to be made? A student who used an assistant within the rules has nothing to dispute.
  2. Read the reasons, not only the score. If the detector's reasons point at boilerplate, a textbook algorithm or formatter output, the flag is weak for this file.
  3. Check the at-risk list above. Short program, canonical algorithm, lecture-style code, experienced student? Weight accordingly.
  4. Compare with the student's own earlier work, including any in-class or supervised exercises.
  5. Look at process evidence. Commit history, drafts, autosaves, notes. Incremental work with mistakes and fixes is strong evidence of authorship.
  6. Hold a short, non-adversarial walkthrough. Ask the student to explain the code and make a small change. A student who does this comfortably has almost certainly written it, and the flag should be closed.
  7. Record the outcome, including closed flags. A record of flags that were reviewed and dismissed is evidence that the process works.

A note on burden. A student cannot prove a negative. Asking them to "prove it is not AI" sets an impossible standard. The fair question is whether the evidence as a whole, including their explanation, shows a breach of the rules.

A process that keeps false accusations rare

  • Publish the rules on AI use per assignment, with examples. The collaboration policy template has wording.
  • Tell students that detection is used and how: that a flag triggers a conversation, never an automatic penalty.
  • Check everyone the same way, so no student is examined because of suspicion alone.
  • Collect process evidence routinely, through version control or milestones, so honest students have it ready.
  • Avoid relying on detection for short, canonical tasks. Put the integrity weight on open-ended work, where both detection and authorship are clearer. See preventing plagiarism in programming assignments.
  • Give students the evidence and a real opportunity to respond, as most integrity procedures already require.

How Codequiry approaches false positives

Codequiry's AI detection is trained on source code, not prose, because a text detector applied to code misreads its natural regularity as machine writing. It is tuned to keep false positives low: it would rather let a borderline generated file pass than flag an honest student. Every result lists the reasons behind it and marks the passages that drove it, so an instructor can see at once when the reasoning rests on boilerplate or a canonical algorithm.

AI results are reported separately from plagiarism matches, so a student is never flagged as AI because they shared code with a classmate, or the reverse. When a report is issued, its certificate rule is published: the code must read as under 60% AI-written, among other conditions. See code examination reports.

AI results you can check

Every AI result lists its reasons and the code behind it, so a weak flag is easy to recognise.

For the signs that do distinguish generated code, see how to tell if code is AI generated, and the language guides for Python, Java, JavaScript and C and C++.

Frequently asked questions

Can human-written code be flagged as AI-generated?

Yes. AI detection estimates likelihood from how code is written, and some honest code shares the features of generated code: short standard solutions, code produced with formatters and linters, code written by experienced programmers, and code closely following a textbook or lecture example.

What should an instructor do when a student disputes an AI flag?

Treat the flag as a question, not a finding. Read the reasons and flagged lines, compare with the student's earlier work, look at process evidence such as commit history, and ask the student to walk through and modify the code. If they can, that outweighs the score.

What code is most likely to be falsely flagged?

Very short programs, textbook algorithms, heavily templated code, code produced by IDE generators or formatters, code from students with professional experience, and code that follows a provided example closely.

How does Codequiry reduce false positives?

Its detector is trained on code and tuned to keep false positives low, accepting that some borderline AI code will pass rather than flagging honest students. Every result lists its reasons and the passages behind it, so an instructor can see when the reasoning does not hold for a particular file.

Is an AI detection score enough to penalise a student?

No. A score is a likelihood about writing style. Decisions should rest on the whole picture, including the student's explanation, under a written policy, with the student shown the evidence and given a chance to respond.

How do I prove my code is not AI-generated?

This guide is for instructors. Students who are asked about their work generally do best by showing how they built it: drafts, commit history and notes, and by explaining and changing the code when asked.

AI detection built to protect honest authors

Trained on code, tuned for low false positives, and every result shows its reasons.

Start a check Pay as you go with credits. Comparing files is free.