GMaN1911/claude-cognitive
Working memory for Claude Code - persistent context and multi-instance coordination
What it solves
Claude Code is powerful but stateless — every new instance starts from scratch, re-reads unchanged files, wastes tokens, and may hallucinate missing integrations. This project gives Claude Code a persistent working memory, so sessions resume productively, avoid duplicate work, and stay aligned across long-running or parallel use.
How it works
Two complementary systems:
- Context Router — scores documentation files by how often they are mentioned. HOT files (score > 0.8) get full content injected, WARM files (0.25–0.8) get only the first 25 lines, and COLD files (< 0.25) are evicted. Scores decay over turns, rise on keyword matches, and boost related files through co-activation.
- Pool Coordinator — shares state across multiple Claude instances. In automatic mode it detects task completions or blockers from conversation every 5 minutes; in manual mode you write explicit
poolblocks. This keeps parallel or long-lived sessions in sync.
History tracking (v1.1+) logs every turn’s attention state (HOT/WARM/COLD transitions) to a JSONL file, with a CLI to query, filter, and get statistics. Setup involves copying scripts, setting an instance ID, and configuring a project-specific keywords.json.
Who it’s for
Developers using Claude Code on large codebases (50k+ lines) who need persistent context across sessions, teams running multiple Claude instances concurrently, and anyone managing multi-day or long-running coding workflows.
Highlights
- Token savings: cold start down 79% (120K → 25K chars), warm context 70%, focused work 75%.
- New instances are productive on the first message; no hallucinated imports or integrations.
- Works across 8+ concurrent Claude instances and multi-day sessions.
- Validated on a 1M+ line production codebase with 3,200+ Python modules.
- Both automatic and manual pool coordination modes.
- Attention history viewer with filtering and statistics.
- MIT licensed and marked production-ready.
Related
- Project
- Project
- Project
- Project