logo

slopo

The missing piece in AI‑assisted development

Open-source CLI tool for detecting non-exact code duplication separated across the codebase. A kind of problem frequently introduced by AI agents and difficult for them to detect.

How detection works

It uses embedding models for semantic code duplication detection, surfacing similar code that's written differently. Distance in the codebase influences the final score. The further away similar code is, the higher its priority.

Supported languages

Python, TypeScript, JavaScript, Java, Kotlin, C#, Go, Rust

Installation

uv tool install slopo

This command uses uv (installing uv), a Python package manager, to install Slopo from PyPI in an isolated virtual environment. No need to get Python separately.

Why agents need help here

Source of duplication

Without rigor, a clear architecture design, and a specification available to it, an AI agent tends to implement logic that already exists elsewhere. It isn't a copy of the code, it's a new implementation of the same solution.

Why it hurts

Duplicated code confuses AI, making it less reliable when deciding where to add new related logic or which existing code to edit. It may update one copy while the others drift out of sync. This problem isn't unique to AI, but AI creates chaos faster than humans do.

The blind spot

AI agents struggle with one specific kind of duplicate. They can find shared names, trace how code is called and referenced, or reason about the part of the system they are working in. But they can't load the whole codebase into context at once, so they miss distant functions that do the same thing in a different form.

Slopo works with your agent

Before involving your agent, exclude obvious noise like test files.

Filter out non-duplicates

Not every code duplication is unwanted, and not all semantically similar code is a duplicate. They make up much of your early results but are easily filtered out by your AI agent. Once added to the ignore list, they won't reappear until the related code changes.

Prompt: filtering
"slopo-report" directory contains information about possibly duplicated code. This code is only similar according to their embeddings, so many of them are not real duplicates we want to act on. "index.md" contains a list of all similar code clusters, and every cluster is in a separate file. Review each cluster and insert its hash into the "slopo.ignore.txt" file if this is not a real duplication. Process clusters in batches; don't load everything at once.

Let your agent refactor

Once the results are clear of the duplicates we don't want to act on, we can focus on the actual fixes. Now an AI agent can look deeper into a single group of similar code, assess it again, and analyze its scope and impact. With more information, we can decide to refactor the group or skip it.

Prompt: refactor
"slopo-report" directory contains information about duplicated code grouped in clusters. Every cluster is in a separate file, and "index.md" contains a list of all clusters. Analyze the first cluster to: verify if this is a real duplication worth refactoring, is there more related similar code, what the scope and impact are, how beneficial and risky refactoring can be.

Documentation

Full documentation is on GitHub, with installation, configuration options, and detailed usage.

View on GitHub