AI Detection

Detect AI-generated code patterns with local ML models and cloud fallback.

Overview

PhantomDev's detection engine analyzes code for patterns typical of AI-generated content. It uses a combination of local ML models and pattern-based detection to identify code that doesn't "look human."

How It Works

The detection engine uses multiple approaches to identify AI-generated code:

Local ML Models

RoBERTa-based models trained on code to detect AI-generated patterns. Runs entirely on your machine with no network required.

Pattern Detection

Identifies common AI tells: watermarks, uniform commenting, emoji overuse, and predictable variable naming.

Cloud Fallback

Optional cloud API integration via OpenRouter and Anthropic for enhanced detection accuracy.

Using Detection

Scan Staged Files

phantomdev scan

Scan Specific Files

phantomdev scan --files src/main.rs src/lib.rs

Verbose Output

phantomdev scan --verbose

Detected Patterns

PhantomDev can detect the following AI-generated patterns:

Watermarks

Hidden patterns embedded by some AI models to identify generated content.

Uniform Commenting

Overly consistent comment style and excessive documentation.

Emoji Overuse

Excessive or inappropriate emoji usage in code comments.

Predictable Naming

Variable and function names that follow AI-generated patterns.

Structural Patterns

Code structure that matches common AI output templates.

Understanding the Score

The detection engine returns a probability score from 0.0 to 1.0:

0.0 - 0.15

Low probability - Code appears human-written

0.15 - 0.50

Medium probability - Some AI patterns detected

0.50 - 1.0

High probability - Code likely AI-generated

Note: The threshold can be configured in your .phantomdev/config.toml file.

Supported Languages

PhantomDev supports detection for the following programming languages:

  • Rust
  • Python
  • JavaScript
  • TypeScript
  • Go
  • C++