r/MachineLearning • u/Ancient_Mango_1576 ML Engineer • Aug 20 '26
Discussion AI-generated code detection in CI/CD — looking for approaches and real-world experience [D]
I'm working on a system to estimate whether code committed to a repository was generated with AI coding tools.
My current approach is based on Git/commit-level signals such as AI-related commit trailers, commit metadata, LOC changes, number of files changed, addition/deletion patterns, etc.
The problem I'm running into is confidence and calibration.
For example, a commit containing 500+ new lines isn't necessarily AI-generated. A developer can also modify or remove the metadata that would make an AI-assisted commit identifiable. Once the code leaves the IDE and reaches Git, much of the original provenance can be lost.
This has led me to a few questions:
Are there Git/CI-level signals that you've found to be genuinely useful for detecting AI-assisted development?
Is it better to treat this as a probabilistic/risk-scoring problem rather than trying to classify commits as AI vs human?
How would you calibrate thresholds for signals such as large LOC changes, addition/deletion ratios, commit frequency, etc.?
Are there better approaches for preserving provenance earlier in the development workflow, rather than trying to infer it after the code has already been committed?
Has anyone worked on AI-code provenance/detection systems in CI/CD and can point me toward useful research, projects, or approaches?
I'm particularly interested in approaches that can work at the pipeline/repository level rather than relying solely on source-code style analysis.
I'm not looking for a perfect AI detector — even a reliable way of estimating “this commit has a high probability of AI assistance” with measurable false-positive/false-negative rates would be useful.
Would appreciate any experiences, papers, open-source projects, or approaches people have tried.
7
u/Cute_Obligation2944 Aug 20 '26
Good luck, I haven't seen a credible one yet.
4
u/JustOneAvailableName Aug 20 '26
In my experience: if there are docstrings or the readme was updated, it was AI.
5
u/liamtrades__ Aug 21 '26
What code is not written by AI now?
7
u/evanthebouncy Aug 20 '26
basically if it has comments it'll be AI generated lol
this will be the top-1 surface level feature any trianed NN will pick up. so you probably have to figure out how to deal with it ahah
3
u/chensium Aug 21 '26
To what end? Are you gonna flag PRs started by humans but modified by AI? Or AI that's been fine tuned in a particular person's style? Or AI suggested code written by a human? There's too much gray area here.
If you don't like the code, block it and put in your objections in the comments. Otherwise who cares who wrote it.
2
u/Budget_Coach9124 Aug 20 '26
I would treat this as provenance and risk scoring, not detection. Once the code is in Git, most direct evidence is already gone, and any classifier will learn style shortcuts like docstrings, large diffs, or unusually clean commit messages. Those signals might be correlated today and useless after one team changes its workflow.
The more robust path is to capture provenance earlier: IDE/plugin attestations, signed tool metadata, policy-aware commit trailers, or CI checks that record whether generated code was reviewed rather than trying to prove who wrote each line. For thresholds, I would calibrate around downstream risk: generated migration script, auth code, and tests should not be scored the same way.
1
u/gini-348 Aug 21 '26
Yeah. Depends on the company, however most of the code will be written by ai. Documentation for sure is written by ai.
1
u/Cute-Net5957 Aug 21 '26
wait.. what are you actually trying to detect this for though?
like what happens when CI says “this commit is probably AI generated”? extra review/security checks? enforcing a no-AI policy? tracking adoption? IP/compliance? catching shitty drive-by AI PRs?
asking because I think those turn into completely different systems.
like if a company wants to stop AI-generated code and their solution is detecting it once it hits CI/CD… isn’t that already kinda late? you’re reconstructing provenance after you’ve thrown most of the provenance away. feels like that company has a bigger DevOps/RunOps/control problem upstream.
but if this is for something like a GitHub Action that helps maintainers thin out the flood of weird low-effort AI slop PRs… ok lol now I actually want it.
except even there I’m not sure I care if AI wrote it.
I care if it’s slop.
humans generate plenty of that too depending on the day 🤷🏽♂️
so maybe “probability this was AI generated” is a useful signal, but not actually the thing you’d want the system making decisions on?
genuinely curious what you’re building toward because the use case changes this a lot imo.
1
u/feng_sg Sep 01 '26
Git diffs can't tell a Copilot paste from a bulk refactor because the provenance is gone by commit time. You need signed attestation at the IDE layer tagging tool and model version before it hits Git, otherwise you're just guessing against team-specific noise.