Dead-Code & Test-Gap Auditing: Traditional Tools vs Memoreal MCP
| Feature / Capability | ts-prune / ts-remove (TypeScript only) | vulture (Python only) | Memoreal MCP (dead_code & test_gaps) |
|---|---|---|---|
| Polyglot Monorepo Support | TypeScript only | Python only | TypeScript, Python, Rust, Go & 15+ languages in one pass |
| Agent Tool Integration | CLI output requires parsing | CLI output requires parsing | Native MCP JSON-RPC tool for Claude Code & Cursor |
| Test-Gap Correlation | None | None | Directly cross-references test files and computes coverage ratio |
| Entrypoint Awareness | Requires manual config regex | Requires whitelist files | Accepts dynamic entrypoints parameter per audit run |
The Hidden Toll of Orphaned Code and Untested Modules
As software repositories evolve, deprecated helper functions, obsolete types, and orphaned internal endpoints accumulate across codebase directories. In large polyglot applications, engineering teams rarely dedicate sprints to manual code pruning because tracing every export manually across thousands of files is exhausting.
Compounding this technical debt, new features are frequently deployed without adequate unit or integration test coverage. When AI coding agents refactor these modules, the lack of test coverage prevents automated validation, turning minor updates into high-risk engineering operations.
- Orphaned code bloats repository size, slows build times, and confuses human and AI contributors.
- Language-specific dead-code CLI tools do not scale across polyglot microservice architectures.
- Missing test references prevent AI agents from verifying refactored functionality automatically.
How dead_code Identifies Zero-Caller Symbols
Memoreal evaluates dead code through comprehensive AST call-graph reachability. When the dead_code tool is called, the engine traverses symbol reference graphs starting from designated entrypoints (such as server bootstrap files or worker entrypoints).
Any symbol that has zero incoming callers outside its own file definition is flagged as an orphan candidate. The tool returns the symbol name, declaration file, line range, and symbol kind (function, class, interface, or constant), giving developers and AI agents clear targets for safe removal.
Uncovering Testing Blind Spots with test_gaps
Complementing dead-code analysis, the test_gaps tool scans workspace source files and cross-references them against test directory conventions and symbol test links. It identifies source files that lack corresponding test suites, as well as individual public functions that have zero test callers.
By running test_gaps during sprint audits or agent-driven QA workflows, teams can automatically prompt AI assistants to generate targeted unit test suites for untested business logic, systematically driving up codebase test coverage.
Auditing Orphaned Symbols and Untested Files via MCP
json{
"jsonrpc": "2.0",
"id": 5,
"method": "tools/call",
"params": {
"name": "dead_code",
"arguments": {
"namespace": "core-backend",
"entrypoints": ["src/index.ts", "src/workers/queue.ts"]
}
}
}
Frequently Asked Questions
Can I exclude legitimate API entrypoints or public exports from dead_code?
Yes. You can pass an optional entrypoints array specifying routes, handlers, or public library exports that should be excluded from pruning.
Does test_gaps run my actual unit tests to measure line coverage?
No. test_gaps performs fast AST structural analysis to determine which files and functions lack test references, completing in under 15ms without running test runners.
Can Claude Code run dead_code and automatically delete orphaned files?
Yes. You can prompt Claude Code to inspect dead_code output, verify zero callers via find_references, and safely remove obsolete functions.
Install Persistent Memory for Your Coding Agent
Sub-15ms deterministic recall, AST symbol navigation, and 70%+ token savings across Claude Code, Cursor, Codex CLI, and Windsurf.
npx -y @kolivri/memoreal-mcp setup