AI-agnostic local memory for your codebase. Index once, query forever, and keep your source private while empowering any AI tool with semantic code memory.
Supports OpenAI-compatible providers and Anthropic
Quick Demo
30-Second Demo
Run these commands and instantly see how CodeMem surfaces relevant authentication context.
Commands
codemem init
codemem start
codemem ask "how does authentication work"
Output
Relevant Files:
login.ts
authMiddleware.ts
Flow:
User → login → JWT → middleware
Why CodeMem
Stop re-pasting code and let your tools remember the project.
Private local indexing
CodeMem runs locally, stores embeddings on disk, and never sends your code to the cloud unless you choose a hosted AI provider.
AI-agnostic
Use OpenAI-compatible APIs, Anthropic, or local transformers. Switch providers without rearchitecting your workflow.
Reduce tokens, increase relevance
Only the most relevant code chunks are retrieved for each query, keeping prompts efficient and responses accurate.
Build with confidence
Power chat, ask, plan, and apply workflows from the same sidecar agent, with built-in command and patch support.
Install
Install CodeMem in minutes.
Option A — Clone and build
git clone https://github.com/mrabhishek1105/Codemem.git
cd Codemem
npm install
npm run build
npm link
Option B — Install from npm
npm install -g @mrabhishek1105/codemem
Requires Node.js 18+ and npm 8+. Works on Windows, macOS, and Linux.
Quick Start
Start using CodeMem with your project.
1. Initialize
Run this in your project root to create the local index and download the model.
codemem init
2. Start the sidecar
Launch the local server and begin querying code from any tool.
codemem start
3. Query
Search with the CLI or via HTTP using your local code memory.
codemem search "how does auth work"
codemem ask "explain the payment flow"
Workflows
Common developer workflows
1. Understand codebase
Ask CodeMem to explain a system and reveal the relevant files in your project.
codemem ask "how payment system works"
2. Implement feature
Generate a plan, review it, and apply changes with confidence.
codemem plan "add JWT auth"
codemem apply
3. Use with AI assistants
Connect Claude, ChatGPT, or other MCP clients so AI tools call CodeMem automatically for context.
AI calls CodeMem via MCP
Gets code context automatically
Commands
Powerful CLI commands for every workflow.
codemem init
codemem init [--force] [--model <name>]
Initialize the local CodeMem index for the current repository. This command creates the `.codemem` folder, extracts code chunks, and downloads the chosen embedding model so the project is searchable and ready for AI workflows.
Options
--force
Rebuild the index from scratch, ignoring any existing local cache.
--model <name>
Choose which embedding model to use for indexing the repository.
Example
codemem init --model minilm
codemem start
codemem start [--port <n>] [--mcp]
Start the local CodeMem sidecar server, which exposes the search and AI workflow endpoints. The server also optionally enables the MCP bridge for tools like Claude Desktop and Cursor.
Options
--port <n>
Override the default server port (8432) for the local HTTP API.
--mcp
Enable MCP bridge mode for compatibility with MCP-enabled clients.
Example
codemem start --port 9000 --mcp
codemem search
codemem search <query> [--top <n>] [--json]
Search the indexed repository for the most relevant code fragments matching your query. This command helps you find where logic lives without manually scanning files.
Options
--top <n>
Return the specified number of top results. Default is 5.
--json
Output the results in machine-readable JSON format.
Ask an AI question about your repository using the stored semantic code context. CodeMem retrieves the most relevant chunks and sends them to your chosen provider for an accurate answer.
Options
--provider <name>
Select the AI backend: `openai`, `anthropic`, or `local`.
--top <n>
Choose how many indexed context chunks to include in the query.
Example
codemem ask "how does login work" --provider anthropic
codemem plan
codemem plan <task> [--out <file>]
Generate an AI-driven implementation plan for a requested task. CodeMem saves the plan so you can review it or use it later with the apply workflow.
Options
--out <file>
Save the generated plan to a file instead of using the default `last-plan.json` location.
Example
codemem plan "add OAuth login" --out plan.md
codemem apply
codemem apply [] [--dry-run] [--test]
Apply a previously generated plan to your repository by producing file patches and offering a review step. This command can preview changes and optionally run tests after applying them.
Options
--dry-run
Show the patch diff without writing any files.
--test
Run tests after the patch is applied to verify the result.
Example
codemem apply plan.md --dry-run
Release Highlights
Features that make CodeMem compelling.
Local-first architecture
Keep code private and control exactly which queries reach hosted AI providers.
Semantic code retrieval
Index code once and retrieve the right context for each question, not entire files.
MCP bridge support
Use CodeMem with Claude Desktop, Cursor, and other MCP-compatible tools.
Self-hosted server
Use the local HTTP API to integrate CodeMem into your own developer tooling.
AI Integration
How CodeMem connects to AI tools.
Mode 1 — CLI
Run direct commands like `codemem ask` from your terminal to get answers based on project context.
codemem ask "what does auth do"
Mode 2 — MCP
Use Claude, Cursor, and other MCP-compatible assistants. They call CodeMem automatically and receive relevant code context.
Mode 3 — Browser AI
Generate full results from AI with output mode flags and copy code for browser-based workflows.
codemem ask "fix auth" --output=full
Output Modes
Choose how CodeMem returns results.
Context
Get an explanation plus the relevant code context for your query.
codemem ask "fix auth" --output=context
Patch
Ask for a complete file patch so you can apply changes directly or review them first.
codemem ask "fix auth" --output=patch
Full
Request a full response that includes expanded context, code, and implementation guidance.
codemem ask "fix auth" --output=full
How it works
How CodeMem works in four steps.
Index your code using AST parsing and embeddings.
Retrieve the most relevant code chunks for each query.
Build structured context from project files.
Send the context to AI for an accurate answer or patch.
API
Use the local HTTP API.
Integrate CodeMem into your tooling with a simple POST request.
Works best with well-structured codebases and clear project layouts.
Large repositories may take longer to index and require more local storage.
AI responses depend on the quality of the selected provider and model.
About the developer
Built by Abhishek Kumar
Founder & engineer
Abhishek builds infrastructure and AI-powered developer tools that scale with production systems. He designs solutions for CI/CD, observability, cloud infrastructure, and semantic code intelligence.