Combating AI Slop: A Deterministic Approach to AI-Generated Code Smells
The rise of AI coding agents like Claude Code, Cursor, and GitHub Copilot has fundamentally changed how we write software. While these tools can generate functional code that passes tests and linting, they often introduce a subtle form of technical debt: "AI slop." This refers to patterns that no experienced engineer would write—narrative comments that restate the obvious, swallowed exceptions, redundant safeguards, and hallucinated imports.
Because these issues often bypass traditional linters, they lead to a slow rot in codebase quality. Enter aislop, a CLI tool specifically designed to catch these AI-generated code smells using deterministic rules rather than another layer of LLM-based analysis.
What is AI Slop?
AI slop isn't necessarily broken code; it's code that is functionally correct but structurally poor. Common examples include:
- Narrative Comments: Comments that describe what the code is doing (which is obvious from the code itself) rather than why it is doing it.
- Defensive Over-Engineering: Adding redundant null coalescing operators or guards for cases that the library or serializer already handles.
- Mechanical Failures: Leaving behind
console.logstatements,TODOstubs, oras anycasts in TypeScript. - Structural Bloat: Duplicated helper functions or oversized functions created during iterative AI prompts.
How aislop Works
Unlike many modern "AI-fixing" tools, aislop is deterministic. It does not use an LLM in its runtime path, ensuring that the same code always produces the same score. It achieves this by running six parallel engines:
| Engine | Focus | Tooling Used |
|---|---|---|
| Formatting | Style consistency | Biome, ruff, gofmt, cargo fmt, etc. |
| Linting | Language-specific issues | oxlint, ruff, golangci-lint, clippy, etc. |
| Code Quality | Complexity & dead code | Knip, AST-based unused declaration removal |
| AI Slop | AI-authored patterns | Regex and AST checks for narrative comments, as any, etc. |
| Security | Vulnerabilities | Dependency audits, checks for eval and SQL injection |
| Architecture | Structural rules | Custom import bans and layering rules |
Integration and Workflow
aislop is designed to fit into the existing developer loop, from local development to CI/CD pipelines.
Local Development
Developers can run npx aislop scan to get a quality score from 0-100. For mechanical issues, npx aislop fix can automatically resolve them. For more complex architectural slop, the tool provides a "hand-off" mechanism, allowing developers to pipe the diagnostics directly back into their AI agent (e.g., npx aislop fix --claude) to request a contextual fix.
CI/CD and Quality Gates
To prevent slop from entering the main branch, aislop can be integrated into GitHub Actions or pre-commit hooks. By setting a failBelow threshold in the .aislop/config.yml file, teams can establish a quality gate that blocks PRs if the AI-generated code regresses the overall score.
Agent Hooks
One of the more advanced features is the ability to install hooks (e.g., npx aislop hook install --cursor). This creates a feedback loop where the tool scans the code immediately after an agent edit, providing instant feedback to the AI before the human developer even sees the code.
Community Insights and Counterpoints
While the tool is well-received for its speed and deterministic nature, early adopters on Hacker News have highlighted several challenges inherent in detecting AI slop:
The False Positive Problem
Some users reported that deterministic rules can occasionally misidentify human patterns as AI slop. For instance, one user noted that SQLModel's exec method in Python was flagged as the built-in exec() function. Others mentioned that common Go patterns (ignoring a boolean 'ok' value) were flagged as ignored error returns.
The "Human Slop" Paradox
Interestingly, some users found that the tool flagged code they wrote themselves as AI slop, while some actual AI-generated laziness went unnoticed. As one user noted, "code written by myself is seen as AI, and the lazy AI bits aren't."
Undetected Antipatterns
Experienced developers suggested additional checks that could be integrated into future versions of the tool:
"One of the more common and nefarious patterns I run into is what you might call 'sweeping exceptions under the rug.' ... catching an error, logging a warning that something didn’t work, and continuing, but with now potentially missing/broken state."
Other suggestions included detecting "meta-references" where an AI references its own internal plan or stage of implementation within the comments (e.g., "# This function is part of Stage 3 of the implementation").
Final Thoughts
aislop represents a shift toward "guardrail engineering." As we delegate more of the initial drafting to AI, the role of the human engineer shifts from writing every line to auditing the structural integrity of the output. By providing a deterministic, fast, and integrable way to measure "slop," aislop helps teams maintain high standards without wasting tokens on repetitive review prompts.