Quarry
A static analysis CLI that finds dead code and unsafe patterns in large TypeScript codebases without a full type check.
- Year
- 2026
- Role
- Design, implementation
- Status
- Shipped
- Stack
- Rust
- Tree-sitter
- CLI
- Links
- Source
Quarry answers one question quickly: what in this repository is no longer used? It parses TypeScript and JavaScript into a syntax tree with Tree-sitter, builds a module-level symbol graph, and reports exports, files, and dependencies that nothing reaches.
Why not just use tsc?
Type checking a million-line monorepo to find nine unused exports is a bad trade. Quarry trades precision for speed. It never resolves types, and it never executes the module graph — it reads imports, re-exports, and identifier references syntactically.
On a real 1.4M-line codebase the full scan takes about 2.8 seconds on a laptop, cold, with no cache. That is fast enough to run on every commit and to keep a report in the terminal while you work.
$ quarry scan ./src --ignore "**/*.test.ts"
unused exports (4)
src/lib/legacy/format.ts:12 formatLegacyDate
src/lib/http.ts:88 RetryPolicy
...
orphan files (2)
src/lib/legacy/format.ts
src/scripts/one-off-migration.ts
Approach
The scanner runs three passes:
- Parse every file in parallel with a bounded worker pool.
- Collect definitions and references into a compact index keyed by file and symbol.
- Walk from declared entry points and report anything unreachable.
The graph is deliberately shallow. A reference only counts if it appears in code that is itself reachable, so a dead file cannot keep another dead file alive. Entry points are configurable, which handles frameworks that import pages by convention rather than by name.
Result
Quarry removed roughly 12,000 lines of dead code from its first production codebase in an afternoon. It is not a type checker and does not try to be — it is the cheap first pass that makes the expensive tools necessary less often.