I built subagent-reuse after noticing that Claude Code subagents often re-read the same files and rebuild the same context from scratch.
It scans Claude’s local session storage, tracks which files each subagent has already read or modified, and routes new work to an existing agent when there’s enough overlap. It also warns when files have changed since that agent last saw them.
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?
Are you referring to per-chat context graphs?
Where each interaction updates a structured state (constraints, entities, dependencies), instead of relying on tools like Mem0/Supermemory that only persist raw memory.
I think this is a universal problem: after a break, you reopen a project and spend more time rebuilding context than actually coding. I’m thinking of a Cursor-style chat that acts as project memory, it can answer “what did I do last?” and “what changed since then?” using git/PR history, and also lets me drop quick ideas for Project A while I’m working on Project B, so it reminds me when I come back. Would you use something like this, or is there a simpler workflow that already solves it?