mcpField
A
anti-slop

anti-slop

github.com/b4r7xTesting & quality079 installsUpdated 12w ago
Repository

About anti-slop

Anti-Slop is a code-auditing skill for identifying patterns associated with AI-generated code. It checks supported source files against a pattern catalog and produces a structured report with locations, severity, and suggested fixes.

Key features

  1. 01Audits supported source files
  2. 02Checks seven code-pattern categories
  3. 03Reports lines and severity
  4. 04Suggests concise fixes
  5. 05Marks audits of long files as partial

Use cases

  1. 01Review code for unnecessary complexity
  2. 02Locate dead code and type workarounds
  3. 03Check several files for repeated utilities

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/b4r7x/agent-skills --skill anti-slop

After installing, type/anti-slopin Claude Code to confirm it loaded.

Bundled filesreferences/slop-code-patterns.md

Details

From the project README

Anti-Slop

Audits source code for AI-generated slop patterns and outputs a structured report.

Workflow

Step 1 — Resolve files

Parse the argument as file paths or glob patterns. Expand globs to a concrete file list.

# If argument is a glob like "src/**/*.ts", expand it
# If argument is a file path, use it directly
# If multiple paths/globs, expand all

Supported extensions: .ts, .tsx, .js, .jsx, .py, .go, .rs, .java, .rb, .php, .swift, .kt

Files larger than 1000 lines: audit only the first 500 lines and mark the file's report entry partial — first 500 of N lines; never present a partial audit as complete.

If no argument is provided, prompt the user:

"Which files should I audit? Pass file paths or glob patterns (e.g. src/**/*.ts)."

Step 2 — Read the pattern catalog

Read references/slop-code-patterns.md for the full detection rules and severity guide.

Step 3 — Audit each file

For each file:

  1. Read the file contents

  2. Scan for patterns across all 7 categories:

    • Cat 1: Unnecessary comments — restating code, obvious JSDoc, vague TODOs, section dividers, "removed" markers
    • Cat 2: Over-engineering — premature abstractions, unnecessary factories, config for hardcoded values, forwarding wrappers, one-off interfaces
    • Cat 3: Defensive over-coding — null checks on non-nullable types, try-catch on infallible ops, redundant else-after-return, verbose error messages, fallbacks hiding bugs
    • Cat 4: AI voice — "enhanced/optimized/improved" naming, "ensure/robust/graceful" comments, control-flow narration, apologetic comments
    • Cat 5: Dead code — unused imports, assigned-but-unread variables, unreachable code, backwards-compat re-exports
    • Cat 6: Type workarounds — as any, unexplained @ts-ignore, unnecessary assertions
    • Cat 7: Verbose patterns — ternary replaceable by ??, boolean verbosity, unnecessary async/await, pointless spread
  3. For each issue found, record:

    • Line number(s)
    • Category (1-7)
    • Pattern (e.g., "1a: restating code")
    • Severity (high / medium / low)
    • The offending code (1-3 lines)
    • Suggested fix (brief — what to do, not the full rewrite)
Step 4 — Cross-file checks

After individual file audits, check for cross-file patterns:

  • Functions called from only one file — may be premature abstractions (Cat 2a)
  • Exported symbols not imported elsewhere — may be dead code (Cat 5d)
  • Duplicated utility functions across files — AI often creates the same helper in multiple places

Only run these if auditing 3+ files. Use grep to search for function/export usage across the codebase.

Step 5 — Output the report

Format the report as follows:

## Anti-Slop Audit Report

**Files audited:** N
**Issues found:** N (H high, M medium, L low)

---

### `path/to/file.ts`

| Line | Severity | Category | Pattern | Issue |
|------|----------|----------|---------|-------|
| 12 | medium | Unnecessary comment | 1a: restating code | `// set the name` above `this.name = name` |
| 45-52 | medium | Over-engineering | 2a: premature abstraction | `formatDate()` called once, body is one line |
| 89 | high | Type workaround | 6a: `as any` | `response.data as any` — fix the response type |

**Suggested fixes:**
- L12: Delete the comment
- L45-52: Inline `formatDate()` at L78
- L89: Type `response.data` as `ApiResponse` based on the fetch call at L85

---

### `path/to/other-file.ts`
...

---

### Cross-File Issues

- `formatSlug()` defined in `utils.ts:34` is only imported by `page.ts:2` — consider inlining
- `UserDTO` exported from `types.ts:12` is not imported anywhere

---

### Summary by Category

| Category | Count |
|----------|-------|
| 1. Unnecessary comments | N |
| 2. Over-engineering | N |
| 3. Defensive over-coding | N |
| 4. AI voice | N |
| 5. Dead code | N |
| 6. Type workarounds | N |
| 7. Verbose patterns | N |

If zero issues are found, output:

## Anti-Slop Audit Report

**Files audited:** N
**Issues found:** 0

Clean. No slop detected.

Comments

Markdown supported