Skip to content
项目

关于

Stop shipping AI slop. Detects empty functions, fake documentation, and inflated comments in AI-generated code. Production-ready.

开发工具

这些数字如何统计

可以做什么

  • Structural warning signs - 57 rules in four languages, each with the file, line, rule and fix
  • Hollow-code review (Python) - success without effect, inputs never used, failure reported as success; unscored review candidates
  • Work orders for AI agents - each item bound to the SHA-256 of the scanned bytes; fixes that only hide a finding are forbidden
  • Agent counterarguments - ACK / REJECT / UNSURE per item in a verify record

实测星标增长

24小时
+1
7天
+3
15天
+6
1个月
+17

各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。

README.md

原文

AI-SLOP Detector - Ship Code. Not Slop.

AI-SLOP Detector

Ship Code. Not Slop.

Detect structural warning signs. Review AI-generated fixes against evidence.
Local, deterministic static analysis for Python, JavaScript/TypeScript, Go and Rust,
with Python hollow-code review and an evidence-bound fix loop for developers and AI agents.
No API key. No model download. No network calls during analysis.

PyPI version npm version VS Code Marketplace version Python versions Languages: Python, JS/TS, Go, Rust MIT License CI

VS Code installs npm downloads per month PyPI downloads per month PyPI downloads total GitHub stars

Quick Start · What You Get · VS Code · CI/CD · AI Agents · Security · Full Guide


What Is AI-SLOP Detector?

Code can look finished and still hide a stub, a swallowed error, an input nothing reads, or a todo!() that panics when it is reached. Linters pass it because it is well-formed, and AI assistants produce a lot of it.

AI-SLOP Detector is a static analyzer for that gap. It reads your code without running it, reports each spot with the file, the line, the rule and a fix, and gives every file a 0-100 score (higher = more warning signs). It does not tell whether a person or an AI wrote the code; it reports what is in the code.

  • 57 rules across Python (39), JavaScript/TypeScript (8), Go (6) and Rust (4)
  • Hollow-code review (Python): success without effect, inputs never used, failure reported as success; review candidates for a person, kept out of the score
  • Deterministic: the same input gives byte-identical JSON
  • Local only: no API key, no model download, no network call during a scan
  • Everywhere you work: terminal, VS Code, CI gates, pre-commit, AI agents (CLI JSON and a Claude Code skill)

A finding that disappears is not proof of a fix. Take a snapshot before an agent edits and prove after it: the receipt is REVIEWABLE (a candidate for a person to review, never an approval) or HOLD with the reasons, such as a new suppression, a deleted function or a changed measurement. Scan, work order, snapshot, fix, prove; then a person decides.

Quick Start

60-second first run (more in the guide):

pip install ai-slop-detector
slop-detector --project .

No configuration is needed. Then:

Next Command
One file slop-detector path/to/file.py
Every report in one folder (Markdown, HTML, PDF with an installed Chrome or Edge, AI report and work order, JSON) slop-detector --project . --report-dir slop-report
JSON for scripts (UTF-8, safe on Windows PowerShell) slop-detector --project . --json --output slop.json
Fail a CI build slop-detector --project . --ci-mode hard --ci-report
No install uvx ai-slop-detector --project . or npx ai-slop-detector --project .
A work order for an AI agent slop-detector --project . --format ai-md --ai-mode agent
Before and after an agent's fix slop-detector snapshot . -o before.json, then slop-detector prove . --before before.json --format md
MCP server for agents (Python 3.10+) pip install "ai-slop-detector[mcp]", then slop-detector mcp --root . (AI Agents)

Every command and option: docs/GUIDE.md.

What You Get

The terminal screen (slop-detector --project examples/demo_project): the score and its band, the findings by severity, the first findings with the rule and the reason, and what to do next.

Terminal summary of examples/demo_project

--details prints the full metric tables, --quiet one line.

The HTML report (-o report.html; -o report.pdf prints the same page): every finding with its fix and evidence, and the review candidates apart from the score.

HTML report of examples/demo_project

Outputs for AI agents, made to be acted on, not read:

Output What it is
--format ai-md (AI work order) Markdown for an agent: the rules it must follow, a VERIFY question per rule, every file bound to the SHA-256 of the bytes scanned, one block per item. It is read back before it is written and refuses when an item is missing or doubled.
--format ai (AI report) One JSON object per line: each finding with its location, rule, fix and evidence.
--json The full result, including scan_coverage (what was measured and how) and next_steps.

Why the AI work order is different. A list of warnings invites an agent to make each one disappear. The work order is a contract instead:

  • Bound to the bytes. Every item names the SHA-256 of the file the scan read. If the file changed since, the item is void: the agent must hold it and re-scan, not repair from a stale document.
  • Fixes that only hide a finding are forbidden. No suppression comment, no threshold or weight change, no deleting or renaming the function to make the item vanish.
  • One question per rule, and REJECT is a valid answer. The agent checks the code against the rule's VERIFY question, then answers ACK and fixes, or REJECT with the evidence the detector could not see. That is the false-alarm channel.
  • Proved by prove, not by a vanished warning. snapshot records the project before the fix; prove re-scans it read-only and compares item by item. The receipt is REVIEWABLE (a candidate for a person to review, never an approval) or HOLD with the reasons: a suppression, a deleted function, a changed measurement, a new finding, a changed test file and more. It does not run the tests; the agent runs the project's tests.
  • One response line per item, so a reviewer can check every claim.

An excerpt of the real work order for examples/demo_project (slop-detector --project examples/demo_project --format ai-md; ... marks lines left out):

# AI-SLOP WORK ORDER
target: demo_project | files 3 | score 13.5 CLEAN (pattern channel only)
items: 13 | work order 13 | backlog 0
...
## HARD-STOP [NORM]
HS-01 the file's SHA-256 differs from source_sha256 -> HOLD the item
HS-03 the fix needs a FORBID change -> stop, REPORT HOLD
HS-04 the fix changes a public signature, a return type or code outside the item's span -> stop, needs a decision (D-*)
...
## FORBID [NORM]
- a suppression comment or a noqa / pragma marker
- a threshold, weight or config change
- deleting or renaming the function to make the item vanish
...
#### W01 F7843b06ebed5 FINDING return_constant_stub high
at [FACT]: orders/pricing.py:1
bound_to [FACT]: B01 (the file is the content the scan analyzed)
evidence [FACT]: 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)
verify [NORM]: the body needs a value computed from the inputs, or an open call that could compute it; found: every return is a literal. 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:1-4 `compute_discount`
```python
1| def compute_discount(order):
2|     """Compute the discount for the order."""
3|     # TODO: use the customer's tier
4|     return 0.1
```
...
## RESPONSE-FORM [FORMAT]
`<id> ACK|REJECT|HOLD verify=PASS|FAIL fix=<one line|NOT-APPLICABLE: why> prove=PASS|FAIL|NOT-MEASURED evidence=<file:line or test name>`

Details: docs/REPORTS.md · docs/AI_WORK_ORDER.md · what you get, in the guide.

Languages

Language Files Read by (base install) Optional extra (Python 3.10+) Rules
Python .py Python AST - 39
JavaScript / TypeScript .js .jsx .ts .tsx regex reader (god functions, dead code and complexity are not measured) [js]: tree-sitter, measures all 8 8
Go .go regex reader, measures every Go rule [go] installs tree-sitter-go; the analyzer does not use it yet 6
Rust .rs token scanner, measures every Rust rule [rust]: tree-sitter, same findings 4
pip install "ai-slop-detector[js]"     # or [rust]; on Python 3.8/3.9 the base install reads these files

Rule counts come from the pattern registry in docs/PATTERNS.md (57 rules), which a test keeps in line with the analyzers. A scan says which reader ran for each language (scan_coverage.analysis_modes).

What It Detects

Language Example Rules (sample)
Python a function that returns a constant where its docstring promises a computed result; a handler that turns a failure into success; a parameter nothing reads; an import no installed distribution, declaration or known provider supplies return_constant_stub, failure_as_success, ignored_parameter, phantom_import
JavaScript / TypeScript any types, empty arrow functions, ==, leftover console.log js_any_type, js_empty_arrow, js_double_equals, js_console_log
Go ignored errors, panic() as error handling, empty functions go_ignored_error, go_panic, go_empty_func
Rust todo!() and unimplemented!() outside test code, leftover dbg!() rust_todo_macro, rust_unimplemented_macro, rust_dbg_macro

Python files also get hollow review candidates: functions that report success with no effect, inputs that reach nothing, docstring promises the body cannot keep. They are listed for review and never change the score.

All 57 rules: docs/PATTERNS.md.

How It Works

flowchart TD
    A["Project or file"] --> B{"Language by file extension"}
    B -->|.py| P["Python<br/>AST, 39 rules<br/>LDR, ICR, DDC, Purity"]
    B -->|.js .jsx .ts .tsx| J["JavaScript / TypeScript<br/>tree-sitter or regex, 8 rules"]
    B -->|.go| G["Go<br/>regex reader, 6 rules"]
    B -->|.rs| R["Rust<br/>tree-sitter or token scanner, 4 rules"]
    P --> F["File score 0-100<br/>higher = more warning signs"]
    J --> F
    G --> F
    R --> F
    P --> H["Hollow review candidates<br/>Python only, not scored"]
    F --> S["Project score<br/>weighted by lines of code"]
    S --> O["For people: terminal,<br/>Markdown, HTML/PDF"]
    H --> O
    S --> AI["For agents: AI report,<br/>AI work order, JSON"]
    H --> AI
    AI --> L["Fix loop: snapshot, prove<br/>CLI or MCP server"]
    S --> C["CI gate: soft, hard, quarantine"]
    F --> V["VS Code: line marks, hover, Problems"]

The same input gives the same output: scoring is deterministic and needs no model or network. Details: docs/HOW_IT_WORKS.md.

Scoring Model

Score Status
< 30 CLEAN
30 - 50 SUSPICIOUS
50 - 70 INFLATED_SIGNAL
>= 70 CRITICAL_DEFICIT
  • Higher score = more warning signs. Each file gets a deficit score from 0 to 100; the project score weights files by their lines of code.
  • CLEAN is a score band, not "no findings". A clean project can still have open findings; its next steps then say how many, and how many are critical or high.
  • Nothing measured is not clean. When no file could be analyzed, reports read NOT EVALUATED, and --fail-threshold fails.
  • Findings are leads, not verdicts. The tool reads code statically: it does not run it.

How the score is computed: the scoring model in the guide and docs/MATH_MODELS.md.

VS Code Extension

Findings where you write code, for all four languages: a tint and a severity bar on the line, the message at the end of it, a hover with the Fix and a link that copies a work order for an AI agent, the Problems panel, a sidebar of files by score, and the file score in the status bar. It runs the same local backend; nothing is sent anywhere.

A Rust file in VS Code: severity bars and messages on the todo!(), dbg!() and TODO lines, the file score above the code, and the findings in the Problems panel

Install from the Marketplace · extension guide

CI/CD Integration

# GitHub Actions
- name: AI-SLOP Gate
  run: |
    pip install ai-slop-detector
    slop-detector --project . --ci-mode hard --ci-report
Mode What it does
--ci-mode soft Reports only, never fails the build
--ci-mode hard Fails on a deficit score >= 70, 3 or more critical patterns, inflation >= 1.5 or DDC < 0.5 (inflation and DDC are Python metrics)
--ci-mode quarantine Escalates a file after 3 violations

The gate judges every analyzed file: Python, JS/TS, Go and Rust. pre-commit hooks (slop-detector, slop-detector-warn, slop-detector-patterns) and more: CI/CD in the guide · docs/CI_CD.md.

AI Agents

Surface How
Claude Code skill cp -r claude-skills/slop-detector ~/.claude/skills/: a review loop of review, pulse, sweep with JSON output
AI work order --format ai-md, bound to the SHA-256 of each scanned file (see What You Get)
MCP server slop-detector mcp --root . on the official MCP SDK ([mcp] extra, Python 3.10+): the AI report, the work order and the snapshot / prove loop as tools; on connect it tells the agent their order; every path stays inside the root
Fix loop (CLI) slop-detector snapshot . -o before.json, fix, then slop-detector prove . --before before.json (--format md for a person)
REST A local FastAPI server ([api] extra) that binds 127.0.0.1
Node npx ai-slop-detector runs the same Python backend; typed results at ai-slop-detector/types

The fix loop. The detector never edits code: the agent fixes, the detector measures before and after, a person approves.

flowchart TD
    W["slop_work_order<br/>findings, evidence, one VERIFY question per rule"] --> V{"Agent checks each item"}
    V -->|"REJECT, with the evidence"| D["verify record<br/>ACK / REJECT / UNSURE"]
    V -->|ACK| S["slop_snapshot<br/>before.json, before any edit"]
    D --> S
    S --> F["Agent fixes the ACKed items<br/>and runs the project's tests"]
    F --> P["slop_prove<br/>read-only re-scan, item by item"]
    P -->|"HOLD + reasons"| F
    P -->|REVIEWABLE| H["A person reviews the receipt<br/>and approves or not"]
Tool (MCP) CLI Use it for
slop_work_order --format ai-md starting a review or a fix: the work list with evidence and rules
slop_ai_report --format ai the same findings as JSON Lines records with their ids
slop_snapshot snapshot recording the project before any edit (config_path / --config to scan with a given config)
slop_prove prove the receipt after the fix (output keeps it in a file)
slop_analyze_file, slop_analyze_project - metric snapshots; no finding ids, not a work list

With Claude Code, the skill turns the scanner into a review loop the agent follows instead of a list it reacts to:

generate/edit -> review -> inspect evidence -> apply bounded fixes -> pulse/sweep -> human handoff

review judges changed code (what the change introduced versus what was already there, and whether the build should fail), pulse summarizes the project's health and the order to repair in, and sweep <family> plans one cleanup (dead code, duplicates, unused dependencies, stale suppressions, boundary violations). The skill tells the agent which fixes are safe to make on its own and when to stop and hand over to a person, so the scanner's output is not read as permission for blind edits.

cp -r claude-skills/slop-detector ~/.claude/skills/
pip install ai-slop-detector

An agent working on this repository starts from its memory: mica.yaml selects the decisions a change must not undo, each with the test or the explicit verification procedure that holds it, and the procedure for verifying and releasing. Load it with the context emitter of MICA (python <MICA_ROOT>/tools/mica_runtime.py . --format context).

Details: Claude Code integration · docs/CLAUDE_CODE_SKILL.md · docs/API.md.

Local Calibration

Every scan is recorded locally (~/.slop-detector/history.db) with what measured it, for all four languages. slop-detector . --self-calibrate reports how the weights would change from the comparable runs of one project. It is advisory: it never writes weights; you change them in .slopconfig.yaml if you agree.

The report shows what its evidence is worth, rule by rule: a warning that went away on changed code (its correctness is not checked), a warning left unchanged, a plain suppression, and a false positive you declared with # slop-disable-next-line <rule> fp: <reason>. None of these is taken as proof. An ok recommendation means the best candidate was at least 0.10 ahead of the next one on this project's own history; it is not a validated accuracy gain. --self-calibrate --json prints the same report as data and writes nothing.

slop-detector --init detects the project's domain and sets that domain's pattern thresholds, printing every change. Local calibration in the guide · docs/SELF_CALIBRATION.md.

Security Considerations

  • No network during a scan. A test runs a full project scan with every socket connection refused and requires that none was attempted.
  • --read-only writes nothing to the project or the home directory.
  • history.db lives in your home directory, outside every repository.
  • .slopconfig.yaml lists which functions are exempt from complexity rules, so it maps the weak spots of a codebase; --init adds it to .gitignore (remove that line to share it with your team).
  • Reports describe your code. Every report names file paths, function names and docstring text, and the AI work order (auditor mode) quotes code lines: share them as you would the code.

More: security considerations in the guide · SECURITY.md.


Why Not Just Use a Linter?

Linters such as ruff, pylint and ESLint, and platforms such as SonarQube, check form, style and many quality rules, and some of them flag empty or unused code too. This tool asks a narrower question: does the code contain structural evidence for what it and its docs claim, and did a fix really change it? Structural evidence is not proof that a claim is true; the tool does not run your code.

What it adds How
Structural warning signs 57 rules in four languages, each with the file, line, rule and fix
Hollow-code review (Python) success without effect, inputs never used, failure reported as success; unscored review candidates
Work orders for AI agents each item bound to the SHA-256 of the scanned bytes; fixes that only hide a finding are forbidden
Agent counterarguments ACK / REJECT / UNSURE per item in a verify record
Before and after a fix snapshot and prove: REVIEWABLE or HOLD with the reasons
Final approval a person; REVIEWABLE is never an approval

It does not check style or formatting. Use a linter for correctness of form and this for whether the code does what it appears to do; run both.

When NOT to Use This

  • You want style or formatting enforcement — use ruff / black / ESLint. This tool ignores style on purpose.
  • You need a runtime correctness guarantee — a low score means cleaner structure, not that the code works. Keep your tests.
  • Your code isn't Python, JS/TS, Go or Rust — other languages aren't analyzed yet.
  • You expect thresholds tuned to your repository — weights are the defaults or the values in your .slopconfig.yaml; nothing tunes them automatically. Treat findings as leads, not verdicts.

Help Improve Detection

Found a false positive, a missed pattern, or a finding that misreads your code? Post a minimal, non-sensitive reproduction in Discussions with the detector version, the rule ID, what you expected and what you got. False alarms and misses both help.

How Results Are Checked

Deterministic The same input gives byte-identical JSON across cache, hash seed, Rust helper and working directory; --read-only writes nothing to the project or the home directory.
Says when it measured nothing Every project result carries measurement_state (COMPLETE, PARTIAL, NO_MEASUREMENT) and score_valid. When nothing was measured, human reports read NOT EVALUATED instead of a clean verdict, and a scan whose files all failed to analyze fails --fail-threshold.
Its own tests are tested More than 1,900 tests run in CI on Python 3.8 to 3.12. Behavior changes are checked against deliberately broken copies of the code (mutation testing): in v3.14.0, 133 of 133 breakages of the item identity, binding, work-order and docstring-promise rules were caught; in v3.15.0, 24 of 24 breakages of the work-order families, file table, read-back check and budget (v3.12.0: 21 of 21).
Rules state their reasons Each rule ships with tests that name the code shape it reports and the shapes it leaves alone; the CHANGELOG records every behavior change.

Release Highlights

Version What changed for you
v3.20.0 Reliability around the fix loop. Faster analysis: each Python file is parsed once per analysis (parse calls -64.5% on a 14-repository test corpus, with identical findings at each optimization step; the detection changes below are listed in the changelog). Suppression comments after code are now found on lines with strings, and hydra is recognised as provided by hydra-core. Untested --fix patches are withdrawn and --gate, --governance and --emit-leda-yaml are deprecated. Reports show each item's id; the prove receipt summarizes what changed; snapshot / prove take --config; the VS Code extension adds a read-only Show Fix Loop view. Independent accuracy validation is not part of this release.
v3.19.0 The fix loop for agents. snapshot before a fix and prove after it tell a real fix from a suppressed, deleted or unmeasured one: the receipt is REVIEWABLE or HOLD with the reasons, what each reason means and which decision holds which item. An MCP server on the official SDK ([mcp], Python 3.10+) serves the work order, the AI report and the loop as tools and tells the agent their order on connect. report.md leads with the findings. The legacy --fix is deprecated and no longer damages files. Three edge cases of 3.18.2 are fixed; findings and scores change only where they occur.
v3.18.2 Fewer findings that would send an agent to change correct code: ignored_parameter understands locals() / vars(), a well-known import name that is only undeclared is no longer a phantom import, and explain <rule> says what the rule checks and when its finding does not apply.
v3.18.1 The VS Code extension follows the 3.18 backend (phantom_import Quick Fix, gate, history and pre-commit hook commands) and the documentation is corrected where it no longer described the code. Findings and scores do not change.
v3.18.0 Python import findings are judged by which distribution provides the import and where that evidence comes from (a declared Pillow is no longer a missing PIL); every import finding carries its evidence; phantom_import is HIGH at most; the REST API answers local clients only.
v3.17.0 The terminal summary fits one window (score, band, Fix first, one Next step), --interactive picks the reports to save, and six fix texts recommend only changes that resolve their finding. Scoring is unchanged.
v3.16.3 A file with an fp: declaration stays in every scan (from the second scan on it failed to load from the analysis cache). Scoring is unchanged.
v3.16.2 Self-calibration shows each rule's evidence, history covers all four languages and stores only measured values, and --self-calibrate --json prints the report.
v3.16.1 Rust files are analyzed and judged by the CI gate; Go and JS/TS readers no longer report text inside strings or comments; the CI report states its verdict and lists files it could not analyze.

Every release: docs/RELEASE_NOTES.md · CHANGELOG.md.

Document Map

The full guide holds everything this page leaves out: docs/GUIDE.md.

Topic Where
Every command, the npm wrapper All commands · CLI usage
Reports Reports · AI work order
Rules and analyzers Patterns · What it detects · Adding a language
Scoring and metrics How it works · Math models · Validation
Configuration Configuration guide · Examples · History tracking
Architecture Architecture · Governance · Agent workflow
Releases Release notes · Changelog · Roadmap

More sections of the guide (old links to this page land here):

Development

git clone https://github.com/flamehaven01/AI-SLOP-Detector.git
cd AI-SLOP-Detector
pip install -e ".[dev]"
pytest tests/

Development guide · Contributing · development in the guide.

Download Stats

PyPI weekly downloads

Chart updated weekly via GitHub Actions. Monthly installs: pypistats.org (mirrors excluded). Total: pepy.tech (incl. mirrors)

License

MIT — see LICENSE.


Flamehaven Labs • Issues • Discussions • Docs

探索相关项目

加载中…