Goal: Working memory for Claude Code in 15 minutes.
cd ~
git clone https://github.com/GMaN1911/claude-cognitive.git .claude-cognitive# Copy scripts to ~/.claude/
cp -r .claude-cognitive/scripts ~/.claude/scripts/
# Set up hooks
cat .claude-cognitive/hooks-config.json >> ~/.claude/settings.json# Add to ~/.bashrc for persistence:
export CLAUDE_INSTANCE=A
# Or per-terminal:
export CLAUDE_INSTANCE=Bcd /path/to/your/project
# Create .claude directory
mkdir -p .claude/{systems,modules,integrations,pool}
# Copy templates
cp ~/.claude-cognitive/templates/* .claude/Edit .claude/CLAUDE.md:
# Your Project Name
> Brief description
## Quick Reference
| Component | Description |
|-----------|-------------|
| ... | ... |Edit .claude/systems/*.md:
- Create docs for your infrastructure/deployment nodes
- See templates/systems/ for examples
Edit .claude/modules/*.md:
- Create docs for your core systems/modules
- See templates/modules/ for examples
Create keywords config:
# Copy template
cp ~/.claude-cognitive/templates/keywords.json.example .claude/keywords.json
# Edit with your project's keywords
nano .claude/keywords.jsonSee CUSTOMIZATION.md for detailed guidance.
# Start Claude Code
claude
# First message - check for context injection:
# Should see: "ATTENTION STATE [Turn 1]" with HOT/WARM/COLD counts
# Query pool activity:
python3 ~/.claude/scripts/pool-query.py --since 1hWhen you type a prompt:
- Hook intercepts your message
- Context router analyzes keywords
- Relevant docs injected automatically
- Files fade when not mentioned
- Token budget enforced (25KB max)
Result: You see relevant documentation without asking for it.
When you end a session:
- If you added a
poolblock, it's extracted - Coordination entry written to shared log
- Other instances see it at their session start
Result: No duplicate work across terminals.
export CLAUDE_INSTANCE=A
claudeWork on something:
user: "Fix the authentication bug"
assistant: [works on fix]
assistant: "Fixed! Added mutex locking to prevent race condition.
```pool
INSTANCE: A
ACTION: completed
TOPIC: Auth bug fix
SUMMARY: Fixed race condition in token refresh. Added mutex locking.
AFFECTS: auth.py, session_handler.py
BLOCKS: Session management refactor can proceed
All tests passing."
End session (Ctrl+D).
### Terminal 2 (Instance B)
```bash
export CLAUDE_INSTANCE=B
claude
Session starts, you see:
## Session Context
- **Instance**: B
- **Pool**: 1 recent (0 own, 1 others)
### Recent Activity
- [A] completed: Auth bug fix
Now Instance B knows what A did!
You type: "How does the API work?"
Context router:
- Sees keyword "api"
- Activates
modules/api.md→ HOT (full content) - Co-activates related files → WARM (headers only)
- Injects before your prompt
Claude sees:
━━━ [🔥 HOT] modules/api.md (score: 1.00) ━━━
[Full API documentation - 10KB]
━━━ [🌡️ WARM] modules/auth.md (score: 0.35) ━━━
[Header only - 500 bytes]
> APIs use this auth system
> Quick health: curl /api/health
━━━ [🌡️ WARM] modules/database.md (score: 0.35) ━━━
[Header only - 500 bytes]
> APIs query this database
> Connection string: postgres://...
[Your prompt]: "How does the API work?"
Result: Claude has full API docs + awareness of related systems, all automatically.
Files fade when not mentioned:
Turn 1: "How does the API work?"
→ api.md: HOT (full content)
→ auth.md: WARM (header)
Turn 2: "What database does it use?"
→ database.md: HOT (newly activated)
→ api.md: WARM (decayed from 1.0 → 0.70)
→ auth.md: WARM (still visible)
Turn 5: "Back to the API"
→ api.md: HOT again (1.0)
→ database.md: WARM (decayed)
→ auth.md: COLD (evicted after not mentioned)
Think of it as:
- Your working memory focuses on current topic
- Related systems stay in background (WARM)
- Irrelevant systems fade away (COLD)
- Mention something → instantly returns
See Attention Decay for details.
Check:
# 1. Verify hooks configured
jq '.hooks.UserPromptSubmit' ~/.claude/settings.json
# 2. Test router manually
echo '{"prompt": "test"}' | python3 ~/.claude/scripts/context-router-v2.py
# 3. Check docs exist
ls .claude/systems/
ls .claude/modules/
# 4. Restart Claude CodeCheck:
# 1. Verify CLAUDE_INSTANCE set
echo $CLAUDE_INSTANCE
# 2. Check pool file exists
ls -lh ~/.claude/pool/instance_state.jsonl
# 3. Test manually
python3 ~/.claude/scripts/pool-query.pyCustomize keywords:
# Edit your keywords config
nano .claude/keywords.json
# Add project-specific terms to the "keywords" sectionSee CUSTOMIZATION.md for guidance.
Look for the visual header:
╔══ ATTENTION STATE [Turn 5] ══╗
║ 🔥 Hot: 2 │ 🌡️ Warm: 6 │ ❄️ Cold: 5 ║
╚══════════════════════════════════════╝
Each file shows its tier:
[🔥 HOT]= Full content[🌡️ WARM]= Header only- (Not shown) = COLD (evicted)
- Attention Decay - Why files fade
- Context Tiers - HOT/WARM/COLD explained
- Pool Coordination - Multi-instance patterns
- Read CUSTOMIZATION.md
- Map your systems to
.claude/systems/*.md - Map your modules to
.claude/modules/*.md - Create
.claude/keywords.jsonwith your project's keywords - Test with real work
- Large Codebases - 50k+ lines strategies
- Team Setup - Multiple developers
- Migration Guide - Adding to existing project
# Context router errors
cat ~/.claude/context_injection.log
# Pool loader errors
cat ~/.claude/pool/loader_errors.log
# Pool extractor errors
cat ~/.claude/pool/extractor_errors.log# Clear attention state (fresh start)
rm .claude/attn_state.json
# Clear pool (fresh coordination state)
rm ~/.claude/pool/instance_state.jsonl
# Restart Claude Code- GitHub Issues: https://github.com/GMaN1911/claude-cognitive/issues
- Discussions: https://github.com/GMaN1911/claude-cognitive/discussions
- Check existing docs: Everything in
docs/directory
You now have:
- ✅ Context router with attention dynamics
- ✅ Pool coordinator for multi-instance work
- ✅ Project-local documentation structure
- ✅ Working memory across sessions
What changes:
- Claude sees relevant docs automatically
- Files fade when not mentioned (working memory)
- Other instances coordinate via pool
- Token usage drops 64-95%
What stays the same:
- Claude Code works normally
- No new commands to learn
- Graceful degradation if hooks fail
- Optional (use pool blocks only when needed)
Ready to dive deeper? See Concepts for how it all works.
Want to customize? See CUSTOMIZATION.md for keyword mapping.
Working on large codebase? See Large Codebases Guide.