Can you detect AI-generated code?
Not reliably, and it's the wrong question. Good AI-written code looks like good human code. What you can detect is unreviewed agent output: the specific mistakes agents leave behind when nobody reads the diff.
Why detectors fail
Code is short, formatted by tools, and full of shared idioms. A classifier trained to say "AI or human" has very little signal per line, and every formatter and linter pass removes more. Text detectors already misfire on human writing, and code gives them even less to work with.
Signals that do hold up
- Placeholders that replace code.
// ... rest of the code ...next to a large deletion. Details. - Imports that aren't in the manifest. The package was invented or never added. Details.
- Methods that don't exist.
Array.prototype.flatten,os.exists. Details. - Comments that narrate the code, or talk to the reader ("Here's the updated function"). Details.
- Helpers nobody calls and blocks pasted twice. Details.
- Stubs: TODO,
pass, "Not implemented" in a PR that says it's done. Details.
None of these prove an agent wrote the code. A tired person can write any of them. They do prove the diff needs another look, which is the thing a reviewer cares about.
Commit trailers
Claude Code, Cursor, Codex and Copilot's coding agent often add a trailer such as Co-Authored-By: Claude or Generated with Claude Code. That tells you which commits to look at, if the trailer wasn't removed. It says nothing about quality.
Check a diff in your browser
Paste a public PR or commit URL on the home page, or add the free GitHub Action to run the checks on every PR.