claude-db logo

claude-db

Persistent memory for Claude Code. Bring your own database.

npm
Website GitHub

What is it?

What it is

Persistent memory for Claude Code that builds a semantic code graph and injects context across sessions, with a bring-your-own-database model.

Why it exists

Every Claude Code session starts from zero, forcing users to re-explain their codebase each time; claude-db solves this by persisting semantic memory locally.

Who should use it

Developers using Claude Code who want persistent memory across sessions, especially those working on larger codebases and seeking to reduce repetitive explanations and token usage.

Who should avoid it

Users not using Claude Code, those who prefer not to run a local database, or those with strict privacy policies that prohibit storing code snippets locally.

Stars over time

No change stars in the last 1 day

213213
Aug 30, 2026Aug 30, 2026

How it works

A quick walkthrough in plain English

How claude-db works

Step 1 of 3

You interact with it

Open claude-db, send a request, or connect it to your stack.

Features

Persistent memory for Claude Code across sessions
Automatic capture and recall via hooks
Code graph scanning with incremental updates
Multi-language support (TypeScript, JS, Python, Go, Rust, Ruby, and pattern-based for others)
Live grep (text mode) without scanning
Symbol usage analysis (usages)
Symbol explanation (explain)
Path mode for code navigation
Configurable database backend (SQLite, MongoDB, PostgreSQL)
Local embeddings with optional @xenova/transformers for semantic search
Privacy protections: no data leaves machine, redaction of secrets
CLI commands: install, status, doctor, scan, usages, use, view, etc.
Integration as MCP server
Provides /cdb-scan skill for mapping codebase

Advantages

  • Maintains context across sessions, avoiding re-explanation
  • Reduces token usage by injecting relevant memory
  • Provides classified symbol information, cheaper than manual grep
  • Incremental scanning is cheap, only re-parses changed files
  • Supports multiple languages and pattern-based inference
  • Can share memory across machines via remote database
  • Open source (Apache-2.0) and community-driven

Disadvantages

  • Requires Node.js 22.5 or newer
  • Additional driver installation needed for non-SQLite databases
  • Semantic search requires extra package (@xenova/transformers)
  • Scanning large codebases may be resource-intensive
  • Memory injection adds ~180 tokens per prompt (though often skipped)
  • Configuration complexity for multiple databases
  • Potential privacy risk if remote database used

Installation

native

1. Ensure Node.js 22.5 or newer is installed (SQLite is provided by Node's built-in node:sqlite).
2. Install the package globally: `npm install -g claude-db`.
3. Navigate to your project directory: `cd your-project`.
4. Register hooks and the MCP server scoped to the project: `claude-db install --project`. The `--project` flag writes `.claude/settings.local.json` and `.mcp.json` (add `.mcp.json` to your `.gitignore` as it contains a machine-specific path).
5. Restart Claude Code so the hooks (capture and recall) take effect.
6. (Optional) Map your codebase: `claude-db scan` to build the code graph.
7. (Optional) For real semantic search, install embeddings: `npm install @xenova/transformers`.
8. (Optional) To use another database backend, install the driver (`npm install mongodb` or `npm install pg`) and run `claude-db use "mongodb+srv://user:[email protected]/memory"` or `claude-db use "postgres://user:pass@host:5432/memory"`.

FAQ

How do I install claude-db and set it up for a single project?

Install globally with npm install -g claude-db, then run claude-db install --project inside the repository. This creates .claude/settings.local.json and .mcp.json, registers hooks and the MCP server, and after restarting Claude Code capture and recall are active.

Which databases does claude-db support and how do I switch to a remote one?

By default it uses SQLite at ~/.claude-memory/memory.db. You can switch to MongoDB or PostgreSQL by running claude-db use followed by the connection string, e.g. claude-db use mongodb+srv://user:[email protected]/memory. Install the corresponding driver (mongodb or pg) first.

How does claude-db build the code graph and which languages are supported?

Run claude-db scan. It parses TypeScript, TSX, JavaScript, Python, Go, Rust and Ruby directly. For other languages such as Java, C, C++, C#, Swift, Kotlin, PHP, Elixir and shell it uses pattern matching and tags references as INFERRED. Re-running scan only re-processes changed files.

What privacy guarantees does claude-db provide?

Nothing leaves your machine unless you point it at a remote database. It never stores .env, secrets/, node_modules or .git/, strips text wrapped in <private>...</private>, and redacts API keys and tokens before writing.

How can I view my project's memory in real time?

Run claude-db view. It opens a browser window showing the project's memory live.

Loading documentation…
View on GitHub

Featured in Videos

YouTube tutorials and walkthroughs for claude-db

Alternatives

Similar projects ranked by category, topics, and text overlap.

Compare