SuperAPI AI Directory

SynthScan

Scans codebases for AI-generated code patterns.

Open website

About this tool

SynthScan is used to detect patterns of AI-generated (synthetic) code in code repositories. It can be used as a powerful CLI tool (installed via npm or pip), or run as a fully automated GitHub Action.

Main capabilities:

  • Over 160 built-in detection patterns, covering 23 categories.
  • Context-aware severity weighting.
  • Scores normalized per 1,000 lines of code.
  • AST structural analysis.
  • Cross-file fuzzy duplicate detection.
  • Diff/PR mode.
  • SARIF output.
  • Editable Markdown pattern files.

Usage:

  • Multi-platform: can be run anywhere via npm, pip, or GitHub Actions.
  • Diff / PR mode: pass in a unified diff file to score only added lines. The score is normalized by the number of lines in the diff, yielding a clear "how synthetic is this PR" metric.
  • Beautiful output: colorful terminal output, and results can be natively piped to tools such as jq via the --format json flag.
  • SARIF output: generates synthscan-report.sarif for integration with GitHub Code Scanning—inline annotations appear directly on the PR diff.
  • Advanced context: detects docstrings of AI structures, over-commented code blocks, unreachable AST code, functions with too many parameters, and cross-file fuzzy duplicates.
  • Easy to configure: use a gitignore-like .synthscanignore to exclude paths. Patterns can be fully edited in plain Markdown.

Installation:

  • Via NPM (Node.js)
  • Via PIP (Python)
  • Via GitHub Actions: add the workflow to .github/workflows/synthscan.yml in any repository. After global installation, run synthscan in the terminal.

Pattern definitions: Patterns are defined in a human-readable Markdown file (patterns/synthetic_patterns.md). Each pattern is either a plain-text substring (case-insensitive) or a Python regular expression (prefixed with regex:). Patterns have severities (CRITICAL, HIGH, MEDIUM, LOW).

Detection layers: The scanner traverses each source file and applies five layers of detection:

  1. Line-level matching (context-aware: comments score higher, strings score lower).
  2. Multi-line block detection (e.g., Try/Catch wrappers, docstrings of AI structures).
  3. AST structural analysis (Python only: detects unreachable code, result variable anti-patterns).
  4. Cross-file fuzzy duplicates (catches AI scaffolding repeated across multiple files).
  5. Inline suppression (lines with # synthscan: ignore are skipped). Scoring is refined through post-processing steps (cluster bonuses and per-file diminishing returns).

Synthetic Code Score: The core metric is the score per 1,000 lines of code: Synthetic Code Score = (Raw Score / Lines Scanned) * 1000 This normalization prevents large codebases from naturally accumulating higher scores than small codebases. Reference ranges (from benchmark testing):

  • 0 – 5: likely human-written
  • 5 – 15: low AI signal—review flagged lines
  • 15 – 30: medium AI signal
  • 30+: strong AI signal

Contributing: Contributions, issues, and feature requests are welcome. If you find new hallucinated words or LLM characteristics, simply submit a PR to add them to the patterns/synthetic_patterns.md file.

Copyright © Marco Ramilli. This project is licensed under the MIT License.