Show HN: AISlop,一个用于捕获 AI 生成代码异味的命令行工具
Show HN: AISlop, a CLI for catching AI generated code smells

原始链接: https://github.com/scanaislop/aislop

**aislop** 是一款开源的确定性工具,旨在捕获并清理 AI 代码助手经常生成的“垃圾内容”(slop),例如叙述性注释、被吞掉的异常、无效代码以及幻觉导入。虽然 AI 生成的代码可以通过测试和代码检查工具,但它们往往会随时间推移降低项目质量。 **主要功能包括:** * **质量评分:** 使用七种主流语言的 40 多条规则对代码进行 0–100 分的评分。 * **确定性分析:** 无需依赖大语言模型(LLM),确保结果一致,无需外部 API 调用,亦无延迟。 * **自动修复:** 自动解决琐碎问题(如未使用的导入、格式化等),并可直接与 Claude Code、Cursor 和 Gemini 等工具集成,在完整上下文下解决复杂问题。 * **支持 CI/CD:** 包含质量门禁,若代码质量低于预设阈值,可阻止合并。 * **易于使用:** 通过 `npx` 运行,无需安装,适用于任何项目,并支持自定义配置。 通过提供统一的质量门禁,aislop 可确保 AI 辅助的工作流保持整洁、可维护且专业。立即运行 `npx aislop scan` 开始使用。

开发者 Kenny (Heavykenny) 推出了 **AISlop**,这是一款本地命令行工具,专门用于检测“AI 代码异味”(AI code smells)——即大模型常生成的欠佳代码模式,如空的 catch 代码块、冗余代码和无用注释等。与标准代码检查工具(linter)不同,AISlop 专门针对 AI 代理经常表现出的重复或草率习惯进行了优化。 该工具在本地运行,确保了代码隐私,并可集成到开发钩子(hooks)中以提供即时反馈。在 Hacker News 上,用户的反响大多积极,将其视为审查 AI 生成内容的一种有益的“质量控制”层。尽管一些评论者对“AISlop”这个名称是否恰当进行了讨论,并质疑无论作者是谁,重点是否都应仅仅放在代码质量本身,但开发者明确表示,其主要目标是通过捕获可能逃过自动化工作流的低质量设计模式,来防止代码库的长期退化。用户可以通过 `npx aislop scan` 测试 AISlop。
相关文章

原文

Catch the slop AI coding agents leave in your code.

npm version npm downloads CI aislop score License: MIT Node >= 20

The patterns Claude Code, Cursor, Codex, and OpenCode leave behind: narrative comments above self-explanatory code, swallowed exceptions, as any casts, hallucinated imports, duplicated helpers, dead code, todo stubs, oversized functions. Tests pass. Lint passes. The code rots anyway.

aislop catches them. 40+ rules across 7 languages (TS/JS, Python, Go, Rust, Ruby, PHP, Java). Scores every change 0–100. Sub-second. Deterministic — no LLM in the runtime path, same code in, same score out. MIT-licensed, free CLI.

No install needed. Works on any project. Get your score in seconds.

npx aislop fix                   # auto-fix issues
npx aislop fix -f                # aggressive fixes (deps, unused files)
npx aislop ci                    # CI mode (JSON + gate)
npx aislop hook install --claude # per-edit hook

Public badge: Show your score on your README

[![aislop](https://badges.scanaislop.com/score/<owner>/<repo>.svg)](https://scanaislop.com)

Run npx aislop badge to auto-generate. Free at scanaislop.com.

aislop scan demo


# Run without installing
npx aislop scan

# npm
npm install --save-dev aislop

# yarn
yarn add --dev aislop

# pnpm
pnpm add -D aislop

# Global
npm install -g aislop

Also available as @scanaislop/aislop on GitHub Packages.


npx aislop scan           # current directory
npx aislop scan ./src     # specific directory
npx aislop scan --changes # changed files from HEAD
npx aislop scan --staged  # staged files only
npx aislop scan --json    # JSON output

Exclude files: node_modules, .git, dist, build, coverage excluded by default. Add more in .aislop/config.yml:

exclude:
  - "**/*.test.ts"
  - src/generated

Or via CLI: npx aislop scan --exclude "**/*.test.ts,dist"

Extend config: Project config can extend a parent:

# .aislop/config.yml
extends: ../../.aislop/base.yml
ci:
  failBelow: 80             # override specific keys

Auto-fix what's mechanical (formatters, unused imports, dead code). For issues that need context, hand off to your agent with full diagnostic info.

npx aislop fix                 # safe auto-fixes
npx aislop fix -f              # aggressive: deps, unused files

When auto-fix can't solve it, pass the remaining issues to your coding agent with full context:

npx aislop fix --claude        # Claude Code
npx aislop fix --cursor        # Cursor (copies to clipboard)
npx aislop fix --gemini        # Gemini CLI
npx aislop fix --codex         # Codex CLI
# Also: --windsurf, --amp, --aider, --goose, --opencode, --warp, --kimi, --antigravity, --deep-agents, --vscode
npx aislop fix --prompt        # print prompt (agent-agnostic)

Runs after every agent edit. Feedback flows back immediately.

npx aislop hook install --claude           # Claude Code
npx aislop hook install --cursor           # Cursor
npx aislop hook install --gemini           # Gemini CLI
npx aislop hook install                    # all supported agents
npx aislop hook install claude cursor      # specific agents

Runtime adapters (scan + feedback): claude, cursor, gemini.
Rules-only (agent reads rules): codex, windsurf, cline, kilocode, antigravity, copilot.

Quality-gate mode: Blocks if score regresses below baseline.

npx aislop hook install --claude --quality-gate
npx aislop hook baseline                    # re-capture baseline
npx aislop hook status                      # list installed
npx aislop hook uninstall --claude          # remove

Docs: /docs/hooks

Expose aislop as MCP tools for Claude Desktop, Cursor, Codex:

Tools: aislop_scan, aislop_fix, aislop_why, aislop_baseline

npx aislop ci                  # JSON output, exits 1 if score < threshold
npx aislop init                # create .aislop/config.yml
npx aislop init --strict       # enterprise-grade gate: all engines, typecheck, failBelow 85
npx aislop rules               # list rules
npx aislop badge               # print badge URL
npx aislop                     # interactive menu

Docs: commands


Run npx aislop init and accept the workflow prompt, or add manually:

- uses: actions/checkout@v4
- uses: actions/setup-node@v4
  with:
    node-version: 20
- run: npx aislop@latest ci .

Composite action:

- uses: actions/checkout@v4
- uses: scanaislop/[email protected]

Set minimum score in .aislop/config.yml:

aislop ci exits 1 when score < threshold. Docs: CI/CD


scanaislop is the hosted platform for teams:

  • PR gates with score thresholds
  • Standards hierarchy (org → team → project)
  • Dashboards and agent attribution
  • Visual rules manager

Same engines, same scores. CLI is MIT-licensed. Learn more →


AI coding tools generate code that compiles and passes tests but ships with patterns no engineer would write. aislop gives you one score, one gate, and auto-fixes what it can.

  • One score: 0-100, enforced in CI. Weighted so sloppy patterns hit harder than style noise.
  • Auto-fix first: Clears formatters, unused imports, dead code mechanically. Hands off the rest to your agent with full context.
  • Deterministic: Regex + AST + standard tooling. No LLMs, no API calls. Same code in, same score out.
  • Zero-config start: npx aislop scan works on any repo. Add .aislop/config.yml to tune.

Six deterministic engines run in parallel:

Engine What it checks How
Formatting Code style consistency Biome, ruff, gofmt, cargo fmt, rubocop, php-cs-fixer
Linting Language-specific issues oxlint, ruff, golangci-lint, clippy, expo-doctor
Code Quality Complexity and dead code Function/file size limits, deep nesting, unused files/deps (knip), AST-based unused-declaration removal
AI Slop AI-authored code patterns Narrative comments, trivial comments, dead patterns, unused imports, as any, console.log leftovers, TODO stubs, generic names
Security Vulnerabilities and risky code eval, innerHTML, SQL/shell injection, dependency audits (npm/pip/cargo/govulncheck)
Architecture Structural rules (opt-in) Custom import bans, layering rules, required patterns

See the full rules reference.


Installation · Commands · Rules · Config · Scoring · CI/CD · Telemetry

Discussions for questions, rule requests, and false-positive triage · Issues for bugs

See CONTRIBUTING.md. AI assistants: AGENTS.md.

Built on: Biome, oxlint, knip, ruff, golangci-lint, expo-doctor

Auto-updated by .github/workflows/contributors.yml. Link commit email or add to .github/contributors-overrides.json.

MIT

联系我们 contact @ memedata.com