Evidence-based static analyzer for detecting AI-generated code quality issues with context-aware validation
pip install ai-slop-detector==3.14.1 Copy PIP instructions
Find AI-generated code that looks finished but isn't.
Catches what a normal linter passes over: empty functions with real-looking bodies, imports of things that don't exist, copy-pasted logic, unreachable code, and docs that oversell what the code actually does. Runs fully offline · deterministic core scoring · no API key, no model download, nothing leaves your machine.
Linters check form; this checks substance. See why not just a linter.
Navigation: What Is It? • Why Not a Linter? • When Not to Use • Quick Start • Verification • Boundaries • How It Works • Document Map • What It Detects • Scoring • Key Features • Calibration • Security • CI/CD • Config • VS Code • Roadmap • Changelog • Release Notes • Schema Validation
AI-SLOP Detector is an evidence-based static analyzer that targets a defect class common in AI-assisted code: structurally plausible code that is functionally empty, disconnected, or misleading. It does not tell whether code was written by an AI; it reports static signals in the code itself.
General linters flag style and convention. This tool flags structural risk.
Ruff, pylint, ESLint, and SonarQube primarily check syntax, style, and general static-quality rules. They'll happily pass code that follows every rule and still does nothing — which is exactly what AI assistants tend to produce. This tool checks the other half: does the code contain structural evidence for what it and its docs claim? Structural evidence is not proof that a claim is true; the tool does not run your code.
Use a linter for correctness-of-form. Use this for "is this code real, or just plausible-looking." The two are complementary — run both.
No project-side config needed. Run it against any folder of Python:
pip install "ai-slop-detector>=3.12.0" slop-detector --project . --json --output slop.json python -c "import json; d=json.load(open('slop.json',encoding='utf-8')); print(d['overall_status'], d['weighted_deficit_score'])" Expected output for a healthy project: clean 0.0 to clean 30.0. clean describes the weighted deficit band only; inspect finding_summary, scan_coverage, and ml_scoring before treating it as a complete project assessment. Modules that hold only static data (literal_data_module) are analyzed but carry no line weight in the weighted score; scan_coverage.aggregation_exclusions lists them. The --output form writes UTF-8 (no BOM) directly to disk, so it is safe under Windows PowerShell — prefer it to > slop.json redirection.
Windows / PowerShell tip: PowerShell > redirection writes UTF-16 LE or UTF-8 with BOM by default, which breaks json.load(..., encoding='utf-8'). Use --output instead — it writes UTF-8 bytes (no BOM) directly, skipping the shell.
One scan gives a person one screen of what matters and an AI agent a work order it can verify and act on. Everything below was produced from examples/demo_project with:
slop-detector --project examples/demo_project --report-dir demo-report HTML report (-o report.html; -o report.pdf prints the same page to A4 with an installed Chrome, Edge or Chromium). Pattern findings are scored; hollow review candidates (code that reports work it does not do, inputs that reach nothing, docstring promises the body cannot keep) are listed separately and never move the score.
Terminal (the default screen; --details prints the full metric tables, --quiet one line):
AI SLOP Detector 3.14.0 - examples\demo_project (3 files, 1.3 s) measurement: COMPLETE Score 13.5/100 CLEAN (score band) Findings 9 (critical 0 / high 2 / medium 6 / low 1) Hollow 4 review candidate(s), not scored - 7 functions, 2 not decidable Promises 2 docstring promise(s): 2 contradicted (1 candidate(s), 1 merged into a finding), 0 undecided, 0 with the structure, 0 delegated, 0 not evaluated Findings top 5 of 9 HIGH orders/pricing.py:1 return_constant_stub Function 'compute_discount' returns constant 0.1 - likely stub; also breaks its docstring: promises "Compute the discount for the order." (computed_result); every return is a literal (0.1) HIGH orders/pricing.py:15 pass_placeholder Empty function with only pass - placeholder not implemented MEDIUM orders/pricing.py:1 ignored_parameter Parameter 'order' of 'compute_discount' is never used - it does not affect the result MEDIUM orders/pricing.py:3 todo_comment TODO comment - incomplete implementation MEDIUM orders/store.py:4 return_none_placeholder Function only returns None - likely placeholder +4 more (--details or -o report.md) Hollow review candidates (not scored) top 3 of 4 orders/pricing.py:7 claim_without_mechanism total_parallel: promises "Sum the order values in parallel." (parallel); no call that could run concurrently orders/store.py:8 input_never_used save_record : the value reaches no result and no effect, here or in the module functions it is passed to orders/store.py:8 success_without_effect save_record: reports success, and every call it makes resolves to module functions with no effect: persist +1 more (--details or -o report.md) Next 1. The score is below every threshold, but 9 pattern finding(s) are open, 2 of them critical or high: review those before accepting this scan. Full tables: --details Report file: -o report.md AI work order (--format ai-md, also written as ai-report.md by --report-dir): a Markdown document for an agent with the rules it must follow, a VERIFY question per rule, and one block per item bound to the SHA-256 of the bytes the scan analyzed. The auditor mode (default) shows the code and grants no right to change it; --ai-mode agent copies no code and holds until its preconditions (repository readable, hashes match, operator approval, a test profile) pass. --ai-token-budget N fits it in an estimated budget. Details: docs/AI_WORK_ORDER.md.
### W03 C56ca6a2c17eb REVIEW_CANDIDATE claim_without_mechanism review at [FACT]: orders/pricing.py:7 bound_to [FACT]: sha256:df9a47d1...de64b48a (the file is the content the scan analyzed) evidence [FACT]: total_parallel: promises "Sum the order values in parallel." (parallel); no call that could run concurrently verify [NORM]: the body needs a concurrent call (pool, thread, process, task) or an await; found: no call that could run concurrently. ACK: implement the mechanism, or change the docstring to what the function does; REJECT: name the mechanism the detector missed (file:line) span [FACT]: orders/pricing.py:7-12 `total_parallel` All report surfaces and their rules: docs/REPORTS.md.
Use the same verification surface the repository exposes in CI:
pip install -e ".[dev]" python -m pytest -q ruff check src tests python -m build Governance verification is a separate enforcement gate:
slop-detector verify-governance ./.cr-ep See docs/GOVERNANCE.md for the artifact contract and policy checks.
Operational review commands live on the same CLI entry point:
slop-detector review . --json slop-detector pulse . --json slop-detector sweep dead-code . --json slop-detector sweep dupes . --json slop-detector sweep unused-deps . --json slop-detector sweep boundary-violations . --json slop-detector watch . --follow slop-detector explain dead-code Legacy command forms such as audit, health, and direct cleanup-family names remain supported for compatibility, but scan / review / pulse / sweep are the preferred stable surface.
Cleanup-family semantics are now more operational than a raw candidate list:
Agent tooling can use the same semantics over MCP stdio:
slop-detector mcp # or slop-mcp Adoption and observability surfaces are intentionally separate from scoring:
flowchart LR A[📄 Source File] --> R[FileRole\nClassifier] R --> B[AST Parser] B --> C[34 Pattern Checks] B --> D[LDR · ICR · DDC\n+ Purity Metrics] C --> E[GQG Scorer\nWeighted Geometric Mean] D --> E E --> F{deficit_score} F -->| |30–50| H[⚠️ SUSPICIOUS] F -->|50–70| I[🔶 INFLATED_SIGNAL] F -->|≥ 70| J[🚨 CRITICAL_DEFICIT] E --> H2[history.db] H2 --> K[Self-Calibrator\nadvisory report] Every file goes through four independent measurement axes (LDR, ICR, DDC, Purity) and 34 pattern checks. Results are combined via a weighted geometric mean — a near-zero in any single dimension pulls the overall score down regardless of other dimensions. Every scan is recorded to local history; --self-calibrate turns that history into an advisory weight report and never writes weights.
Full specification: docs/HOW_IT_WORKS.md · docs/MATH_MODELS.md Agent usage: docs/AGENT_WORKFLOW.md
Registry and advanced pattern detectors across structural, placeholder, clone, dependency, and language-specific signals. Full catalog: docs/PATTERNS.md
purity = exp(-0.5 × n_critical_patterns) quality (GQG) = exp( Σ wᵢ·ln(max(1e-4, dimᵢ)) / Σ wᵢ ) — weighted geometric mean deficit_score = 100 × (1 − quality) + pattern_penalty max(1e-4, ...) prevents log(0) = -inf from collapsing the entire score (v3.7.2 __post_init__ guards enforce upstream range invariants on metric results).
Default weights: ldr=0.40 · inflation=0.30 · ddc=0.20 · purity=0.10 — sum is 1.00; GQG divides by total_w so exact normalization is not required (all four appear in the advisory --self-calibrate report) Project aggregation uses SR9 conservative weighting: 0.6 × min + 0.4 × mean
Scores are not a black box. The full report (--details, Markdown, HTML) renders each metric with its value, healthy direction, and a one-line what it means, plus a deficit-band legend:
Project Metrics Metric Value Healthy What It Means Average Deficit Score 6.1/100 Lower Mean file risk; 0 is clean, 100 is severe. Logic Density Ratio (LDR) 95.36% Higher Share of code lines that contain real implementation. Inflation-to-Code Ratio (ICR) 0.00x Lower Unjustified jargon vs. average cyclomatic complexity. Dependency Usage Ratio (DDC) 86.00% Higher Imported libraries referenced by runtime code. Deficit bands: CLEAN =70 Each report ends with deterministic Next Steps — the top concern, the recommended sweep command, and the highest-priority file to open — so analysis turns directly into action. The same wording is shared by the rich, text, and markdown renderers.
Every per-file result in the JSON output also carries a deficit_breakdown that attributes the score back to its source dimensions. This answers "why is my clean-status file not 0.0?" without drilling into raw findings:
GQG-dimension shares are computed via log-loss attribution — the sum of the five penalty fields equals total within 0.01 when deficit_score < 100.
coherence_level in project-level JSON output reports how the structural_coherence value was derived:
mst_persistence and not_applicable are not emitted — they were proposed in the v3.7.5 audit but never wired in. Verify the actual value from the JSON output rather than guessing.
Bootstrap — domain-aware, one command to start
slop-detector --init # auto-detect domain, generate .slopconfig.yaml slop-detector path/to/repo --init # same, for another directory (must exist) slop-detector --init --domain web/api # explicit domain override slop-detector --init --adaptive-init --init-preview slop-detector --init --adaptive-init --apply-init-suggestions --init detects your project domain from the imports of your own non-test Python files (8 built-in profiles: general, scientific/ml, scientific/numerical, web/api, library/sdk, cli/tool, bio, finance). Common stacks (numpy, scipy, matplotlib, argparse) do not decide the domain, and a tie is general. The profile sets pattern thresholds and --init prints each threshold it changes; every profile keeps the default weights. Also secures .slopconfig.yaml in .gitignore by default.
Adaptive init is now a separate safety layer:
pip install "ai-slop-detector[js]" slop-detector --project ./src # now includes .js/.jsx/.ts/.tsx files Activates JSAnalyzer v2.8.0 with tree-sitter AST (regex fallback when not installed). Results appear under js_file_results in ProjectAnalysis and JSON output. The regex fallback cannot measure god functions, dead code or complexity; scan_coverage.analysis_modes lists those checks as not_measured, and the text, rich and markdown reports say so in one line.
Go Analysis — regex-based, optional tree-sitter-go path
pip install "ai-slop-detector[go]" slop-detector --project ./src # now includes .go files Activates GoAnalyzer v1.0.0. Detects: empty function stubs, panic() as error handling, fmt.Println/Printf debug prints, _ = ignored errors, TODO/FIXME comments, god functions (> 60 lines). Results appear under go_file_results in JSON output.
Self-Calibration — advisory weight report (Calibration v2)
slop-detector . --self-calibrate # advisory: what this project's history suggests Learns ldr / inflation / ddc (purity is held) from the comparable runs of the scanned project root only: same detector, engine and configuration. An improvement needs a changed file whose metric-only score fell from the SUSPICIOUS band; a flagged file left unchanged counts once. Pattern penalties are never learned as weights. The report is advisory only: scans never run it, and --apply-calibration is disabled (it writes nothing and exits 2). History recorded before v3.10 has no measurement provenance and is reported as legacy, not evidence (on one real database v1 learned 79% of its "improvements" from files that had not changed).
docs/SELF_CALIBRATION.md → · Validation boundary →
History Tracking — longitudinal quality analysis
slop-detector mycode.py --show-history # per-file trend slop-detector --history-trends # 7-day project aggregate slop-detector --export-history data.jsonl Every run auto-recorded to ~/.slop-detector/history.db. The history database is the repository-local signal source for operational calibration and trend review. docs/HISTORY_TRACKING.md →
cp -r claude-skills/slop-detector ~/.claude/skills/ # restart Claude Code, then use the canonical review surfaces below Adds a persistent JSON-first review loop inside Claude Code: review → inspect evidence → apply bounded fixes → pulse/sweep → human handoff.
AI-SLOP Detector can report how its weights would change from the history of one project root. This is a local operational aid: it is not a multi-repository data collection channel, a global profile injector, or evidence that the score is externally validated.
The report is bounded by comparable evidence (same measurement, same project root), per-class minimums, a confidence gap, and the configuration boundary: it never writes weights. Review a recommendation before changing .slopconfig.yaml for a team workflow. See docs/SELF_CALIBRATION.md for the supported flow and docs/VALIDATION.md for the validation boundary.
Your .slopconfig.yaml contains domain_overrides — a precise map of which functions are exempt from complexity rules. This is effectively a codebase weakness surface: it reveals which areas are too complex to refactor right now.
History is stored at ~/.slop-detector/history.db (your home directory, outside all repos). It is never committed and accumulates across all projects you scan.
Adversarial Validation (SPAR-Code) — ground-truth regression guard
fhval spar # 3-layer adversarial check fhval spar --layer a # known-pattern anchors fhval spar --layer c # existence probes Verifies each metric is measuring what it claims. Catches calibration drift before it reaches production.
project = detector.analyze_project("./src") print(project.structural_coherence) # 0.0 – 1.0 Experimental. Use for longitudinal comparison within a project, not as an absolute gate. Exact MST topology is used up to advanced.exact_topology_ceiling (default 300 files); above that the engine switches to a deterministic approximation and reports coherence_level = "vr_structural_approx". docs/ARCHITECTURE.md →
from slop_detector.core import SlopDetector detector = SlopDetector() result = detector.analyze_code_string(code) # no location result = detector.analyze_code_string(code, "pkg/mod.py", project_root=".") # as that file Without project_root the filename is only a label: no sibling module, project root or dependency declaration is read, and an import the installed environment cannot resolve (it may be local code) is listed in unverified_imports instead of being reported. With project_root the source is analyzed as analyze_file(project_root/filename, root=project_root) would analyze it.
# .pre-commit-config.yaml repos: - repo: https://github.com/flamehaven01/AI-SLOP-Detector rev: v3.7.3 hooks: - id: slop-detector # hard gate — fails on CRITICAL_DEFICIT >= 70 # - id: slop-detector-warn # soft mode — reports only, never blocks # - id: slop-detector-patterns # fast per-file pattern scan GitHub Actions (runs on every PR):
# .github/workflows/quality-gate.yml - name: AI-SLOP Gate run: | pip install "ai-slop-detector>=3.7.3" slop-detector --project . --ci-mode hard --ci-report Enforcement modes:
--ci-mode soft # informational, never fails build --ci-mode hard # fails: deficit_score >= 70, critical_patterns >= 3, inflation >= 1.5, ddc < 0.5 --ci-mode quarantine # escalates repeat offenders after 3 violations Full CI/CD Integration Guide →
# .slopconfig.yaml weights: ldr: 0.40 inflation: 0.30 ddc: 0.20 purity: 0.10 patterns: god_function: domain_overrides: - function_pattern: "check_node" # AST walker — complex by design complexity_threshold: 30 lines_threshold: 200 ignore: - "tests/**" - "**/__init__.py" advanced: exact_topology_ceiling: 300 topology_mode_above_ceiling: deterministic_approximate analysis_cache_enabled: true analysis_cache_db: "" churn_commit_window: 200 coverage_data_file: ".coverage" hotspot_limit: 10 hotspot_weights: deficit: 0.50 churn: 0.30 coverage_gap: 0.20 architecture: enabled: true preset: layered layers: [] Full Configuration Guide → · Config Examples →
Use inline suppression when a specific local exception is intentional and should remain visible in audit output:
# slop-disable-next-line bare_except except: pass # slop-disable all def compatibility_layer(): ... # slop-enable all # slop-disable-next-line # slop-disable # slop-enable Suppressed findings are removed from scoring, but they are still recorded in the suppression ledger so reviewers can see which lines were muted.
Repeated Python-file analysis can reuse prior results through the SQLite-backed metadata cache:
advanced: analysis_cache_enabled: true analysis_cache_db: "" # empty = default user cache under ~/.slop-detector/ Cache keys include file path, size, mtime, content hash, engine version, and config fingerprint. A changed file or changed config invalidates only the affected entries. Current scope is Python file analysis reuse; project aggregation still recomputes from the live file set. Priority Hotspots Project scans now rank repair order instead of only printing static scores. The hotspot layer combines:
When present, the report highlights files that are both sloppy and risky to change because they churn often or remain under-tested. If git metadata or coverage data is missing, the prioritization layer degrades gracefully instead of failing the scan.
The FastAPI server exposes an agent-native contract alongside the existing human-oriented /analyze/* routes:
These routes return structured snapshots with summary metrics, suppression metadata, hotspot ranking, and the raw analysis payload so tools can consume the results without scraping text output.
Real-time inline diagnostics, debounced lint-on-type, ML score and purity signal in status bar. v3.7.1 rebuilt from a single 855-line monolith into eight focused modules.
Install from the VS Code Marketplace or build locally:
cd vscode-extension npm install npx vsce package # produces vscode-slop-detector-3.7.3.vsix code --install-extension vscode-slop-detector-3.7.3.vsix Settings (slopDetector.*): pythonPath, lintOnSave, lintOnType, failThreshold (default 50), warnThreshold (default 30), recordHistory, enableCodeLens (default true).
git clone https://github.com/flamehaven01/AI-SLOP-Detector.git cd AI-SLOP-Detector pip install -e ".[dev]" pytest tests/ -v --cov black src/ tests/ ruff check src/ tests/ Development Guide →
Chart updated weekly via GitHub Actions. Monthly installs: pypistats.org (mirrors excluded). Total: pepy.tech (incl. mirrors)
Flamehaven Labs • Issues • Discussions • Docs
Both files in this release have provenance metadata.
ai code-quality static-analysis slop-detection code-review
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 12, 2026.
Both files in this release have been uploaded with provenance metadata.
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.




