Skip to main content
Glama

CodeEraser

ci crates.io npm license site HOL Guard · English | 中文

CodeEraser keeps an agent-written repo small and clean: a write that duplicates code or bloats a file is refused before it lands.

The write-time guard refusing a write: an agent asks to create a new file, and CodeEraser answers with the indexed region that content already duplicates and the ordering that would pass instead

What it does

LLM-assisted codebases drift the same way: the same function written twice, the same paragraph pasted into three files, files that only grow. CodeEraser refuses the write that would do that, before it reaches disk, with no model in the loop.

  • A write that copies code already in the tree is refused, and the refusal names the region it duplicates.

  • A write that grows a file past 750 lines is refused the same way (a write that does not lengthen a file already past the line passes, so the file can be split step by step).

  • Everything else is a report or a gate: CI refuses the merge, and under [guard] mode = "deny" the Stop audit refuses the turn and ce precommit the commit (by default both record and do not refuse).

Judges Python, TypeScript/TSX, Rust, Go, Haskell, C, C++, Java, Lua, R, Markdown and HTML (thirteen language codes, twelve tree-sitter grammars); JS, CSS, Vue, Svelte, shell and YAML files for size only; .txt for documentation duplication only.

Runs as CLI · GUI (eleven screens) · Claude Code plugin (four hooks, one skill, one command, twenty-one read-only MCP tools) · pre-commit · CI.

Related MCP server: codedelta

The effect: the same task, run twice

Without CodeEraser

With CodeEraser

writes refused before they reached disk

0

2

duplicate clone blocks left behind

4

0

duplicated doc segments

1

0

removals still owed

1

0

check score

752

1000

One seven-step task, two identical copies of the seed; the only variable is whether CodeEraser is in the loop — the write-time guard, the Stop audit, and, once the audit refuses, the eraser acting on its own plan. Both runs still end red — not on the same things.

A scripted agent replays one seven-step task (discounts, a compact report, CSV and JSON output, money formatting) on demo/seed, a small invoicing service, once without CodeEraser and once with it. Every number above and every refusal below is ce's verbatim output.

With CodeEraser: two writes are denied at PreToolUse with the duplicated region named, the Stop audit then refuses to end the turn over the two blocks that slipped past, the repair it asks for lands, and the erase plan removes the verbatim doc twin

A copied helper, refused before the file exists. Move 1 of the run above, on its own. The reason names the region the content duplicates and the ordering that would pass, so the refusal is actionable rather than a veto.

$ Write invoicer/discount.py
✗ ce: content for <work>/invoicer/discount.py duplicates 1 indexed region(s): invoicer/money.py:6-18 (80 tokens). Reuse the existing implementation instead of re-writing it. Moving it? Trim the source region first: the probe verifies against the current tree, and the same write then passes.

One line, two mouths. ce.toml puts invoicer/** on file_lines_fail = 40. The write-time guard refuses the write that would cross it, and ce scan grades the same tree against the same number — one declaration, read by the hook and by CI.

$ Write invoicer/invoice.py
✗ ce: <work>/invoicer/invoice.py is already past the hard budget of 40 at 51 lines; this write grows it to 93 (plan §4.1). A write that keeps or shrinks it passes: split it step by step.
$ ce scan .
FAIL invoicer/invoice.py:1 file-lines = 51 (limit 40) [invoicer/invoice.py]
warn invoicer/report.py:1 file-lines = 35 (limit 30) [invoicer/report.py]
scanned 9 files / 19 functions — 1 warn, 1 fail -> FAIL (failed: hard_line)

The full table, both transcripts and the JSON behind them are in demo/README.md, replayed byte for byte in CI; the first real interception is recorded in T1-INTERCEPT. The precision and recall points are frozen with their evaluation ledgers (EVAL-SET, EVAL-SET-LANGS).

How it works

How a verdict is made: Rust measures syntax units, token fingerprints and each unit's bag facts, documentation shingles, git windows and diffs, and the reference graph; Haskell judges structure and score, clones and same-role advice, documentation duplication, change verdicts (trajectory, audit, tombstone residue), liveness and erase, and flow, merge and architecture, one to three wire families per row; the gate and the per-family reports deliver the verdicts

Zoom and pan this diagram at codeeraser.dev/how/#verdict.

  • Write-time clone guard: normalized tokens winnowed at k = 25, w = 26, so any shared run of 50+ tokens is caught; import and load statements (the package clause and a Haskell module header among them) and a Python docstring that holds no code give no token, and a report keeps a run only with 50 tokens of its own (the core's coverage rule); only novel duplication is charged (FPR-REPLAY).

  • Near-miss (T3) clones: candidates from MinHash/LSH, judged in the core by tree edit distance at TSED ≥ 0.85.

  • Documentation duplication that survives rewording: 5-word shingles, Jaccard ≥ 0.80 or a 50-word verbatim run.

  • Liveness: per-language resolution ladders feed a reference graph; a four-way verdict comes back with a confidence code, and each unreferenced file is listed under the root it falls with.

  • Gate score: 0–1000, the share of the tree's lines no finding names (seven axes name lines: size, complexity, clone, docdup, unreferenced, churn, cycles; six count by default, the unreferenced axis only when [score.weights] deadcode names it), held by the ADR-006 shrink-only ratchet (growth needs max(+2 %, +10 lines) or a named re-establish).

  • Deterministic: no model anywhere; text crosses only the local ce → ce-core pipe, and the core opens no file.

The rest — same-role advice, Datalog queries and rules, intra-function dead code, merge suggestions, architecture, structure axes, tombstone residue, erase — is on codeeraser.dev/how and in the methodology booklets.

Install, run, update

  • Installer. Each release ships five GUI installers (NSIS / AppImage / dmg) bundling the GUI, ce and the ce-core judgment core; the Windows installer runs ce setup (AppImage / dmg users run it once), which wires Claude Code. The fifteen artifacts are unsigned by decision; verify with sha256sum -c --ignore-missing SHA256SUMS.

  • Homebrew / winget. brew install skymanbp/codeeraser/codeeraser; winget install skymanbp.CodeEraser once winget-pkgs merges.

  • Claude Code plugin. /plugin marketplace add skymanbp/CodeEraser@release, then /plugin install codeeraser@codeeraser.

  • CLI only, or from source. Put ce and ce-core side by side on PATH; cargo install codeeraser builds ce only, so take ce-core from a release or build it with GHC 9.14.1 + cabal; ce finds the core as CE_CORE_BIN → a ce-core sibling → PATH, and --core <path> wins.

  • Updating. ce update checks the latest release against its two-phase pins and --yes replaces the binaries (RELEASE).

Commands

Command

What it reports / judges

ce scan / ce dedup

size and complexity metrics; T1/T2 clone blocks against the budget

ce clone / ce docdup

T3 near-miss clones; documentation duplication

ce graph / ce deadcode

reference sites and mentions; liveness verdicts

ce churn / ce join / ce trend

git-window churn; the three-signal join; score trajectory

ce similar

same-role units, ranked by the core; advice only

ce query / ce rules

Datalog over the index's facts; rules judged as a gate

ce flow

dead code inside functions, from the control-flow graph

ce merge

how a clone group would fold into one function; advice only

ce arch

directory layers, cycle cuts, clusters, change impact; advice only

ce structure

eight structure axes and split pricing

ce check / ce baseline

the ratchet and score floor, seven named fail conditions

ce erase

the deterministic two-phase eraser; dry run by default

ce update

latest release vs this build; --yes installs it

ce doctor / ce setup / ce eject / ce mcp

machine state; Claude Code wiring; uninstall; the MCP server

Output is English by default and Chinese under --lang zh, CE_LANG=zh or [ui] lang = "zh". [[rules.class]] in ce.toml gives one glob set its own lines and ratchet tolerance (ce.toml reference).

Three faces, one product

Every capability reaches the CLI, the GUI and the plugin with its MCP server, or is a named omission; the face_parity gate derives the sets from the code.

capability

report document (core catalogue)

CLI

GUI (screen · commands)

plugin (hooks · MCP · commands · skills)

size / complexity / readability metrics

scan

ce scan

reports, scan_report

MCP scan

T1/T2 clone blocks

dedup

ce dedup

reports, candidates, dedup_report

MCP check_duplication

T3 near-miss clones

clone

ce clone

reports, clone_report

MCP clone

the unit universe T3 judges

clone-units

ce clone --units

reports, clone_report

MCP clone

documentation duplication

docdup

ce docdup

reports, docdup_report

MCP docdup

reference sites

sites

ce graph --sites

reports, sites_report

MCP graph_sites

the mention universe

mentions

ce graph --mentions

— CLI only: the census behind the symbol advisory, which every face of deadcode carries

— CLI only: the MCP deadcode tool carries the advisory the census feeds

liveness verdicts + symbol advisory

deadcode

ce deadcode

reports, deadcode_report

MCP deadcode

graph screen (canvas + liveness)

graphscreen

— GUI only: the canvas is a picture; the same judgment's CLI and MCP faces are deadcode

graph, graphscreen_report

— GUI only: the MCP face of the same judgment is deadcode

git-window churn

churn

ce churn

reports, churn_report

MCP churn

three-signal join

join

ce join

candidates, join_report

MCP join

tree-scale structure (split pricing)

structure

ce structure

structure, structure_report

MCP structure

score trajectory

trend

ce trend

trend, trend_report

MCP trend

score, ratchet and floor

check

ce check

score, check_report

MCP check

same-role advisor (similar units, associative view)

similar

ce similar

similar, similar_report

MCP similar_units

code query and architecture rules

query, rules

ce query, ce query --prelude, ce rules

query, query_report, query_prelude, rules_report

MCP query, MCP rules

intra-function dead code (unreachable, dead stores, unused locals and parameters)

flow

ce flow, ce flow --check

reports, flow_report, flow_kinds

MCP flow

clone merge suggestions (anti-unification)

merge

ce merge

reports, merge_report

MCP merge_suggestions

architecture analysis (layers, cuts, clusters, impact)

arch

ce arch

reports, arch_report

MCP architecture

baseline writes

—

ce baseline

— CLI only: a machine surface never writes a baseline

—

erase plan

erase

ce erase

erase, erase_preview

MCP erase, skill erase

erase apply

—

ce erase --apply

erase, erase_apply

— no MCP face: applying is a human act

erase audit log

erase-trail

ce erase --log

erase, erase_log_report

MCP erase_log

machine state and guard-class tiers

—

ce doctor

doctor, doctor_report

MCP doctor

update check

—

ce update

update, update_check

MCP update_check, /codeeraser:update, hook SessionStart

update apply

—

ce update --yes

update, update_apply

— the plugin's copy is re-pinned by /plugin update codeeraser

write-time guard

—

ce probe --hook (guard · flow · tombstone)

— hooks are the plugin's face; flow and tombstone judge the write inside the hook, so no report family of their own — their tiers ride every face's doctor

hook PreToolUse

asked-write settlement

—

ce settle --hook

— hooks are the plugin's face

hook PostToolUse

stop audit / git hooks

—

ce audit --hook (guard · flow · tombstone), ce precommit (guard · flow · tombstone), ce commitmsg (guard · flow · tombstone)

— hooks are the plugin's face; precommit and commitmsg are git's; tombstone judges the changeset inside them, its tier on every face's doctor

hook Stop

session health line

—

ce health --hook

— hooks are the plugin's face

hook SessionStart

project daemon

—

ce daemon, ce ping

— started lazily by every face

—

read-only report server

—

ce mcp

— the plugin registers it

.mcp.json

uninstall

—

ce eject

— CLI only

—

Claude Code wiring

—

ce setup, ce setup --unwire

— CLI only: the Windows installer calls it, AppImage / dmg users run it once

—

root anchoring

—

— every command and hook anchors through root

default_root, resolve_root

—

Tech stack and philosophy

Architecture: the repository is parsed and fingerprinted by the Rust measurement side (tree-sitter, the SQLite fingerprint index kept warm by a per-project daemon, the reference graph, git windows), crosses one NDJSON wire of sixteen families to the Haskell judgment core with its policy shipped as data, and the same reports are rendered by five faces: terminal, GUI, MCP server, Claude Code hooks, CI

Zoom and pan this diagram at codeeraser.dev/#architecture.

  • Rust 1.94.1 (edition 2024): tree-sitter 0.27 with twelve grammars, rusqlite 0.40 (index schema 17 / GRAPH_REV 28 / MENTION_REV 4), a per-project daemon.

  • Haskell (GHC 9.14.1): ce-core, every judgment family. Tauri 2: the GUI over the same crate.

  • One wire: NDJSON over stdio (proto 10.0.0, sixteen families); the daemon speaks its own protocol (2.4.0).

  • Design rules: ADR-001 … ADR-009 (Rust frontend, parse layer in Rust, lazy daemon, cheap PreToolUse, two clone layers, shrink-only ratchet, pinned distribution, policy as Haskell data, derived documentation facts) in DEVELOPMENT_PLAN.

  • Philosophy. Measure in Rust, decide and write in Haskell, print everywhere else. Nothing asks a model anything; hooks fail open and say so; documentation is generated or gated, including the nineteen-booklet methodology, and every push runs the seven product gates on this tree.

Known limits

PreToolUse shapes behaviour; it is not a security wall (shell writes bypass it; CI is the backstop, and the Stop audit too under [guard] mode = "deny"). The probe matches a write against the index as it stands and does not refresh it: a file created or changed outside Write/Edit (a shell command, an editor, git) becomes a duplicate source at the next whole run (ce dedup, the Stop audit). Hooks fail open on internal errors and on a hook envelope over 4 MiB (the largest writes pass unjudged), and record the degradation.

  • Languages. AST judgment uses the twelve grammars above; Markdown and HTML are judged by the documentation and graph rules, .txt by documentation duplication only; T4 clones are not promised.

  • Advice, never a verdict. Symbol-level liveness, ce similar, ce merge and ce arch never fail a gate; a guard class stays observe until it has its own false-positive record.

  • Lines, not findings. The score counts the lines some finding names, each line once however many findings name it: one long duplicated file weighs more than many short ones, and a second finding on lines already named does not lower it further. With the unreferenced axis off (the default), an unreferenced file is an ordinary clean file: deleting one shrinks L and can lower the score; [score.weights] deadcode = 1 counts its lines as findings again.

  • A span is first token to last. A clone block's printed span runs from its first token's line to its last, so it can name the comment, docstring and import lines between them, which carry no token (a head declaration never starts or ends a span); the score counts those lines like any other line the block names.

  • Lines not drawn. cognitive_fail defaults to 0 (complexity only warns), and ce structure has no score floor.

  • What the text names. Liveness reads the references a file spells. A load whose target is computed (require(prefix .. name), import("./lib/" + name)) or a star import whose __all__ is not all literal draws no edge for what it does not spell: the file stays unreferenced and its language cannot vouch for it. Unreferenced is not unused, so the default lists such a file and fails nothing; a project that wants new ones blocked declares [deadcode] block and commits a baseline. Nor is it a deletion licence: a file nothing references may still be run by name or found by a tool's convention (the eight conventions the dead-file exam passed, among them setup.py, Sphinx's conf.py, package-info.java and a Next.js app/ page, are entries; a convention the product does not list is not), so ce erase deletes no whole file and erases only byte-identical documentation spans. Entry points declared in setup.cfg or a non-root pyproject.toml are not read, and booklet 06 lists the other reference forms and entry families the graph does not read (a file reached only by include!, a script run by its path, a worker loaded by new URL(...), among others), each with its remedy: [graph] entry_globs, or ce:allow(deadcode) -- <why> in the file.

  • Distribution. A release builds five targets; ce setup wires nothing from an elevated account that is not the logged-in user (exit 13); judging this repository needs the cli/tests submodule seated.

  • One wire line. A request line to the core is at most 134,217,728 bytes; larger requests split into batches, and an oversized item is refused by name, never truncated.

Scores are not comparable across a [[rules.class]] switch, across a named re-establish that moves softLine, or across these releases: v0.7.3 → v1.0.0, v1.2.0 → v1.3.0, v1.3.x → v1.4.0, v1.6.0 → v1.7.0, v1.7.4 → v1.8.0, v1.8.0 → v1.9.0 (1.9.1 and 1.9.2 are comparable with 1.9.0), v1.9.x → v1.10.0 (the score became the share of lines no finding names, and the unreferenced axis weighs 0 unless named; 1.10.1 is comparable with 1.10.0), v1.10.1 → v1.10.2 (Python docstrings give no clone token and are read past a leading comment; a docstring or a comment block, in any language, keeps the prose under a tilde title underline; 1.10.3 is comparable with 1.10.2); the reasons are in CHANGELOG.

Documentation

License

Apache-2.0; see LICENSE. Third-party inventory in NOTICE (regenerated and gated in CI). The test suite lives in skymanbp/CodeEraser-tests; clone with --recurse-submodules. "CodeEraser"™ is a trademark of skymanbp; per Apache-2.0 §6 the license covers the code, not the name.

Available Tools

21 tools
architectureB

The architecture of the tree (ce.arch-report schema): directory layers and the arcs to cut out of their cycles (each with the file references behind it), file clusters and the files outside their cluster's directory, per-directory fan-in / fan-out / instability, and the files a change to impact reaches. Advisory.

Inputs: path, impact.

checkC

ADR-006 baseline judgment: score, ratchet and axes (report only — this surface never writes a baseline).

Inputs: days, path, floor.

check_duplicationC

Verified T1/T2 clone blocks (ce.dedup-report schema).

Inputs: path, min_tokens, min_distinct.

churnC

Append-vs-rewrite and co-change over a git window (ce.churn-report schema).

Inputs: days, path.

cloneC

T3 near-miss clone judgment (ce.clone-report schema); units lists the cached unit universe instead.

Inputs: path, units.

deadcodeC

Liveness verdicts over the reference graph, plus the symbol-level advisory of declarations no other file spells — never a verdict (ce.deadcode-report schema).

Inputs: path.

docdupC

Documentation-duplication judgment (ce.docdup-report schema).

Inputs: path.

doctorB

This machine's state (ce.doctor-report schema): ce-core handshake, the tier of every guard class the hooks read (the write guard, flow, tombstone), index freshness, daemon, degraded-run counter. The daemon is asked without being started.

Inputs: path.

eraseA

The deterministic erase PLAN (ce.erase-plan schema) — dry-run by construction: this surface reaches the plan and nothing else, and applying it is a human act at the CLI or the GUI.

Inputs: path.

erase_logA

The applied-erase audit trail (ce.erase-trail-report schema): every record ce erase --apply or the GUI appended to .ce/erase-log.ndjson, with the lines the reader could not parse named by number. Read-only — nothing here can apply or append.

Inputs: path.

flowB

Dead code inside functions (ce.flow-report schema): unreachable statements, dead stores, unused locals and parameters, judged by the core over flow/1 and placed by path, unit, kind, lines and variable; each finding says whether it is judged or advisory (unused parameters always are). Report-only.

Inputs: kind, path.

graph_sitesC

Reference sites, resolution-free (the ce graph --sites rows).

Inputs: path.

joinC

Three-signal join: similarity, graph position, churn (ce.join-report schema).

Inputs: days, path.

merge_suggestionsB

Clone-merge suggestions (ce.merge-report schema): every clone group — T1/T2 families, T3 pairs — anti-unified by the core's merge/1: the parameters a merged function takes with each member's text at them, the member kept, the lines saved, feasible or why not. Advisory.

Inputs: path.

queryB

One question in CE Datalog over the index's facts (ce.query-report schema): files, references, units, clones, mentions, path classes, with the built-in prelude (dead, reach, depends, same_dir, dir_ref) and the project's rules file; every answer labelled, its derivation under why; prelude answers the text a question builds on instead (ce.query-prelude schema: the prelude and the [rules.pack] program). Report-only.

Inputs: why, body, file, path, +1 more.

rulesB

The project's architecture rules judged (ce.rules-report schema): every assert in the rules file with its violations, each carrying its witness and derivation. The CLI exits on counts.violations; here it is a report.

Inputs: why, file, path.

scanC

Size/complexity/readability metrics report (ce.scan-report schema).

Inputs: path.

similar_unitsC

The same-role advisor (ce.similar-report schema): the units most like one unit or a text, in the core's order with its role bit and a six-channel evidence row; widen adds the PPMI associative view. Advisory — never a verdict.

Inputs: at, path, text, unit, +1 more.

structureC

Tree-scale structure judgment, eight axes (ce.structure-report schema).

Inputs: days, deep, path, split.

trendB

Score trajectory over mainline git history (ce.trend-report schema; points cache in the index, rebuildable from history).

Inputs: path, batch, commits.

update_checkA

Whether a newer CodeEraser release exists (ce.update-report schema): the latest tag, that tag's committed SHA256 pins, and the one action for this install. Reads the release index over the network; places nothing — applying is a human act at the CLI or the GUI.

Inputs: path.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3/5.0

    Scored across 21 tools

    Disambiguation3/5

    The set clusters into overlapping families: clone/check_duplication/docdup/join/merge_suggestions all concern duplication, and deadcode/flow/graph_sites all concern liveness, while scan/structure/architecture/trend/check all emit report-style metrics. The dense descriptions do differentiate them (T1/T2 vs T3, liveness verdicts vs in-function flow), but an agent could easily misselect within these families.

    Naming Consistency4/5

    Names are uniformly lowercase, using snake_case for compounds (check_duplication, graph_sites, erase_log, merge_suggestions) and single words elsewhere (scan, erase, churn, flow, query). No camelCase or mixed verb styles, though the single-word vs compound mix means the pattern is readable rather than strictly uniform.

    Tool Count4/5

    21 tools is at the heavy end but the domain (multi-faceted static analysis: duplication, dead code, structure, rules, query, diagnostics, updates) genuinely spans that many distinct reports. Each tool appears to earn its place rather than being redundant filler.

    Completeness4/5

    The surface covers the full analysis lifecycle: scanning, dedup, dead code, flow, structure, architecture, rules, Datalog query, trend, doctor, update_check, and erase audit. Applying an erase is deliberately a human act, and query/prelude fill the ad-hoc retrieval gap, so only minor workflow conveniences seem absent.

    Maintenance

    ActivityActive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Live codebase intelligence for AI agents. Import graph PageRank for file importance, git forensics for co-change coupling and fragile code, convention detection across 16 domains, and blast radius analysis.
      39 npm
      3
      Business Source 1.1
    • A
      license
      A
      quality
      C
      maintenance
      Deterministic code-churn measurement and AI-agent detection from the CodeDelta engine: measure churn between two directories or git refs, scan for code that runs AI agents, and get AI-authorship pointers. Runs fully locally.
      3
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables AI coding assistants to scan a repository for code that cannot prove its usefulness, attribute it to AI-assisted or human commits, prove candidate deletions against the project's own tests, and pull a payoff report or run history, all without ever writing to the repository. The test command and any model judging stay under a person's control through environment configuration.
      1
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      Evidence-backed, read-only codebase diagnostics for coding agents: secrets, dependency, RLS, and source-impact audits with a verify loop and PR review verdicts. Never writes files or uses the network by default.
      7
      101 npm
      MIT