The only automatic context preservation system for Claude Code
Zero configuration. Works out of the box. Never lose work to compaction again.
Quick Start β’ Use Cases β’ AI Search β’ How It Works β’ Docs
npm install -g c0ntextkeeper && c0ntextkeeper setup| π€ Automatic | Captures on both /compact and auto-compaction |
| π§ AI-Powered Search | Ask naturally: What auth did I build last week? |
| π Searchable | Find past solutions via 3 MCP tools or 30 CLI commands |
| π Secure | Auto-redacts API keys, credentials, and PII |
| β‘ Fast | <10ms operations, zero performance impact |
| π Comprehensive | 7 hooks, 187 semantic patterns, 3 MCP tools |
| β Production Ready | 483 tests passing, TypeScript, MIT licensed |
When Claude Code compacts your conversation, valuable context disappears:
- Solutions you discussed but haven't implemented
- Decisions about architecture and design patterns
- Problems you identified and their fixes
- Implementation details and code patterns
The cost? You waste 30+ minutes rediscovering solutions. You repeat past mistakes. You lose architectural consistency across sessions.
c0ntextKeeper preserves everything automaticallyβand makes it searchable.
# Install globally
npm install -g c0ntextkeeper
# Run setup (configures Claude Code hooks)
c0ntextkeeper setup
# Verify it's working
c0ntextkeeper statusThat's it. c0ntextKeeper now automatically preserves your context.
Note: The CLI command is
c0ntextkeeper(all lowercase with zero). The project name isc0ntextKeeper(capital K), but commands are always lowercase.
| Use Case | Without c0ntextKeeper | With c0ntextKeeper |
|---|---|---|
| Starting a new feature | Re-explore old solutions from scratch | Ask: What auth did I implement? |
| Debugging an error | Search files manually for past fixes | Ask: How did I fix this before? |
| Architecture decisions | Forget why you chose a pattern | Instant access to reasoning |
| Onboarding teammates | Explain everything verbally | Share searchable context archive |
Try it now:
c0ntextkeeper search "authentication"
c0ntextkeeper patterns --type commandNo regex. No exact keywords. Just ask:
What did I implement for authentication last week? How did I fix that database connection error? What commands do I run most often?
Claude uses c0ntextKeeper's 3 MCP tools automatically. Your queries are processed with word expansion, stop word filtering, and 60-day temporal decay scoring.
π Full MCP Guide β
| Feature | Description |
|---|---|
| Zero Configuration | Install and immediately start preserving context |
| Fully Automatic | Works with both /compact and auto-compaction |
| Intelligent Extraction | 187 semantic patterns detect problems, solutions, decisions |
| MCP Integration | 3 tools + 3 resources for instant context retrieval |
| Security First | Automatic redaction of API keys, credentials, PII |
| Production Ready | 483 tests passing, <10ms operations |
| Feature | c0ntextKeeper | Manual Notes | Other MCP Servers |
|---|---|---|---|
| Automatic Capture | β Both manual & auto | β Manual only | |
| Zero Configuration | β Works out of box | β Requires discipline | β Complex setup |
| 7 Claude Code Hooks | β All events | β N/A | |
| 187 Semantic Patterns | β Intelligent extraction | β Manual categorization | |
| Searchable Archive | β MCP tools + CLI | β File searching | |
| Security Filtering | β Auto-redact secrets | β Manual redaction | β None |
| Performance | β <10ms operations | N/A | |
| Test Coverage | β 483 tests | N/A |
You work in Claude Code
β
Context accumulates from conversations
β
Compaction triggers (manual or automatic)
β
c0ntextKeeper captures context via hooks
β
Archive created with searchable index
β
Retrieve via CLI or MCP tools
c0ntextKeeper provides 30 CLI commands:
- 20 top-level commands (
setup,status,doctor,search, etc.) - 7 hook management subcommands (
hooks list,hooks enable,hooks disable, etc.) - 3 context management subcommands (
context preview,context test,context configure)
# Quick health check
c0ntextkeeper status # See automation status
c0ntextkeeper doctor # Full diagnostics
# Search your history
c0ntextkeeper search "auth" # Find past work
c0ntextkeeper patterns # View recurring patterns
# Manage hooks
c0ntextkeeper hooks list # See all 7 hooks
c0ntextkeeper hooks health # Check data healthπ Full CLI Reference with 30 Commands β
| Hook | Purpose |
|---|---|
| PreCompact | Captures full context before compaction |
| PostToolUse | Tracks tool execution patterns |
| UserPromptSubmit | Preserves user prompts |
| Stop | Captures Q&A exchanges |
| Notification | Tracks notifications |
| SessionStart | Records session metadata |
| SessionEnd | Captures session summaries |
How the AI-powered search works under the hood:
| Feature | Description |
|---|---|
| Word Expansion | "fix" matches "fixed", "fixes", "fixing" automatically |
| Stop Word Filtering | Removes 32 noise words for precision |
| Temporal Decay | Recent content scores higher (60-day half-life) |
| Multi-Field Search | Searches problems, solutions, decisions, patterns |
| Relevance Scoring | Weighted by field: problems (0.3), solutions (0.2), implementations (0.2) |
| You Want To... | Claude Uses | Example Query |
|---|---|---|
| Start a new feature | fetch_context |
"What auth implementations exist?" |
| Find specific work | search_archive |
"Find Redis config in TypeScript files" |
| Filter by date | search_archive |
"What did I work on last week?" |
| See your patterns | get_patterns |
"What commands do I use most?" |
π Full MCP Guide β - Complete documentation with all parameters, examples, and troubleshooting.
Retrieve relevant archived context for your current task:
"Use fetch_context to find previous authentication implementations"
Parameters:
query(required) - What you're looking forlimit- Maximum results (default: 5)minRelevance- Minimum score 0-1 (default: 0.5)scope- "session", "project", or "global"
Search with advanced filters:
"Search the archive for Redis configuration decisions"
Parameters:
query(required) - Search queryfilePattern- Filter by pattern (e.g., "*.ts")dateRange- Filter by datesortBy- "relevance", "date", or "frequency"
Identify recurring patterns and solutions:
"Show me recurring error patterns in this project"
Parameters:
type- "code", "command", "architecture", or "all"minFrequency- Minimum occurrenceslimit- Maximum patterns to return
c0ntextKeeper automatically loads context at session start - Claude begins each conversation already aware of your project history:
| Resource | Content |
|---|---|
context://project/{name}/current |
Recent sessions, decisions, implementations |
context://project/{name}/patterns |
Your recurring patterns and workflows |
context://project/{name}/knowledge |
Q&A knowledge base |
Full MCP documentation: MCP Guide - includes search algorithm details, configuration, and troubleshooting.
Installation Options
- Node.js 18.0.0 or higher
- Claude Code CLI installed
npm install -g c0ntextkeeper
c0ntextkeeper setupgit clone https://github.com/Capnjbrown/c0ntextKeeper.git
cd c0ntextKeeper
npm install
npm run build
npm linkc0ntextkeeper --version
c0ntextkeeper doctorAll CLI Commands (30 total)
| Command | Description |
|---|---|
setup |
Configure Claude Code hooks |
status |
Check automation status |
doctor |
Health diagnostics |
validate |
Verify configuration |
| Command | Description |
|---|---|
search <query> |
Search archived context |
patterns |
View recurring patterns |
stats |
Storage statistics |
| Command | Description |
|---|---|
hooks list |
List all 7 hooks |
hooks health |
Check hook data health |
hooks enable/disable |
Toggle hooks |
hooks config |
Configure hook settings |
hooks test |
Test specific hook |
hooks stats |
View hook statistics |
| Command | Description |
|---|---|
context preview |
Preview auto-load content |
context test |
Test loading strategies |
context configure |
Configuration wizard |
| Command | Description |
|---|---|
init |
Initialize storage |
archive |
Manual archive |
cleanup |
Clean old archives |
rebuild-index |
Rebuild search indexes |
migrate |
Migrate old formats |
migrate:restore |
Restore from backup |
| Command | Description |
|---|---|
debug |
Verbose debug mode |
benchmark |
Performance testing |
test-hook |
Test hook integration |
test-mcp |
Test MCP tools |
server |
Start MCP server |
Storage Architecture
~/.c0ntextkeeper/
βββ config.json # Global configuration
βββ archive/
βββ projects/
βββ [project-name]/ # Human-readable names
βββ sessions/ # Full session context
βββ knowledge/ # Q&A pairs
βββ patterns/ # Tool usage patterns
βββ prompts/ # User prompts
βββ notifications/ # Notifications
βββ sessions-meta/ # Session lifecycle
βββ search-index.json # Inverted index
βββ index.json # Project stats
- Per-Session Files - Unique timestamped files per hook event
- Atomic Writes - No race conditions or data corruption
- JSON Format - Human-readable storage
- Hybrid Storage - Project-local or global (configurable)
Configuration
Located at ~/.c0ntextkeeper/config.json:
{
"storage": {
"location": "global",
"path": "~/.c0ntextkeeper"
},
"autoLoad": {
"enabled": true,
"strategy": "smart",
"maxTokens": 50000
},
"hooks": {
"precompact": { "enabled": true },
"posttool": { "enabled": true },
"stop": { "enabled": true },
"userprompt": { "enabled": true },
"notification": { "enabled": true },
"sessionstart": { "enabled": true },
"sessionend": { "enabled": true }
}
}| Variable | Description |
|---|---|
CONTEXTKEEPER_HOME |
Override storage location |
C0NTEXTKEEPER_DEBUG |
Enable debug logging |
Security
c0ntextKeeper automatically protects sensitive information:
- API Keys - OpenAI, Anthropic, AWS, GitHub
- Credentials - Passwords, secrets, connection strings
- Private Keys - RSA, SSH keys
- PII - Emails (masked), IPs, phone numbers
- Tokens - JWT, bearer, session tokens
API_KEY=sk-1234... β API_KEY=[REDACTED]
user@example.com β ***@example.com
192.168.1.100 β 192.168.***.***
Troubleshooting
Hook not triggering:
c0ntextkeeper hooks health
c0ntextkeeper doctorSearch returns no results:
c0ntextkeeper rebuild-index
c0ntextkeeper statusMCP tools not available:
- Verify c0ntextkeeper-server is running
- Check Claude Code MCP configuration
- Run
c0ntextkeeper doctor
C0NTEXTKEEPER_DEBUG=true c0ntextkeeper statusDoes this slow down Claude Code?
No. All operations average <10ms and hooks run asynchronously without blocking your workflow.
Is my data secure?
Yes. c0ntextKeeper automatically redacts API keys, credentials, PII, and other sensitive data before archiving. All archives are stored locally on your machineβnothing is sent externally.
Do I need to configure anything after installation?
No. Run c0ntextkeeper setup once and it works automatically forever. Zero ongoing maintenance required.
What happens to my old archives?
Archives are preserved indefinitely by default. Use c0ntextkeeper cleanup to remove old archives if needed, or c0ntextkeeper stats to see storage usage.
Can I use this with other AI tools?
Currently, c0ntextKeeper is designed specifically for Claude Code's hook system. Support for other tools is being considered for future releases.
| Topic | Location |
|---|---|
| Quick Start | docs/guides/quickstart.md |
| User Guide | docs/guides/user-guide.md |
| CLI Reference | docs/guides/cli-reference.md |
| MCP Guide | docs/guides/mcp-guide.md |
| Hooks Reference | docs/technical/hooks-reference.md |
| MCP Tools (Technical) | docs/technical/mcp-tools.md |
| Configuration | docs/technical/configuration.md |
| Troubleshooting | docs/guides/troubleshooting.md |
| CI/CD & Contributing | docs/development/CI-CD-GUIDE.md |
git clone https://github.com/Capnjbrown/c0ntextKeeper.git
cd c0ntextKeeper
npm install
npm run dev # Development server
npm run build # Production build
npm test # Run tests (483 tests)
npm run lint # Lint code
npm run typecheck # Type checkContributions are welcome! See CONTRIBUTING.md for guidelines.
- Fork the repository
- Create a feature branch
- Make your changes
- Run tests (
npm test) - Open a Pull Request
MIT License - see LICENSE for details.
Made for the Claude Code community!
SmB