• free & MIT
  • local-first
  • pre-commit
  • MCP

Your agent grows the code. Prune trims it.

A structural linter for AI-written TypeScript. Prune finds the dead exports, orphan files, duplicate types and god files your agent leaves behind, then hands the cleanup back to it as tasks it can verify.

Set up Prune in this repo by following https://prunecode.ai/setup, then show me the top cleanup tasks.

works with Claude Code, Cursor, Codex, Copilot and any MCP client

prune · your codebase, trimmed

why prune

Linters check each line. Agents make a mess across files.

Every line an agent writes can pass lint and typecheck while the codebase quietly grows a second User type, a helper nobody calls, and a file nothing imports. Prune reads the whole module graph, so it sees those problems.

eslint · tsc · biome

src/lib/format.tsone file
export function formatDate(d: Date) {
  const opts = { month: "short" };
  return d.toLocaleDateString();
}
  • Unused variables inside a file
  • Type errors and syntax
  • Style and formatting

prune

page.tsx api.ts User format.ts UserDTO orphan.ts nothing imports it same shape
  • Exports and files nothing reachable uses
  • The same shape declared under several names
  • God files, runtime import cycles, near-duplicate functions

set it up

You don't configure it. Your agent does.

The one line at the top of this page is the whole install. Your agent follows a runbook written for agents, uses what your repo already has, and tells you what it did.

  1. Installs Prune with your package manager
  2. Baselines existing debt so nobody is blocked
  3. Hooks prune check into the hook system you already use
  4. Connects the MCP server to your client
  5. Leaves notes for the next agent, then reports back
files your agent touches
  • Mpackage.jsondevDependency prunecode
  • A.prunercdefaults, generated code excluded
  • M.gitignoreignores the local index .prune/
  • A.prune-baseline.json37 existing findings accepted
  • M.husky/pre-commit+ npx prune check
  • A.mcp.jsonprune MCP server
  • MAGENTS.mdwhen to ask Prune
your agent

Prune is set up. The baseline holds 37 findings, so nothing blocks commits. Top tasks: delete 2 unused exports in format.ts, merge UserDTO into User, and break the auth ↔ session cycle. Want me to start?

Prefer to set it up by hand? See exactly what the agent adds.

pre-commit framework

The prune hook uses the binary on your PATH. prune-cargo builds from source instead.

Record existing debt once with prune baseline and commit .prune-baseline.json.

# .pre-commit-config.yaml
repos:
  - repo: https://github.com/dlabadini/prune
    rev: v0.2.0
    hooks:
      - id: prune
        args: [--fail-on, medium]

how it works

Prune marks. Your agent cuts. Prune checks the cut.

Prune never rewrites your code behind your back. It finds the dead wood, writes a precise task, and verifies the result, so an agent can clean up without guessing.

exports by reachability412 files · 1,356 exports
  1. usedreached from product code or a framework1,204
  2. test_onlyonly tests touch it38
  3. same_file_onlyexported, used only in its own file61
  4. unusednothing reachable uses it44
  5. unreachableits whole file is orphaned9 files

Entries found automatically: package.json exports and scripts, next.config routes, convex/ functions, configs, shebang scripts.

what it finds

Eight detectors, tuned against false positives.

Every finding comes with its locations, why it matters, a refactor plan, and an id that stays stable across unrelated edits. essential recommended emerging

src/lib/format.tsts
1import { parseISO } from "date-fns";
2
3export function formatDate(d: Date) {unused
4  return d.toLocaleDateString("en-US");
5}
6
7export function toISO(d: Date) {same_file_only
8  return d.toISOString();
9}
10
11export const stamp = () => toISO(new Date());used · api/log.ts

Fix: delete formatDate, drop export from toISO. prune fix can do both.

local-first

Your code never leaves the shed.

Prune is one Rust binary with no account and no telemetry. Everything from parsing to the index runs on your machine. A scan makes no network requests; the only download is the optional embedding model, once, if you turn it on.

  • Knows your frameworks. Next.js routes and Convex functions count as entry points, so nothing they load is reported dead.
  • Respects boundaries. Fence a package and it may keep its own copies of types on purpose.
  • Measured, not guessed. Labeled fixtures check every detector for precision and recall in CI.

faq

Questions, answered.

What is Prune?

Prune is a free, open-source structural linter for TypeScript and JavaScript. It reads your whole module graph to find what coding agents tend to leave behind: dead exports, unreachable files, duplicate types, god files, import cycles and near-duplicate functions. It then turns those findings into tasks an agent can work through and verify.

Do I need to configure anything?

Usually not. Ask your coding agent to follow https://prunecode.ai/setup and it handles the install, the baseline, the pre-commit hook and the MCP connection, using whatever your repo already has. Defaults work without a .prunerc. You only touch config to exclude generated code or tune thresholds.

Is Prune free?

Yes. Prune is MIT licensed and free for any use, including commercial. There is no account, no license key and no paid tier.

Does my code leave my machine?

No. Prune is a single binary that parses, indexes and analyzes your code locally. A scan makes no network calls. The optional semantic matching uses a small embedding model that runs locally and is only downloaded when you enable it.

Which languages and frameworks does Prune support?

TypeScript and JavaScript (.ts, .tsx, .js, .jsx, .mts, .mjs, .cts, .cjs). Entry points are discovered from package.json, tool configs, scripts and shebang files, and there are built-in adapters for Next.js routes and Convex functions.

How is Prune different from ESLint or an unused-exports tool?

ESLint and tsc check code file by file. Unused-export tools report what nothing imports. Prune classifies every export by how far it is from used (used, test_only, same_file_only, unused, unreachable). It also finds duplicate shapes, god files and import cycles, and it hands each finding to your agent as a task with a verify command.

How do I use Prune with Claude Code, Cursor or another agent?

Tell your agent: "Set up Prune in this repo by following https://prunecode.ai/setup." The setup page is written for agents. It installs Prune with your package manager, adds the pre-commit check, and connects the MCP server (for Claude Code: claude mcp add prune -- npx prune mcp). After that, the agent can call tasks, verify, who_uses, safe_to_delete and rename_impact on its own.

Will Prune block commits because of existing debt?

Not if you record a baseline. Run prune baseline once and commit .prune-baseline.json. After that, prune check in pre-commit and prune scan --baseline --ci fail only on findings that are new.

Can Prune fix problems automatically?

Only the mechanical ones: dropping export from symbols that only their own file uses, and deleting unreachable files. prune fix --apply --check "<your typecheck>" applies each fix, runs your check, and reverts the fix if the check fails. Everything else becomes a task for you or your agent.

open source

Plant it in your repo.

MIT licensed, free forever, built in the open. If Prune gets something wrong, open an issue with the smallest repro you can. That's how the detectors get sharper.

Star on GitHub Read the docs