Rolling Out AI Code Detection Across a CS Department

Running AI code detection across a whole department for a full academic year is less a detection problem than a consistency problem. The detector numbers are the easy part. The hard parts are calibration, triage, and the fact that different instructors respond very differently to the same score.

What follows is how to assemble a pipeline that combines AI generation scoring with peer similarity and web-source matching, how to calibrate it, and where the process tends to be weaker than the tooling implies.

The Problem Is Comparability

Many departments have run MOSS for pairwise peer similarity for years. That tool answers one question well: did two students in the same section turn in overlapping code?

It does not answer two other questions that integrity committees keep running into. The first is source provenance: code lifted from a GitHub repository or an old Stack Overflow answer passes a peer check cleanly because no classmate wrote it. The second is authorship. Submissions can be internally consistent, match nobody in the cohort, trace to no web source, and still read nothing like the student's own work from three weeks earlier.

Most departments are not short of suspicion. They are short of a way to make suspicion comparable across sections, courses and instructors. That is the real goal of a department-wide setup.

A Detection Stack in Layers

A sensible setup runs three layers on every submission, plus a fourth layer that is human.

LayerToolWhat it returns
Peer similarityMOSS, JPlag or similarPairwise percentage between submissions in the set
Peer, web, and AICodequiryPer-submission peer score, web score, AI score
AI cross-check (optional)General text detector on comment-stripped sourcePer-file probability
AdjudicationDepartment rubricCommittee notes, outcome, sanction

The third layer is the most debatable. General-purpose text detectors were trained on prose, not code, and comments are the only prose in a source file. Stripping them first is a compromise: it removes the detector's easiest signal and leaves it reasoning about a token stream it was never really built for. Treat that layer as a tiebreaker and nothing more.

A code-native AI code detector should score each file on a continuous scale rather than emitting a binary verdict. That matters for the same reason a p-value matters: you need to see where a score sits relative to a distribution before you act on it.

Codequiry AI code detection report with average AI score, highest file score and a risk distribution
AI code detection: probability scores per file, flagging submissions likely written by ChatGPT, Copilot, Claude or Gemini.

Calibrate Against a Known-Human Control Set

Before any AI score is used in a conversation with a student, build a control set. Pull a few hundred archived submissions from before public access to ChatGPT and GitHub Copilot, ideally from courses still being taught. These files are human-written by construction. Running the detector across them gives you the false positive floor for coursework of that type.

Break the results down by course level. Expect the median score and the right tail to climb as code gets more sophisticated. Upper-division and graduate code is more idiomatic, more uniformly structured, and more likely to use the same handful of design patterns everybody uses, which makes it statistically harder to tell apart from generated code. A single flat threshold applied across intro and graduate courses will therefore produce very different false positive rates at each end of the curriculum.

A per-course control set of 60 to 80 archived files is usually enough to see that divergence and set thresholds per course level rather than globally. Do not carry another institution's percentages over as exact numbers; the shape is what transfers.

When Two Detectors Disagree

If you run two detectors, expect them to agree on the broad strokes and diverge at the edges. Measure the agreement (Cohen's kappa at your cutoff is a simple way) before treating either score as ground truth. Moderate agreement is common, and it is nowhere near enough to rely on one detector alone.

The disagreements are informative. A code-native detector may flag short procedural assignments with almost no comments, which give a text detector nothing to work with. A text detector may flag heavily commented files where the student's own writing style happens to read as formulaic. Files flagged by both are where a committee should spend most of its time.

It helps to encode the triage as a small function that the gradebook import calls. It need not be sophisticated, but writing the policy as code forces a committee to argue about specific numbers instead of adjectives:

def review_tier(ai_score, peer_max, web_max):
    """Returns the escalation tier for one submission.
    Thresholds are per course level; these are the CS1 values.
    """
    if ai_score >= 0.85 or peer_max >= 0.90 or web_max >= 0.80:
        return "committee_review"
    if ai_score >= 0.55 or peer_max >= 0.65:
        return "instructor_notice"
    return "no_action"

The gap between the two thresholds in this example, 0.55 for a notice and 0.85 for committee review, is deliberate. It creates a band where the instructor is told and nothing else happens. Most submissions in that band should resolve as a conversation about citation practice.

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.

Peer Similarity Does Not Go Away

High peer-similarity pairs still appear, and they often cluster in courses that reuse the same textbook exercises every term. That is a curriculum problem wearing a detection costume.

The bottleneck is rarely the matching. MOSS and JPlag both compare structure, and neither is fooled by variable renaming or reformatting. The bottleneck is triage: 400 submissions produce 79,800 pairs, and an HTML page sorted by percentage does not tell a TA which few dozen of those actually matter. If you are still triaging by raw percentage, a code plagiarism checker that ranks by how unusual a submission is within its cohort will save more hours than any improvement in matching accuracy.

Codequiry smart review queue ranking submissions by cohort outlier score, topped by a 100% match
The smart review queue: cohort outliers ranked by priority, so a TA reviews the riskiest five, not all fifty.

An Escalation Policy That Holds Up

Use three tiers, each with a named owner and a clock: instructor notice within a few business days of the scan, committee review within a fixed window after that, and student contact only after a human has read the code. The message to the student should never contain the score. Tell students their submission has been referred for a conversation, which is accurate and does not invite an argument about model calibration.

Scores should also never appear in a grade. A 0.62 from a detector is an invitation to look, not a fact about authorship, and the moment it enters a gradebook it becomes something the student has to disprove.

A rubric with worked examples works better than a policy paragraph. Define "AI-assisted" as, for example, autocomplete on boilerplate, docstring generation, and syntax questions. Define "AI-generated" as any submitted logic the student did not author, regardless of how much editing followed. Ship both categories with two annotated code samples each.

Instructor Variance Can Be Bigger Than the Tooling

Give several instructors teaching the same course identical assignments, identical thresholds and identical rubrics, and their escalation rates can still differ several-fold. Detector variance rarely comes close to that. Anyone building an integrity program should expect human variance to dominate the system and budget effort accordingly: calibration sessions, shared adjudication notes, and a second reader on any committee referral. The thresholds are the cheap part.

Many of the people applying these policies are adjuncts and graduate teaching assistants with grading authority and no formal integrity training. That is not a criticism. It is a description of the job, and the policy should be written for it.

Pitfalls to Avoid

  • Duplicate submissions. Resubmissions processed under an earlier check can be double-counted and inflate a section's average AI score. Deduplicate on student ID plus assignment ID before you compute any cohort statistic.
  • One pooled calibration. Calibrating once on a pooled control set and applying the result to every course hides the gap between intro and advanced coursework. Calibrate per course level.
  • Vague syllabus language. Separate AI-assisted from AI-generated with concrete examples, and state plainly that detectors score files rather than people.

The tooling piece is the simplest part to get right. A platform that returns peer, web, and AI signals from one submission event, with a review queue that ranks what to look at first, removes most of the operational friction. If you are weighing options, the Codequiry vs MOSS comparison covers the differences.

Codequiry assignment insights with a class integrity score and the submissions to review first
Assignment insights: a class-wide integrity score and the submissions worth reviewing first.

If your department is at an early stage, the sequence is worth following in order: build a control set before you build a policy, pick thresholds per course level rather than globally, and treat every score as a logging decision until a person has read the file. You can detect code plagiarism and AI generation in the same scan without turning the scan into the verdict.

Start with a small pilot cohort and a control set you trust, then run a similarity check on submissions you already know the answer for. The false positive data will teach you more in an afternoon than a semester of thresholds guessed from documentation.