Claude Cache - Memory for your AI coding assistant
Project description
Claude Cache
Memory for your AI coding assistant
Claude Cache automatically processes your Claude Code logs, identifies successful patterns, and builds memory that reduces AI hallucinations and improves coding effectiveness.
Note: This is an independent tool for enhancing Claude Code, not an official Anthropic product.
๐จ Important: How Claude Cache Learns
Claude Cache learns from your feedback! When Claude helps you successfully, you must tell it:
- Say "Perfect!", "That worked!", or "Thanks!" when things work
- Without feedback, Cache won't know what succeeded and won't save patterns
- More feedback = Better memory = Smarter Claude
Example:
You: "Add user authentication"
Claude: *implements auth*
You: "Perfect! The login works now" โ This triggers learning!
Features
- First-Run Documentation Import - Scans your entire Development folder for existing documentation
- Automatic Log Processing - Monitors and processes Claude Code session logs in real-time
- Intelligent Lesson Organization - Categorizes lessons by topic (auth, database, API, etc.)
- Smart Document Management - Keeps CLAUDE.md under 30KB with overflow handling
- Success Pattern Detection - Identifies which approaches worked well for specific tasks
- Context Generation - Creates hierarchical context with category-specific files
- Slash Commands - Generates Claude Code slash commands for quick access to patterns
- Convention Tracking - Learns your project's coding conventions and patterns
- Team Knowledge Sharing - Export and import patterns for team collaboration
- User Content Preservation - Your custom notes in CLAUDE.md are never overwritten
How It Works
- First Run - Prompts to scan your Development folder for all existing documentation
- Import - Extracts lessons learned, warnings, and best practices from your docs
- Organize - Categories lessons into topics (authentication, database, API, etc.)
- Monitor - Watches your Claude Code log files (
~/.claude/projects/) - Analyze - Detects successful patterns using multiple indicators
- Store - Builds a searchable knowledge base with SQLite
- Generate - Creates intelligent index with category files in
.claude/lessons/ - Learn - Improves Claude's responses with hierarchical context
Multi-Project Support
Claude Cache automatically handles multiple projects without any configuration:
- Automatic Detection - Identifies different projects from Claude Code session logs
- Separate Knowledge Bases - Each project gets its own patterns and context
- Project-Specific Learning - React patterns for your frontend won't mix with Python patterns from your API
- Smart Context Injection - Claude reads the right
.claude/CLAUDE.mdbased on which project you're working in
When you switch between projects in Claude Code, Claude Cache automatically switches context too!
Installation
From PyPI (Recommended)
pip install claude-cache
From Source (Development)
git clone https://github.com/ga1ien/claude-cache.git
cd claude-cache
pip install -e .
Quick Start
First Time Setup
cache start
On first run, you'll see:
๐ Welcome to Claude Cache!
Would you like to scan for existing documentation?
1. Scan all Claude Code projects (from logs)
2. Scan your Development folder [Default]
3. Scan a custom directory
4. Skip for now
Choose an option [2]: _
This imports all your existing documentation, giving you an immediate knowledge base!
Running Claude Cache
Option 1: Terminal Tab (Simplest)
cache start
# Keep this terminal tab open
Option 2: tmux (Recommended for long sessions)
# Install tmux (one-time)
brew install tmux
# Start in tmux
tmux new -s cache
cache start
# Detach: Ctrl+B then D
# Reattach: tmux attach -t cache
Note: The --daemon flag has issues on macOS. Use tmux or a terminal tab instead.
-
Use Claude Code as normal - Claude Cache will automatically process your interactions
-
Give feedback when things work - Say "Perfect!", "That worked", or "Thanks!" to help Claude Cache learn
-
Access your patterns via slash commands in Claude Code:
/project-context [task description]- Get relevant patterns for your current task/best-practices- View successful approaches/conventions- See detected project conventions/quick-ref- Quick reference for frequently used files/debug-helper- Get debugging assistance
Usage
Basic Commands
# Start monitoring and processing logs
cache start
# Process existing logs without monitoring
cache process
# Query patterns from your knowledge base
cache query "implement authentication"
# Show statistics
cache stats
# Generate slash commands for a project
cache generate --project my-project
Documentation Commands
# Scan repository for documentation (lessons learned, READMEs, etc.)
cache scan-docs /path/to/repo
# Scan current directory
cache scan-docs .
# Search through indexed documentation
cache search-docs --query "authentication" --project my-app
Advanced Usage
# Export patterns for backup or sharing
cache export patterns.json --project my-project
# Import patterns from team member
cache import team-patterns.json
# Rebuild knowledge base from scratch
cache rebuild --confirm
# Generate context for specific request
cache context "fix login bug" --project my-app
Configuration
Claude Cache stores its database at:
~/.claude/knowledge/cache.db
Slash commands are generated in your project's .claude/commands/ directory.
Fine-Tuning Detection
The tool automatically detects and adapts to different tech stacks:
Built-in Stack Detection:
- Frontend: React, Vue, Angular, CSS, Tailwind
- Backend: APIs, Express, Django, Rails
- Database: SQL, migrations, ORMs, query optimization
- Mobile: React Native, Expo, Flutter
- DevOps: Docker, Kubernetes, CI/CD
- Testing: Jest, Pytest, Cypress
Customization via config.yaml:
# Adjust success weights for your stack
stack_weights:
frontend:
user_satisfied: 0.3
no_console_errors: 0.25
component_renders: 0.25
# Add custom success patterns
custom_patterns:
react_success:
keywords:
- "useEffect working"
- "state updated correctly"
weight: 1.3
Per-Project Configuration:
projects:
my-frontend-app:
primary_stack: frontend
success_threshold: 0.75
extra_patterns:
- "lighthouse score improved"
The tool learns what "success" means for YOUR specific tech stack and coding patterns.
Adding Custom Tech Stacks
Any tech stack can be added! Edit config.yaml:
custom_stacks:
your_stack_name:
keywords: ["your", "stack", "keywords"]
file_patterns: ["*.ext", "folder/*"]
success_indicators:
- "compilation successful"
- "your success condition"
failure_indicators:
- "your error pattern"
weight_multiplier: 1.3
Examples included for:
- Rust/Actix, Elixir/Phoenix, Go/Gin
- Svelte/SvelteKit, Game Development (Unity/Godot)
- Data Science (Pandas/PyTorch), Blockchain/Web3
- Infrastructure as Code, Embedded Systems
See custom_stacks_example.yaml for complete examples.
How Success Detection Works
Claude Cache uses multiple signals to identify successful patterns:
Your Feedback (Most Important!)
- User satisfaction - "Perfect!", "That worked!", "Thanks!"
- Task completion - "Fixed!", "Done!", "Working now!"
Automatic Detection
- Test Results - "Tests passed", "Build successful" in output
- Error-Free Execution - No exceptions after changes
- File Modifications - Successful edits without errors
- Success Markers - โ, โ , "SUCCESS" in output
Sessions scoring above 70% are stored as successful patterns.
Pattern Matching
When you make a new request, the system:
- Searches for similar previous requests using TF-IDF vectorization
- Ranks patterns by similarity and success score
- Generates context from the most relevant patterns
- Injects this context to improve Claude's response
Project Structure
claude-cache/
โโโ src/
โ โโโ cache_for_claude/
โ โโโ __init__.py
โ โโโ agent.py # Main coordination agent
โ โโโ cli.py # Command-line interface
โ โโโ context_injector.py # Context and command generation
โ โโโ doc_scanner.py # Documentation scanner for imports
โ โโโ lesson_organizer.py # Categorizes lessons by topic
โ โโโ knowledge_base.py # Database storage
โ โโโ log_processor.py # Log parsing
โ โโโ log_watcher.py # File monitoring
โ โโโ success_detector.py # Pattern detection
โโโ pyproject.toml
โโโ README.md
Privacy & Security
- All data is stored locally on your machine
- No data is sent to external services
- Sensitive information in logs remains private
- Export/import allows controlled sharing
Use Cases
For Individual Developers
- Build a personal knowledge base of what works
- Reduce repetitive explanations to Claude
- Speed up problem-solving with historical context
- Track your most successful coding patterns
For Teams
- Share successful patterns across team members
- Maintain consistent approaches to common tasks
- Onboard new developers with team-specific knowledge
- Build collective intelligence from everyone's interactions
For Projects
- Document project-specific conventions automatically
- Track which files are frequently modified together
- Identify common debugging patterns
- Maintain project-specific context
Working with Multiple Projects
Claude Cache seamlessly handles multiple projects. Here's what happens:
Automatic Project Separation
# When you work on different projects:
~/Development/my-react-app โ Patterns stored under "my-react-app"
~/Development/python-api โ Patterns stored under "python-api"
~/Development/mobile-app โ Patterns stored under "mobile-app"
Project-Specific Files Created
each-project/
โโโ .claude/
โ โโโ CLAUDE.md # Main index (5-10KB, Claude reads this)
โ โโโ lessons/ # Categorized lessons (unlimited)
โ โ โโโ authentication_lessons.md
โ โ โโโ database_lessons.md
โ โ โโโ api_lessons.md
โ โ โโโ debugging_lessons.md
โ โโโ commands/ # Slash commands for Claude Code
Intelligent Document Organization
CLAUDE.md Structure (Kept Small):
- Top 5 critical warnings
- Category index with file paths
- Instructions for Claude
- User notes section (preserved)
Lessons Directory:
- Organized by topic
- 10 lessons per priority level
- Automatic overflow files for >40 lessons
- Smart navigation between parts
Managing Multiple Projects
# View all projects
cache stats
# View specific project
cache stats --project "my-react-app"
# Export one project's patterns
cache export react-patterns.json --project "my-react-app"
# Query across all projects
cache query "authentication"
# Query one project only
cache query "authentication" --project "python-api"
How Claude Uses Project Context
- You open
my-react-appin Cursor/Claude Code - Claude automatically reads
my-react-app/.claude/CLAUDE.md - Claude now knows your React patterns, not your Python patterns
- Switch to
python-apiโ Claude switches context automatically
No configuration needed - it just works!
Contributing
Contributions are welcome! Please see our Contributing Guide for details.
Roadmap
- Web dashboard for pattern visualization
- Integration with other AI coding tools
- Pattern clustering and categorization
- Automated pattern quality scoring
- Multi-project pattern correlation
- VSCode extension for pattern access
License
MIT License - see LICENSE file for details.
Acknowledgments
Inspired by the insight that "if you document along the way, AI hallucinates less because it has more documentation that's personalized to the project."
Support
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Documentation: Full Documentation
Note: This tool is not officially affiliated with Anthropic or Claude. It's a community tool designed to enhance your Claude Code experience.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file claude_cache-0.2.0.tar.gz.
File metadata
- Download URL: claude_cache-0.2.0.tar.gz
- Upload date:
- Size: 72.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3ba61760ae5defa3788cacb5b3d9a1a6b632a596cccea5bbbb03805bd216d1e5
|
|
| MD5 |
91d5915057fb0d6a7bfbb9c3e5470047
|
|
| BLAKE2b-256 |
21ec1c0d8d63a14cb87cbef40589c1e13151e2046fba72b811b4355554cd284e
|
File details
Details for the file claude_cache-0.2.0-py3-none-any.whl.
File metadata
- Download URL: claude_cache-0.2.0-py3-none-any.whl
- Upload date:
- Size: 56.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5bdf38c8b6d52ab9c88a53d3c94fa441002cbb1994092c36c6ed2e97940f4f70
|
|
| MD5 |
85747c4b81b39ddff3005a7133646ba4
|
|
| BLAKE2b-256 |
293278c469f28ef1d937426cfc0c360a8e25573587f641addadf1414e3371c05
|