ContextForge — Context-aware intelligence for Claude Code. Automatic codebase indexing, GPU-accelerated semantic RAG retrieval, and persistent cross-session memory.
npx claudepluginhub kaakati/context-forgeContext-aware intelligence for Claude Code. Automatic codebase indexing, GPU-accelerated semantic RAG retrieval, and persistent cross-session memory.
Share bugs, ideas, or general feedback.
Context-aware intelligence for Claude Code. Automatic codebase indexing, semantic RAG retrieval, and persistent cross-session memory.
ContextForge is a Claude Code plugin that transforms stateless coding sessions into context-aware, learning systems. It automatically indexes your codebase, retrieves relevant code via semantic search, captures coding conventions, and maintains persistent memory across sessions.
claude --plugin-dir /path/to/context_forge
ContextForge will automatically bootstrap on the first session start:
.contextforge/venvcd /path/to/your/project
bash /path/to/context_forge/scripts/bootstrap.sh
When a Claude Code session starts or resumes, ContextForge:
all-MiniLM-L6-v2 sentence transformer (GPU-accelerated when available)On each user prompt, ContextForge:
When files are written or edited, ContextForge:
Modified files are re-chunked and re-embedded in real time, keeping the RAG index current within the session.
| Command | Description |
|---|---|
/contextforge:context-status | Show index state, file counts, conventions |
/contextforge:context-rebuild | Force full re-index of the codebase |
/contextforge:context-memory | Manage persistent memory (list, clear, forget) |
ContextForge automatically detects and uses the best available compute device for embeddings:
| Device | When used |
|---|---|
| CUDA | NVIDIA GPU with CUDA drivers detected |
| MPS | Apple Silicon Mac (M1/M2/M3/M4) |
| CPU | Fallback when no GPU is available |
No configuration needed — detection is automatic. To force a specific device, set embedding.device in your config:
{
"embedding": {
"device": "cpu"
}
}
ContextForge uses sensible defaults. To customize, create .contextforge/config.json in your project:
{
"retrieval": {
"relevance_threshold": 0.4,
"max_results": 10
},
"memory": {
"convention_threshold": 5
},
"indexing": {
"max_file_size_bytes": 1048576
}
}
See config/defaults.json for all available options.
All ContextForge data is stored in .contextforge/ within your project directory:
| File | Purpose |
|---|---|
embeddings.db | SQLite database of code chunk embeddings |
memory.db | Conventions and file change history |
graph.json | Knowledge graph of file relationships |
index_state.json | Git watermark for incremental indexing |
venv/ | Python virtual environment |
models/ | Cached embedding model files |
config.json | User configuration overrides (optional) |
The .contextforge/ directory is automatically added to .gitignore.
ContextForge works on Windows, macOS, and Linux. The hook runner script uses bash (Git Bash on Windows) and all Python code uses pathlib.Path for path handling.
# Unit tests (requires pytest)
python -m pytest tests/ -v
# Integration test
bash tests/test_integration.sh
contextforge/
├── .claude-plugin/plugin.json # Plugin manifest
├── commands/ # Slash command definitions
├── skills/contextforge/ # Skill definition
├── hooks/hooks.json # Hook configuration
├── scripts/ # Hook scripts and bootstrap
│ └── lib/ # Core Python library modules
├── config/defaults.json # Default configuration
└── tests/ # Unit and integration tests
MIT - See LICENSE for details.