whitespaces-dont-lie-feature-driven

Installation
SKILL.md

Whitespace-Driven Machine-Generated Code Detection

This skill enables Claude to analyze source code and assess whether it was likely written by a human or generated by an LLM (ChatGPT, Copilot, Claude, etc.) by extracting and evaluating whitespace patterns, indentation consistency, stylometric features, and structural properties. The approach is based on the empirical finding that AI-generated code exhibits mechanically uniform formatting -- especially in indentation and whitespace -- while human-written code carries idiosyncratic, inconsistent formatting signatures. A feature-based detector using these signals achieves ROC-AUC 0.995 and F1 0.971 on a 600k-sample benchmark.

When to Use

  • When a user pastes code and asks "Was this written by AI?" or "Is this code machine-generated?"
  • When reviewing student submissions for academic integrity and needing to flag potential AI-generated code
  • When performing authorship attribution on code of unknown origin
  • When auditing a codebase to estimate what proportion may have been AI-assisted
  • When a user wants to understand what stylistic signals distinguish human code from AI code
  • When building or evaluating a code-origin detection pipeline and needing feature engineering guidance

Key Technique

The core insight is that whitespace and indentation patterns are the most discriminative features for separating human-written from AI-generated code. Human developers accumulate idiosyncratic habits: mixing tabs and spaces, varying indentation depth across blocks, leaving trailing whitespace inconsistently, inserting irregular blank-line groupings, and aligning code to personal aesthetic preferences. AI models, trained on normalized corpora and generating token-by-token, produce mechanically consistent formatting -- uniform indentation depth, predictable blank-line placement, and almost no trailing whitespace or tab/space mixing.

The paper compares two approaches. The feature-based approach extracts lightweight, interpretable features across four categories: (1) whitespace features (blank-line ratios, trailing whitespace frequency, space-to-tab ratios), (2) indentation features (indentation depth variance, consistency score, tab-vs-space preference), (3) structural features (cyclomatic complexity, nesting depth, function/block density), and (4) stylometric features (variable naming patterns, comment density, line length distribution). These feed into gradient-boosted tree classifiers (XGBoost, Random Forest) that achieve near-perfect discrimination. The embedding-based approach uses CodeBERT to encode semantic code representations, achieving slightly higher precision but less interpretability.

Installs
1
GitHub Stars
6
First Seen
Jun 20, 2026
whitespaces-dont-lie-feature-driven — ndpvt-web/arxiv-claude-skills