Tools

Breathing out

Find the copies and dead code an agent leaves behind.

Rule 12 has two halves. While a feature takes shape the code is allowed to sprawl. Then it has to breathe out: copies merged, dead ends deleted, unused packages dropped. Agents rarely clean up unasked, so these tools put the cleanup in the pull request checks.

Copies

  • Ours

    exhale

    No pull request merges while it leaves duplication or complexity behind.

    Ruby Open source, MIT23 starsLatest release Oct 2026Source

  • Start here

    dupl

    Finds duplicated Go code by comparing syntax trees, so renamed copies still match.

    golangci-lint runs it, which makes it an easy gate for agent-written Go.

    Go Open source, MIT369 starsLatest release Mar 2026

  • Start here

    jscpd

    Copy and paste detector covering over 220 languages, with a failure threshold and an MCP server.

    One binary gives every stack the same duplication gate, and agents can check their own copies through MCP.

    Any language Open source, MIT6.3k starsLatest release Sep 2026Source

  • CloneDR

    Commercial clone detector that parses code and finds exact and near-miss clones with parameterized matching.

    Parse-based matching finds clones that token tools miss, which helps in large legacy codebases.

    Any language Paid

  • DeepSource

    Hosted static analysis that flags complexity and unused code in pull requests.

    Each pull request gets comments, so sprawl is flagged before merge.

    Any language Paid

  • Duplo

    Small line-based duplicate finder for C, C++, C# and Java.

    A light CI check for C-family code, where PMD is heavy.

    Java/JVM, .NET, C/C++ Open source, GPL-2.0131 starsLatest release Jul 2026

  • flay

    Analyzes Ruby code structure to find similar and identical code, scored by mass.

    It catches near copies with renamed variables, which paste-and-tweak edits produce constantly.

    Ruby Open source, MIT770 stars

  • phpcpd-next

    A community fork that keeps the PHP copy and paste detector working on current PHP versions.

    PHP teams whose phpcpd stopped installing can switch to it as a drop-in.

    Version 2.0 needs PHP 8.4 or newer.

    PHP Open source, MITSource

  • PMD CPD

    Token-based copy and paste detector that ships with PMD and handles two dozen languages.

    A minimum token count in Maven, Gradle or CI makes duplicate blocks fail the build.

    Ruby, Python, JavaScript/TypeScript, Go, Java/JVM, .NET, PHP, Swift/iOS, C/C++, Dart/Flutter Open source, BSD-style5.5k starsLatest release Sep 2026Source

  • pylint duplicate-code

    The R0801 check in Pylint that reports similar line blocks across Python files.

    It adds duplication checks to a Pylint run many Python teams already have in CI.

    Python Open source, GPL-2.0Part of PylintLatest release Oct 2026Source

  • Qodana

    JetBrains inspections run in CI, including duplicate and dead-code checks, with quality gates.

    IDE inspections run in the pipeline, so agents face the same checks a developer sees.

    Has a free Community tier.

    Python, JavaScript/TypeScript, Go, Java/JVM, .NET, PHP Paid312 starsLatest release Sep 2026Source

  • similarity

    Rust CLI that finds semantically similar functions and types using tree-sitter, aimed at AI-generated code.

    It finds near duplicates after an agent writes the same helper twice under different names.

    Python, JavaScript/TypeScript, Go, Rust Open source, MIT829 starsLatest release Apr 2026

  • SonarQube

    Code quality server that tracks duplicated lines and blocks, with quality gates on new code.

    Its new-code gate fails a pull request when duplication passes a set percentage.

    Community Edition is free. Paid tiers add branch analysis and more languages.

    Any language Open source, paid tier, LGPL-3.011k starsLatest release Sep 2026Source

  • Teamscale

    Commercial code analysis platform with clone detection and test gap analysis.

    It tracks clones across commits, which shows when copies start piling up.

    Any language Paid

Dead code and unused dependencies

  • Start here

    cargo-machete

    Quickly finds unused Rust dependencies by scanning source for crate names, on stable Rust.

    It runs in seconds, so it fits on every pull request.

    Fast, but it can miss usages or flag crates used only through macros.

    Rust Open source, MIT1.4k starsLatest release Apr 2026

  • Start here

    Dead Code Detector (ShipMonk)

    PHPStan extension that finds unused PHP classes, methods, constants and properties.

    It runs inside the PHPStan pass most PHP projects already have.

    PHP Open source, MIT521 starsLatest release Sep 2026

  • Start here

    Gradle Dependency Analysis plugin

    Gradle plugin that finds unused and misdeclared dependencies and can fail the build.

    It keeps the dependency list honest in multi-module builds that agents edit.

    Java/JVM Open source, Apache-2.02.2k starsLatest release Sep 2026

  • Start here

    knip

    Finds unused files, exports and dependencies in JavaScript and TypeScript projects.

    Files and packages that agents add and never use get flagged before they pile up.

    Has an MCP server and plugins for most frameworks.

    JavaScript/TypeScript Open source, ISC12k starsLatest release Oct 2026Source

  • Start here

    mix_unused

    Mix compiler that reports public Elixir functions that nothing calls.

    Unused public functions become compile warnings that a CI step can fail on.

    Elixir/Erlang Open source, MIT229 starsLatest release Jun 2023

  • Start here

    Scalac -Wunused and Scalafix

    Compiler warnings for unused imports and values, with Scalafix rules that remove them.

    The compiler flag makes unused code a build failure with no extra tool.

    Java/JVM Open source, BSD-3-ClausePart of ScalacLatest release Sep 2026Source

  • Start here

    vulture

    Finds unused functions, classes, variables, imports and unreachable code in Python, with confidence scores.

    The confidence score lets a CI gate fail only on findings the tool is sure about.

    Dynamic code such as getattr and frameworks causes false positives. Use a whitelist.

    Python Open source, MIT4.8k starsLatest release Mar 2026

  • cargo-shear

    Detects and removes unused or misplaced Rust dependencies and unlinked source files.

    It also finds source files no module includes, a common leftover after agent refactors.

    Rust Open source, MIT571 starsLatest release Sep 2026

  • cargo-udeps

    Finds unused dependencies in Cargo.toml by compiling the project. Needs nightly Rust.

    Fewer false positives than the fast tools make it a good scheduled deep check.

    Rust Open source, MIT/Apache-2.02.1k starsLatest release Apr 2026

  • composer-unused

    Lists Composer packages that your PHP code never uses.

    Packages added during an experiment stop lingering in composer.json.

    PHP Open source, MIT1.7k starsLatest release Jan 2026

  • coverband

    Records which Ruby code runs in production so you can see which code never does.

    Runtime evidence settles what static tools can only guess, so deleting agent-written code gets safer.

    Needs a Redis store and production traffic.

    Ruby Open source, MIT2.7k starsLatest release Apr 2026

  • deadcode (Python)

    Finds unused Python code and can remove it automatically with a --fix flag.

    The --fix flag lets an agent delete what it finds in one pass.

    Licensed under AGPL-3.0, which may matter to some teams.

    Python Open source, AGPL-3.0177 stars

  • debride

    Static analysis that lists Ruby methods that nothing appears to call.

    It gives a first list of removal candidates in a Rails app that agents have grown.

    Rails dynamic calls cause false positives. Pair it with coverband.

    Ruby Open source, MIT775 stars

  • dependency_validator

    Dart tool that checks pubspec.yaml for unused and missing dependencies.

    It keeps pubspec files clean after agents try out packages.

    Dart/Flutter Open source, Apache-2.066 starsLatest release Sep 2026

  • deptry

    Checks Python projects for unused and missing dependencies, including transitive ones.

    Packages an agent adds and forgets fail the build here when they are declared but never used.

    Python Open source, MIT1.5k starsLatest release Mar 2026Source

  • i18n-tasks

    Finds missing and unused translation keys in Rails and Ruby projects.

    A spec that runs it keeps locale files in step with edited views.

    Ruby Open source, MIT2.2k starsLatest release Dec 2025

  • include-what-you-use

    Clang-based tool that finds unnecessary C and C++ includes and suggests the right ones.

    Include sprawl slows builds, and agents add headers freely.

    C/C++ Open source, LLVM/NCSA4.8k starsLatest release Oct 2026Source

  • JetBrains Rider and ReSharper inspections

    IDE inspections that mark unused types and members in C# code.

    Teams already on Rider or ReSharper get unused-code checks they know.

    .NET Paid

  • Maven dependency:analyze

    Maven goal that reports declared-but-unused and used-but-undeclared dependencies.

    It ships with Maven and can fail the build through failOnWarning.

    Java/JVM Open source, Apache-2.0Part of Maven

  • traceroute

    Rake task that lists Rails routes with no matching controller action and the reverse.

    Routes and actions get added separately, so one side often ends up orphaned.

    Ruby Open source, MIT904 stars

  • ts-prune

    Lists unused exports in TypeScript projects.

    It lingers in many CI configs, and knip has replaced it.

    Superseded by knip.

    JavaScript/TypeScript Open source, MIT2.1k starsLatest release Dec 2021

  • ts-unused-exports

    Finds exported TypeScript symbols that no other module imports.

    A smaller option for teams that want only an unused-export check.

    JavaScript/TypeScript Open source, MIT800 stars

  • unimport

    Detects and removes unused Python imports.

    It clears the import litter left after refactors, though Ruff's F401 rule does the same job for most teams.

    Python Open source, MIT248 starsLatest release Oct 2026Source

Complexity limits

  • Start here

    DCM (DCM for Dart)

    Dart and Flutter analyzer with metrics, unused code and unused files checks.

    Metrics and unused-code limits for Dart and Flutter come from one analyzer.

    Dart/Flutter Paid

  • Start here

    Lizard

    Measures cyclomatic complexity and function size in over 25 languages, with threshold exit codes.

    One tool and one set of limits cover every language in a polyglot repo.

    Any language Open source, MIT2.5k starsLatest release Oct 2026

  • Start here

    NDepend

    Commercial .NET analyzer with code metrics and a query language for dependency rules that can fail builds.

    A team can write its complexity and layering gates for C# in one place.

    .NET Paid

  • Clippy cognitive_complexity

    Clippy lint that warns when a Rust function's cognitive complexity passes a set threshold.

    It rides along with the cargo clippy step teams already run.

    The lint sits in the nursery group, so it must be enabled by name.

    Rust Open source, Apache-2.0Part of ClippySource

  • Codacy

    Hosted code quality platform with pull request gates for complexity, duplication, coverage and security.

    Many languages get one merge gate without anyone running a server.

    Any language Paid

  • CodeScene

    Behavioral code analysis that scores code health and finds hotspots from git history, with PR quality gates.

    It points at files where heavy change and high complexity overlap, and offers guidance for AI-written code.

    Free for open source projects.

    Any language Paid

  • complexipy

    Rust-based cognitive complexity checker for Python with a configurable failure threshold.

    Cognitive complexity tracks how hard code is to read, which suits checking agent output.

    Python Open source, MIT875 starsLatest release Sep 2026

  • ESLint complexity rules

    Built-in ESLint rules that cap cyclomatic complexity, nesting depth, function length and parameter count.

    They run on every save with no extra install, so agents hit the limits while they write.

    JavaScript/TypeScript Open source, MITPart of ESLintLatest release Oct 2026Source

  • eslint-plugin-sonarjs

    ESLint plugin that adds cognitive-complexity and identical-function rules.

    The identical-function rule catches same-file copies, which agents like to make.

    JavaScript/TypeScript Open source, LGPL-3.01.3k starsLatest release Sep 2026

  • flog

    Scores Ruby methods by how painful they are to test and read, using an ABC-style metric.

    A flog score per method makes bloated agent-written methods easy to spot.

    Ruby Open source, MIT969 stars

  • gocognit

    Computes cognitive complexity of Go functions and can fail above a limit.

    Cognitive complexity penalizes nesting, which is where agent-written Go tends to sprawl.

    Go Open source, MIT493 starsLatest release Oct 2026

  • gocyclo

    Computes cyclomatic complexity of Go functions and can fail above a limit.

    A tiny, quick gate that is also available inside golangci-lint.

    Go Open source, BSD-3-Clause1.6k stars

  • PHPMD

    PHP Mess Detector with rules for complexity, long methods, unused code and too many parameters.

    One ruleset covers complexity and unused private code in PHP.

    PHP Open source, BSD-3-Clause2.5k starsLatest release Oct 2026Source

  • PhpMetrics

    Reports complexity and maintainability metrics for PHP projects, including coupling, as HTML reports.

    Maintainability and coupling numbers make useful trend lines for PHP code that agents are growing.

    PHP Open source, MIT2.6k starsLatest release Aug 2026Source

  • Qlty

    CLI that wraps over 70 linters and reports duplication, complexity and maintainability grades.

    Its git-aware mode reports only new issues, which suits a gate on agent pull requests.

    Successor to Code Climate Quality, whose API was disabled on 2025-07-18.

    Any language Open source, paid tier, BSL-1.13.2k starsLatest release Oct 2026Source

  • radon

    Computes cyclomatic complexity and Halstead metrics for Python, plus a maintainability index.

    The maintainability grade gives one number to track as agents add code.

    Release cadence is slow.

    Python Open source, MIT2k starsSource

  • RuboCop Metrics cops

    RuboCop cops that limit method length, class length, ABC size and cyclomatic and perceived complexity.

    Most Ruby teams already run RuboCop in CI, so limits take one config change.

    Ruby Open source, MITPart of RuboCopLatest release Sep 2026Source

  • rust-code-analysis

    Mozilla's library and CLI for computing code metrics such as cyclomatic and cognitive complexity across several languages.

    A scriptable metrics engine for teams that build their own gates.

    Any language Open source, MPL-2.0459 starsLatest release Jan 2023

  • scc

    Very fast code counter that also estimates complexity per file for over 300 languages.

    It gives a quick size and complexity snapshot of a repo that agents are growing.

    Gives estimates only and has no failure threshold.

    Any language Open source, MIT8.8k starsLatest release Sep 2026

  • wily

    Tracks Python complexity metrics across git history and graphs the trend.

    The trend shows whether a month of agent work left the code heavier.

    Python Open source, Apache-2.01.3k starsLatest release Oct 2023

  • xenon

    Fails a Python build when radon complexity exceeds set grades per function, module or whole project.

    It adds the failing threshold to radon, which suits a merge check.

    Release cadence is slow.

    Python Open source, MIT282 stars

Gone quiet 6

These tools are archived or shut down, or nobody has released or committed to them in two years. Some still work fine. Read the note before you adopt one.

  • depcheck

    Reports npm dependencies that no file imports and imports missing from package.json.

    It was the usual unused-dependency check, so existing pipelines may still call it.

    Archived in 2025. Use knip.

    JavaScript/TypeScript Open source, MIT4.9k starsLast change Feb 2025

  • Periphery

    Finds unused Swift declarations by analyzing the compiler's index store.

    Unused declarations pile up fast in agent-written Swift, and this was the tool Swift teams reached for.

    The open source repo was archived on 2026-08-12 and the tool is now a commercial product.

    Swift/iOS Paid6.2k starsLast change Aug 2026

  • phpcpd

    The original PHP copy and paste detector from the PHPUnit author.

    Many PHP projects still run it, so it helps to know it is archived and where to move.

    Archived. phpcpd-next continues it and PMD CPD also supports PHP.

    PHP Open source, BSD-3-Clause2.2k starsLast change Jan 2023

  • sbt-explicit-dependencies

    sbt plugin that checks for undeclared and unused library dependencies.

    It catches dependency drift in sbt builds.

    Dormant since 2024.

    Java/JVM Open source, Apache-2.0294 starsLast change Aug 2024

  • Simian

    Long-standing similarity analyser that works on most text-based languages.

    It still appears in older build setups.

    Dormant. Quandary Peak released it as open source under Apache 2.0.

    Java/JVM, .NET, C/C++ Open source, Apache-2.0

  • unimported

    Finds files and dependencies that nothing imports from your entry points.

    Teams moving off it should go to knip.

    Archived. Use knip.

    JavaScript/TypeScript Open source, MIT2k starsLast change Mar 2024

Missing a tool that belongs here? Suggest it.

Every tool here was checked against its GitHub repository or its own site on 6 October 2026. Stars and dates come from GitHub on that day.