CodeEraser: A Deterministic Gate Against LLM-Induced Code Drift
CodeEraser is a deterministic, non-LLM tool that blocks duplicate code and stale docs in AI-assisted codebases at write time and in CI.
CodeEraser targets a specific failure mode of long-lived LLM-assisted codebases: functions reimplemented twice, paragraphs copy-pasted across files, and updates that only append rather than replace existing content. Rather than adding another model to review code, it runs entirely without an LLM, using tree-sitter parsing, winnowing-based fingerprinting, MinHash/LSH clustering, and exact tree-edit-distance comparisons to catch duplication deterministically.
The tool intercepts writes before they reach disk: an exact clone (T1/T2) not already present in the replaced content, or a file exceeding its configured line budget, is denied at PreToolUse. Everything else is enforced downstream — a Stop-hook audit, pre-commit hooks, and CI exit codes — covering near-duplicate code via Zhang–Shasha tree edit distance, reworded documentation duplication via Jaccard similarity on word shingles, and dead code via per-language reachability analysis. A ratcheting check score from 0 to 1000 prevents regressions from creeping back in, and every judgment is byte-for-byte reproducible, with no randomness or clock dependency.
In a controlled test — the same seven-step coding task run twice on identical seed code — the version without CodeEraser ended with four duplicate clone blocks, one duplicated doc segment, and a lower check score (871/1000), all silently accepted. With CodeEraser active, two writes were denied outright, one stale doc reference was erased automatically, and the check score reached 979/1000. For teams running long AI-assisted coding sessions, this kind of deterministic, non-LLM gate offers a way to catch entropy at write time instead of discovering it in a review months later.
This synthesis was produced from its source by AI; there is no human editor or manual review step. How we work