AI Code Detector False Positives on Boilerplate

By the third week of CS1, the assignments arrive in predictable shape. Most students begin from the same scaffold: a main method, a loop reading standard input, a class definition with getters and setters. Run an AI code detector across a course like that and it can flag a large share of the submissions as likely AI-generated, many of them structurally near identical to the starter code. Those AI code detector false positives are a known weakness in tools universities have rushed to adopt, and the problem is most acute on boilerplate-heavy assignments.

Boilerplate code is not a sign of cheating. It is the necessary scaffolding a language demands. In Java, a class with private fields, a constructor, and accessor methods follows a pattern every student sees in the first five weeks. In Python, a script that reads a list and computes an average looks almost identical across hundreds of submissions. When a detector measures predictability, these files score poorly even when a human wrote them line by line.


public class Student {
    private String name;
    private int id;

    public Student(String name, int id) {
        this.name = name;
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public int getId() {
        return id;
    }
}

That file could have come from a student, a course handout, or Codex. A detector that relies on perplexity sees no meaningful difference because the token sequence is extremely likely under any model trained on Java.

If every student turns in the same Student.java file because they were all given the same template, there is no way to tell a generator from a student who followed instructions. The detector cannot tell either.

AI Code Detector False Positives: The Boilerplate Problem

Detectors trained to spot AI text look for two statistical signals: low perplexity and low burstiness. A passage with very predictable word choices and uniform sentence rhythm is more likely to be machine generated. Source code has both properties for reasons that have nothing to do with a large language model. The grammar of a programming language is strict. Indentation, semicolons, braces, and return statements repeat because they must. Variable names in beginner code follow conventions from lectures and textbooks: total, numbers, count, temp.


def calculate_average(numbers):
    if not numbers:
        return 0.0
    total = 0.0
    for number in numbers:
        total += number
    return total / len(numbers)

values = [1, 2, 3, 4, 5]
print(calculate_average(values))

A file like this can be written by a student in a supervised lab and still score very high, because the only unusual thing about it is that it is completely ordinary. The more of a file that comes straight from the starter template, the more likely a false positive; assignments that require custom logic outside the template give a detector far more to work with.

The stakes are high. A single erroneous score can trigger an academic integrity case, and a false accusation in a first-year course does damage well beyond the grade.

How Detectors Measure Code, and Where That Goes Wrong

Text detectors often treat low perplexity as strong evidence of machine writing. Code detectors face a harder problem because the language itself enforces low perplexity for large portions of any program. A human student who has just learned a pattern will reproduce it almost exactly. The difference between that student and a generated file is not in the boilerplate; it is in the custom logic, the comments, and the mistakes. Those are the regions where detectors need to focus, but many are still looking at the whole file.

The most reliable signal is not the raw AI probability but the relationship between that probability and similarity to peer submissions and web sources. A file with a high AI score and a very high peer match is usually a template or a shared starter file. A file with a low peer match and a high AI score deserves a closer look.

Codequiry's approach addresses this by showing each submission's peer similarity, web matches, and AI generation score side by side. Seen together, they change how a high AI score should be interpreted.

A submission with a 91 percent peer match and a 78 percent AI score is usually copied starter code. A submission with a 12 percent peer match, a 7 percent web match, and an 85 percent AI score warrants a conversation.

That reduction in false alarms matters in large courses. If a detector flags 22 percent of submissions and most of those are boilerplate artifacts, the review queue becomes useless. Instructors stop trusting it, and the actual cases get lost.

Codequiry per-file AI analysis showing AI versus human probability for each file with written indicators
Drilling into one submission: per-file AI and human probabilities, each with the stylistic indicators behind the score.

Stacking AI Detection With Structural Similarity

The most effective workflows use AI detection not as a verdict but as one signal in a stack. A code plagiarism checker that compares token sequences, ASTs, and fingerprints across peer submissions catches the student who copied a classmate's file and then renamed the variables. A web-source check catches code lifted from Stack Overflow or a public GitHub repository. The AI detector catches something different: text that shows the statistical signature of generation, even when no exact source exists.

When those signals disagree, the disagreement is often the most useful evidence. A large language model can produce code that is syntactically correct but oddly uniform, with no digressions, no commented-out experiments, and no half-finished alternative approaches. Students, even strong ones, leave traces. The absence of those traces, combined with a high AI probability and no match in the peer or web corpus, is a stronger signal than any single score.

Codequiry makes this stack practical because it runs peer similarity and web-source tracing in the same scan as its AI code detector. Other tools require separate submissions or different platforms for each kind of check. That separation is not just inconvenient; it breaks the comparison. If a detector returns only an AI probability for each file, the instructor has no baseline for whether the file is also a template, a peer copy, or a snippet from a tutorial site.

Codequiry insights score breakdown separating peer similarity, web similarity and AI generation, with match sources
The score breakdown: peer similarity, web similarity and AI probability reported separately, with where the matches came from.

What Instructors Can Do Differently

The most useful adjustment is to strip the course template before running any detector. A small Python script that removes the instructor-provided scaffolding from each submission before sending the rest to the detector can cut the false flag rate substantially. It will not reach zero, but it shrinks the review burden.

Another shift is thresholding. Rather than treating any AI score above 70 as actionable, set the review threshold at 85 or 90 and require a human to look at the file before any academic integrity case proceeds. A second detector, or a short interview in which the student explains the code, helps further. That last step catches two problems at once: the false positive and the true positive who cannot explain what the code does.

The technical fix is still incomplete. Detectors have gotten better at distinguishing boilerplate from generated code by comparing a submission to a baseline of starter templates, but the field has not settled on a standard for what should count as a false positive in code. A detector that flags a student's faithful reproduction of a course template is technically wrong, but it is also telling the instructor something true about the assignment: that the task did not require enough original work to distinguish students from a generator. That is worth taking as a prompt to redesign assignments, not just to tune detectors.

For CS departments weighing these tools, the practical question is whether the detector helps a reviewer find the cases worth reviewing. A high AI score on a file that is 90 percent similar to every other submission is noise. A high AI score on a file that matches nothing else is signal. Platforms that separate those two numbers leave instructors to do that reasoning by hand. Ones that put them in the same report make the false positive problem visible, and visibility is the first step toward fixing it.

Instructors who want to see how combined peer, web, and AI scores change a review queue can start with the AI-generated code detector and the companion similarity checks.