h1r1ms 2 hours ago
Blog post with full context: https://medium.com/@itsamruth/stop-burning-tokens-how-to-use...
I built this after noticing a painful pattern with Claude Code: every new subagent (planner, explorer, implementer, fixer) would re-read the same files from scratch — burning hundreds of tokens each time on files like src/auth/callback.ts.
subagent-reuse solves it by automatically scanning Claude's native session storage (~/.claude/projects/) and tracking exactly which files each subagent has already read and modified. It builds a SHA-256 Merkle tree per agent for fast lookup.
Before spawning a subagent, it runs route_task(task, files). - Strong file overlap → REUSE the existing agent - File changed since last read → staleness warning (only re-read what's needed) - No good match → CREATE_NEW + summaries of existing agents so Claude can decide
I kept routing purely structural (file overlap + directory + recency). No embeddings or word matching — the calling LLM is better at semantics anyway.
Install (one command):
npx subagent-reuse --setup
It adds the MCP and auto-approves permissions.This is part of a small stack I'm using to make Claude Code dramatically more efficient (routing + semantic search + memory).
Code is ~1000 lines of vanilla JS with 52 tests.
Would love feedback especially on the routing approach — is staying purely structural the right decision, or should I add something smarter when the task doesn't specify file paths?
Happy to answer any questions!