Native support for semantic search and memory rotation (demonstrated in 4-Layer Memory System)
Preflight Checklist
- [x] I have searched existing requests and this feature hasn't been requested yet
- [x] This is a single feature request (not multiple features)
Problem Statement
When working on multiple projects with Claude Code, developers face:
- Context loss between sessions - Each new session requires re-explaining project context (5-10 min overhead)
- Knowledge silos - Solutions discovered in one project aren't accessible in others
- Manual memory management - No automatic cleanup of outdated information
- Limited search - Keyword-only search, no semantic understanding
These issues become critical for complex, long-term projects where context accumulation is essential for productivity.
Proposed Solution
Add native support for:
- Semantic Search in Auto-Memory
- Vector-based search that understands meaning, not just keywords
- Cross-project memory queries
- Multilingual support
- Memory Rotation API
- Configurable TTL for memory entries (e.g., 24h/14d/permanent)
- Automatic archival of old memories
- Prevents memory bloat while preserving important information
- Memory Health Commands
- Built-in validation:
/memory health - Detect ghost links, orphaned files, corruption
- Suggest cleanup actions
- Cross-Project Memory
- Global memory shared across all projects
- Project-specific memory for local context
- Commands like
/recall --allto search everywhere
Example config:
{
"memory": {
"rotation": {
"hot": "24h",
"warm": "14d",
"cold": "permanent"
},
"semantic_search": {
"enabled": true,
"cross_project": true
}
}
}
Alternative Solutions
Current approach (community implementation):
I've built a working system that demonstrates these needs: 4-Layer Memory System
- Repository: https://github.com/mergelord/claude-4layer-memory
- License: MIT (open source)
Architecture:
- Layer 4: SEMANTIC (ChromaDB + sentence-transformers)
- Layer 3: COLD (Permanent archive)
- Layer 2: WARM (14 days)
- Layer 1: HOT (24 hours)
Integration:
- SessionStart hook: Load context, validate memory
- Stop hook: Write session summary
- PreCompact hook: Flush semantic DB
Limitations of community approach:
- ❌ Requires external dependencies (ChromaDB, sentence-transformers)
- ❌ ~500MB model download
- ❌ Complex setup for new users
- ❌ Maintenance overhead
Benefits of native support:
- ✅ Zero setup complexity
- ✅ Better integration with Claude Code
- ✅ Consistent UX
- ✅ Lower barrier to entry
Priority
Low - Nice to have
Feature Category
CLI commands and flags
Use Case Example
Real-world results after 3 weeks:*
Projects completed:
- 4-Layer Memory System (~3,000 lines)
- Flight Simulator Integration (~14,878 lines)
- Total: ~18,000 lines in 6 weeks
Productivity improvements:
- Context recovery: 5-10 min → <1 min (90% reduction)
- Overall productivity: 3-4x multiplier
- Code quality: Pylint 9.5+/10, 0 security issues (Bandit)
Example workflow:
- Cross-Project Learning
/recall --all "how to handle Unicode errors"
Results:
[project-A] decisions.md - UTF-8 enforcement solution
[project-B] feedback.md - Windows console encoding fix
→ Reused solution, saved 2 hours of debugging
- Automatic Context Recovery
Session starts → loads:
- Last 10 events (HOT layer)
- Important decisions (WARM layer)
- Relevant semantic chunks (L4 layer)
→ Zero manual explanation needed
- Memory Health
/memory health
Output:
✓ HOT: 3 entries (within 24h)
✓ WARM: 12 entries (within 14d)
✓ L4 index: 489 chunks
✓ No ghost links
→ Automatic validation, no manual maintenance
Community adoption:
- Published on GitHub 2 days ago
- MIT license (open for community use)
- Full documentation, installation scripts
- Cross-platform (Windows/Linux/macOS)
Technical stats:
- Memory validation: <0.5s (quick mode)
- Semantic search: 1-3s
- Memory footprint: ~50MB
- Disk usage: ~500MB (including embeddings model)
Additional Context
Questions for Anthropic team:
- Are there plans for native semantic search in Claude Code?
- Would you consider adding memory rotation APIs?
- Is there interest in featuring community projects like this in official docs?
Community value:
- Demonstrates advanced hook usage patterns
- Shows real-world demand for these features
- Provides reference implementation
- Can inform future Claude Code development
Credits:
This implementation integrates ideas from:
- qwwiwi's 4-layer architecture concept
- cablate's atomic wiki system
- Custom L4 semantic layer, auto-discovery, multilingual support
Repository: https://github.com/mergelord/claude-4layer-memory
Status: Production-ready, actively maintained
License: MIT
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗