This CLI tool cleans up AI code slop for you

04 Jun 2026 02:37 35,009 views
AI coding assistants are great at generating code—but terrible at cleaning up after themselves. This article breaks down a Rust-based CLI tool that finds dead code, duplication, and boundary violations, and even auto-fixes them so your AI-assisted projects stay lean and maintainable.

AI coding tools can ship features fast, but they also leave a mess behind. Extra files, unused exports, duplicated functions, and broken architecture boundaries quietly pile up until your codebase turns into a wall of slop. The good news: there’s now a command-line tool designed specifically to fight that mess.

This Rust-based CLI (referred to here as “this tool”) scans your project for dead code, duplication, architectural violations, and more—then gives you clear, machine- and human-friendly reports that are perfect for both developers and AI agents.

Why AI-generated code creates so much slop

AI assistants love to generate new code, but they’re not great at cleaning up what they no longer need. Ask an AI to refactor a function and you might get 10 lines removed and 2,000 new ones added. Old functions stay in the codebase, unused types linger, and slightly different versions of the same helper function appear in three different folders.

Over time, this “code slop” doesn’t just bloat your repository. It also pollutes the context that AI agents rely on. When your codebase is full of unused and duplicated pieces, AI models can easily make wrong assumptions about what’s actually in use, leading to worse suggestions and more confusion.

If you’re building serious AI-assisted workflows, it’s worth pairing your agents with a cleanup tool—just like you’d pair them with a good editor or test runner. For broader ideas on building a modern AI dev stack, check out the only AI coding tools worth learning in 2026.

Meet the Rust-powered CLI that hunts code slop

This tool is a fast, Rust-built CLI that analyzes your codebase and surfaces:

• Dead code (unused exports, types, files, and dependencies)
• Duplicate code (exact, near-duplicate, and semantically similar clones)
• Architectural boundary violations (for example, UI importing directly from database code)
• High-impact refactor targets (based on complexity and confidence)

Because it’s written in Rust, it’s designed to be fast enough to run frequently—locally, in CI, or even as part of an AI agent’s workflow.

Using it is simple. You run a command like:

npx fow dead-code
npx fow dupes
npx fow health

Each command generates a focused report you can act on immediately or feed into an AI agent.

Finding and removing dead code

The dead code command scans your project for things that no longer serve any purpose, such as:

• Unused exports (functions, components, constants)
• Unused TypeScript types
• Unused files
• Unused dependencies and test-only dependencies

In practice, most projects see a surprising amount of waste on the first run. The tool’s own docs mention that many codebases surface 50+ unused exports right away. In the example from the transcript, the scan found 15 unused exports, 19 unused types, and a couple of unused dependencies—including a stray d3-array package that was never referenced.

The report is very concrete: it tells you the file, the line, and exactly what’s unused. That makes it trivial for:

• A developer to clean things up manually
• An AI agent to apply targeted edits without guessing

You can even wire this into an AI skill that runs after each commit, so the agent not only writes code but also cleans up any dead code it leaves behind.

Enforcing architecture with boundary rules

One of the standout features of the dead code tool is its support for boundary violations. You can define architectural rules in a JSON config file so the tool can enforce them automatically. For example:

• UI code must never import directly from /database
• Certain folders should not depend on others
• Server-only modules must not be pulled into client code

These rules are defined using glob patterns, and there are presets you can start from or you can customize them to match your project structure. When the tool detects a violation, it flags it clearly in the report.

This is useful not just for AI agents, but for human teams too. Instead of waiting for a code reviewer to notice that someone imported a server module into a client component, your CI can fail or warn early. That shortens feedback loops and avoids awkward “your architecture is wrong” comments in reviews—let the robot deliver the bad news.

Detecting duplicate code with the dupes command

Another classic AI behavior: instead of reusing an existing helper, it just writes a new one that does almost the same thing. Over time, this leads to multiple versions of similar logic scattered across the codebase.

The dupes command is built to catch that. By default, it uses AST-based tokenization to find clones, which means it looks at the structure of your code rather than just raw text. It can:

• Detect duplicated blocks within the same file
• Find similar code across different files
• Work across JavaScript and TypeScript

There are multiple detection modes:

• A default AST-based mode for structured matching
• A “weak” mode that does simpler string-based comparisons
• A semantic mode that tries to detect code that was copied and slightly adapted (for example, same logic, different variable names)

Not every duplication it finds will need to be refactored, and that’s expected. The tool is highly configurable, so you can tune what counts as a duplicate and decide which findings matter for your style and architecture. But it’s especially powerful when paired with an AI that refuses to reuse functions—run dupes, feed the report to the AI, and ask it to consolidate repeated logic.

Health reports for high-impact refactors

The health command gives you a higher-level view of where to refactor next. Instead of just listing issues, it prioritizes them based on:

• Code complexity
• Dead code presence
• Estimated effort
• Confidence that the change will improve the code

For example, it might flag a file like dateNormalization.ts and suggest: “Remove five unused exports to reduce its surface area.” That’s the kind of clear, actionable instruction that both a junior developer and an AI agent can follow without much context.

This turns the tool into a refactoring guide, not just a linter. You can take the top health suggestions and systematically improve your codebase, or have an AI agent work through them one by one.

Safe auto-fixes with dry runs

The tool also supports autofix for certain issues. You can run a command like:

npx fow fix --dry-run

This shows you exactly what changes it plans to make before it touches your files. Once you’re comfortable with the plan, you can run the same command without --dry-run to apply the fixes.

In the example from the transcript, the tool didn’t blindly delete a function—it simply removed an unnecessary export while keeping the implementation. That kind of conservative, targeted change makes autofix much less scary.

Because it’s fast, you can run these fixes frequently: locally, in pre-commit hooks, or as part of a CI pipeline.

Perfect for AI agents and automated workflows

This CLI is built to play nicely with AI agents and automated workflows. It offers:

Agent skills: prebuilt skills you can plug into your AI agent so it knows how to run the tool and interpret results.
Cloud code hooks: run checks automatically when code changes.
VS Code extension: surface issues right in your editor.
CI integration and health badges: keep an eye on code health over time.

Instead of writing custom scripts for every project, you can give your agent a standard toolkit: “Run dead code, dupes, and health; then fix what you safely can.” If you’re interested in deeper AI workflow automation, especially around coding, you might also like these Claude Code tricks for faster AI workflows.

Broad framework and tooling support

Out of the box, the tool ships with around 90 built-in plugins, so it understands many popular frameworks and build systems without extra setup. That includes:

• Frontend frameworks: SvelteKit, Gatsby, Astro, Angular, Next.js, Expo, and more
• Backend and full-stack: NestJS, Nitro, and others
• Bundlers: Vite, Webpack, Rspack, Rsbuild, Rollup, and more
• TypeScript tooling and linters

It also supports SCSS and Tailwind analysis, so you’re not limited to just JavaScript and TypeScript logic. In many cases, you can drop it into an existing project and start getting useful reports immediately.

Keeping AI-assisted codebases lean and healthy

As AI coding tools become standard, the real challenge isn’t generating code—it’s keeping that codebase clean, consistent, and maintainable over time. This Rust-based CLI is a strong companion for any AI-heavy workflow:

• It finds dead code before it pollutes your context.
• It catches duplication before it spreads across your repo.
• It enforces boundaries so your architecture doesn’t quietly rot.
• It gives clear, actionable refactor suggestions that humans and AIs can follow.

Whether you’re working solo with an AI assistant or running a full team, adding a tool like this to your stack can turn chaotic AI output into something you can confidently ship and maintain.

Share:

Comments

No comments yet. Be the first to share your thoughts!

More in Code Assistants