AI Code Detector| Why the Score Fails and What It Cannot See

An AI code detector is a tool that analyzes source code to estimate whether it was written by a human or generated by a large language model. Independent research shows these tools have a short “half-life,” with performance collapsing on new generators and unseen programming languages, and some dedicated detectors classifying nearly every sample as AI-generated while still reporting 50% accuracy .


At-a-Glance: Key Takeaways

  • Detectors have a “half-life.” A detector validated on one generation of models may not transfer to the next, with performance varying considerably across generators and prompting strategies .
  • Accuracy can hide severe bias. DetectCodeGPT and GPT-Sniffer achieved 50% accuracy but an F1 score of 0.00 because they classified almost every sample as AI-generated .
  • Language bias is a critical flaw. A SemEval team’s model achieved 97.5% F1 on validation data but dropped to 36% F1 on unseen test data, partly because training data was 91.5% Python .
  • Turnitin does not detect AI code. The company states it “does not reliably detect AI-generated text in the form of non-prose, or code” and is “not pursuing ChatGPT code detection at this time” .
  • General-purpose LLM judges outperform dedicated detectors in some benchmarks, but their reliability depends on the judge model and prompting strategy .
  • Explicit attribution markers are the only reliable signal. Footers like “Generated with Claude Code” are self-signed evidence. Their absence means nothing .

What Is an AI Code Detector?

An AI code detector is a tool that analyzes source code and assigns a probability indicating whether it was written by a human or generated by an AI model. It is not a plagiarism checker. Plagiarism tools compare code against existing repositories. AI code detectors analyze internal patterns, structure, and statistical features to estimate provenance.

The category spans several approaches. Dedicated detectors use fine-tuned code models like CodeBERT to classify code . General-purpose LLM judges use models like GPT or Claude with prompts asking them to assess provenance . Attribution tools look for explicit markers left by coding assistants, such as commit footers or bot authors . Statistical tools analyze commit patterns, code velocity, and anomalies .

The search intent is commercial investigation. Developers, educators, and engineering managers want to know which tools work, what their limitations are, and whether they can be trusted for high-stakes decisions. The evidence suggests they cannot.


How AI Code Detectors Work

The Semantic and Structural Approach

Dedicated code detectors typically fine-tune pre-trained code models. CodeBERT, trained on code-text pairs, provides a semantic understanding of what the code does. Some detectors add structural features like abstract syntax tree (AST) depth, cyclomatic complexity, and naming conventions .

A hybrid approach combining CodeBERT embeddings with statistical and authorship features achieved 99.06% accuracy in Python, 98.46% in Java, and 95.87% in C++ in one study . These numbers sound impressive. They also illustrate the problem: the performance was measured on data drawn from the same distribution as training.

The General-Purpose LLM Judge

A newer approach uses general-purpose LLMs as “training-free judges.” Instead of fine-tuning a specialized model, researchers prompt an LLM to assess whether code looks AI-generated. The 2026 ASE paper found that general-purpose LLM judges achieved stronger accuracy and F1 scores than dedicated detectors like DetectCodeGPT and GPT-Sniffer .

However, the paper’s authors caution that reliability depends on the judge model, the code generator, and the prompting strategy. They recommend evaluating across multiple generators and reporting macro-F1 alongside class-specific precision and recall.

The Attribution Approach

The simplest and most reliable signal is explicit attribution. Tools like Coderbuds’ AI Detector scan pull requests and commits for markers: commit footers like “🤖 Generated with Claude Code,” co-author tags like “Co-Authored-By: GitHub Copilot,” bot authors like github-copilot[bot], and branch patterns like codex/feature .

This is not detection in the statistical sense. It is evidence collection. The tool signing its own work at confidence 100 is a fact. A branch named claude/fix-login is a convention, not a signature .

The limitation is critical: “No match does not mean a person wrote it.” Coderbuds notes that on its own production data, pull requests with no marker were routinely agent-written, including every one Codex CLI produced. The one trace Codex leaves is the name it connects to MCP servers with .


The Accuracy Problem

The Detector Half-Life

The 2026 ASE paper evaluated eight general-purpose LLM judges and three dedicated detectors on human-written code and code from seven generators across C++, Java, and Python. The findings were stark .

Performance varied considerably across generators and prompting strategies. This suggests some detectors rely on generator-specific patterns rather than general evidence of code provenance. A detector that works on GPT-4 may fail on Claude. A detector trained on one model’s style may not recognize another’s.

The authors call this limited useful life a “detector half-life.” A detector validated on one generation of models may not transfer to the next.

The Bias Concealed by Accuracy

DetectCodeGPT and GPT-Sniffer achieved an accuracy of 0.50 but an F1 score of 0.00 across all generators. They classified almost every sample as AI-generated. Accuracy looked acceptable because half the samples were AI-generated. F1 revealed the truth: the detectors had no discriminative power at all .

This is a fundamental measurement problem. A detector that flags everything as AI will achieve 50% accuracy on a balanced dataset. Reporting accuracy without F1, precision, and recall conceals this failure.

The Language Generalization Collapse

A SemEval-2026 team’s hybrid CodeBERT + structural features model achieved 97.5% F1 on validation data. On the official test set, it dropped to 36% F1 .

The reason was distribution shift. Training and validation data were 91.5% Python. The test set had a markedly less skewed distribution across languages. The model had overfit to Pythonic syntax and could not generalize to PHP, C, or Java .

The lesson: a detector that works on your Python codebase may not work on your Java codebase. A detector validated on one language distribution may fail on another.

The Academic Integrity Challenge

An IEEE conference paper on detecting AI-generated C source code in programming assignments found near-ceiling in-distribution performance (macro-F1 = 0.998) but significant limitations under out-of-distribution conditions. The authors argued that detectors are “best deployed as risk-ranking support tools rather than standalone enforcement mechanisms, requiring calibration, abstention thresholds, and human review” .


What Turnitin Does Not Do

Turnitin’s AI detection is designed for prose. It does not reliably assess code. The company states its model “does not reliably detect AI-generated text in the form of non-prose, or code.” It is “not pursuing ChatGPT code detection at this time” .

For programming coursework, this matters. If a student submits a report with code listings embedded, only the prose between the listings is measured. The code is outside the denominator. A report that is listing-heavy may have a very small measured slice, or even fall below the 300-word threshold required for a report at all .

The prose that is measured is often the most formulaic part of a technical document: the algorithm walk-through that restates in English what the code already says. That uniformity can trigger false positives.


What the Score Actually Means

Explicit attribution markerReliable evidence. The tool signed its own work.
No marker foundUnknown. Does not mean human.
Statistical detector score (high)A signal for review, not proof. The detector may be biased, overfit, or relying on generator-specific patterns.
Statistical detector score (low)Unreliable. False negatives are documented, and dedicated detectors can fail to classify almost everything.

The score answers one question: “How closely does this code match patterns the model associates with AI generation?” It does not answer: “Did this person write this?”


Who Should Rely on AI Code Detector Scores

Engineering teams using attribution tools can use explicit markers as reliable evidence of AI assistance. A commit footer is a fact. It can inform code review, licensing decisions, or security audits.

Educators should not use statistical code detectors as enforcement mechanisms. The IEEE paper recommends risk-ranking support with human review, not standalone enforcement . The evidence of bias, half-life, and language collapse is too strong.

Security teams can use attribution data to flag AI-generated contributions for additional scrutiny, as the De-AI project suggests. But the flag is a prompt for review, not a verdict .

Developers should not treat a detector score as an objective measure of their work. The tools are probabilistic and biased. A high score means the code triggered patterns, not that it was generated.


Common Mistakes and Cautions

Treating accuracy as meaningful without F1. A detector that flags everything as AI achieves 50% accuracy on balanced data but zero F1. Always check precision, recall, and F1 .

Assuming a detector works across languages. A model trained on 91.5% Python may collapse on Java or C++. Language distribution matters .

Using Turnitin for code. Turnitin does not detect AI code. Its prose detector will measure only the report, not the listings .

Trusting “no match” as human. Coderbuds found that pull requests with no marker were routinely agent-written. Absence of evidence is not evidence of absence .

Ignoring the half-life. A detector validated on one model generation may fail on the next. Re-evaluate detectors regularly .


Frequently Asked Questions

How accurate are AI code detectors?

Accuracy varies widely and often collapses on new data. Dedicated detectors like DetectCodeGPT and GPT-Sniffer achieved 50% accuracy but 0% F1 because they classified almost everything as AI-generated. A SemEval team’s model dropped from 97.5% F1 on validation to 36% on test. There is no universal accuracy figure .

Can AI code detectors detect ChatGPT code?

Some dedicated detectors claim to, but reliability is poor. The 2026 ASE paper found that general-purpose LLM judges outperformed dedicated detectors, but their reliability depends on the judge model and prompting strategy. Detectors have a “half-life” and may not transfer to new model generations .

Does Turnitin detect AI-generated code?

No. Turnitin states its model “does not reliably detect AI-generated text in the form of non-prose, or code” and is “not pursuing ChatGPT code detection at this time.” It measures prose only, not code listings .

What is the most reliable way to detect AI-generated code?

Explicit attribution markers. Commit footers like “Generated with Claude Code,” co-author tags like “Co-Authored-By: GitHub Copilot,” and bot authors are self-signed evidence. They are facts, not predictions. Their absence means unknown, not human .

Should educators use AI code detectors?

Only with caution and human review. The IEEE paper recommends detectors as risk-ranking support tools, not standalone enforcement, requiring calibration and human review. The bias and generalization problems are too severe for automatic penalties .


Conclusion

AI code detectors are probabilistic tools that estimate provenance from patterns. The evidence is clear: dedicated detectors can be biased, overfit to specific languages, and fail on new model generations. General-purpose LLM judges perform better but depend on the judge model and prompting strategy. Turnitin does not detect code at all.

Leave a Comment