Skip to main content

Local-first causal memory for AI coding agents (Claude Code, Cursor, Codex)

Project description

IntentDB

ci pypi python license: MIT

IntentDB is a local-first "causal memory" database for AI coding agents.

It answers one question extremely well:

"Why did this file change?"

It does that by indexing your local AI coding history and linking every file edit to the user prompt (intent) that triggered it, plus a compact diff preview and any nearby agent reasoning.

Highlights

  • Causal attribution: link file edits to the prompt that caused them
  • Fast "why" lookups: LMDB hot cache for file history
  • Keyword search: SQLite FTS over prompts, diffs, and reasoning
  • Agent-native: MCP tools so other agents can query the history for you
  • Optional semantic search: embeddings + sqlite-vec

Documentation quick links

Quick start

Prereqs: Python (see pyproject.toml) and uv.

uv sync
uv run intentdb etl

uv run intentdb why path/to/file.py
uv run intentdb search "grpc timeout"
uv run intentdb session <session-uuid-prefix>
uv run intentdb context <change-uuid>
uv run intentdb info

Example output (abridged):

$ intentdb why src/worker/auth.py

  1  Feb 03 12:44  Edit  [claude]  session 9c12a3...
     File: src/worker/auth.py
     User said: "Fix token refresh loop"
     Agent reasoning:
       ...
     Diff:
       @@ ...
       + ...

Demo

IntentDB demo

Use cases

  • Debug regressions: trace a surprising edit back to the prompt that caused it
  • Code review archaeology: understand the "why" behind a diff days later
  • Onboarding: learn how a codebase changed by reading intent + reasoning
  • Agent coordination: let other agents query your local history via MCP
  • Audit trail / provenance: answer "who/what changed this" across multiple agent sources

What it indexes

IntentDB reads from local, on-disk histories (no server required):

  • Claude Code session JSONL (default: ~/.claude/projects/**/*.jsonl)
  • Codex CLI threads (default: ~/.codex/state_5.sqlite)
  • Cursor Composer chats (default: ~/Library/Application Support/Cursor/.../state.vscdb)
  • Optional real-time tool-use queue (hook_queue.jsonl) via a Claude Code hook

It stores data locally under ~/.claude/intent-db (configurable):

  • intent.db (SQLite): durable history + FTS keyword search
  • hot.lmdb (LMDB): hot cache for fast "why" lookups by file path
  • vec_changes (sqlite-vec, optional): semantic search

Why it exists

When you work with AI agents, the real "why" often lives in chat transcripts:

  • tool calls happen across many turns
  • the user intent can be several parent messages back
  • a file can be touched by multiple agents (Claude Code, Codex, Cursor)
  • a week later, "why did we do this" becomes expensive to reconstruct

IntentDB makes that reconstruction a query.

How it works

At a high level:

  1. Parse session histories and extract messages + tool-use events.
  2. For each file-touching tool call, walk the parent chain to find the nearest real user prompt (skipping tool-result user turns).
  3. Store the change record (intent, reasoning, diff preview) in SQLite and a hot index in LMDB.
Sources (local)
  - ~/.claude/projects/**/*.jsonl
  - ~/.codex/state_5.sqlite
  - Cursor state.vscdb
  - hook_queue.jsonl
        |
        v
ETL / indexer
  - extract messages
  - resolve "user intent"
  - build diff preview
        |
        +--------------------------+
        |                          |
        v                          v
SQLite (intent.db)                 LMDB (hot.lmdb)
  - messages                        - c:<change_uuid>
  - changes                         - f:<file_path> -> history
  - search_index (FTS5)             - s:<session_uuid>
  - vec_changes (optional)
        |
        v
CLI + MCP server + daemon

For deeper details: docs/ARCHITECTURE.md.

Installation

From PyPI

python -m pip install intentdb
intentdb etl

If you prefer uv:

uv tool install intentdb
intentdb etl

From source (recommended for now)

git clone https://github.com/H4RR1SON/intentdb.git
cd intentdb

uv sync
uv run intentdb etl

Claude Code integration (macOS)

install.sh is macOS-focused (launchd). It will modify local config files.

bash install.sh

What it does:

  • creates .venv and installs deps
  • registers a Claude Code PostToolUse hook in ~/.claude/settings.json
  • registers the MCP server in ~/.mcp.json
  • runs an initial intentdb etl
  • installs and starts a daemon that keeps indexing

Optional: semantic search (embeddings)

Semantic search requires optional dependencies and an embedding provider key.

uv sync --extra semantic
export VOYAGE_API_KEY="..."
uv run intentdb embed

Usage

Common commands:

  • intentdb etl - index all known sources (Claude Code, Codex, Cursor)
  • intentdb why <file> - show changes to a file, with the triggering prompt
  • intentdb search <query> - keyword search across prompts, diffs, reasoning
  • intentdb session <uuid> - list all changes in a session (prefix ok)
  • intentdb context <change-uuid> - show surrounding conversation
  • intentdb info - stats and per-agent breakdown

MCP server:

uv run intentdb-mcp

Releasing

IntentDB uses a tag-based release workflow.

# 1) bump version in pyproject.toml (and optionally CHANGELOG.md)
git commit -am "Release vX.Y.Z"

# 2) tag + push
git tag vX.Y.Z
git push origin main --tags

GitHub Actions will:

  • build sdist/wheel
  • publish to PyPI (trusted publishing via OIDC)
  • create a GitHub Release with artifacts

Social preview

This repo includes a share image you can upload as the GitHub social preview:

  • assets/social-preview.svg

GitHub requires a raster image for the social preview in Settings; export the SVG to PNG (1280x640) and upload it in:

Settings -> Social preview

Configuration

Environment variables (optional):

  • INTENTDB_DIR: where to store intent.db, hot.lmdb, state files
  • INTENTDB_PROJECTS_DIR: where to read Claude Code session JSONL files
  • CLAUDE_DIR: base directory for Claude Code data (default: ~/.claude)

Privacy

IntentDB stores your prompts, diffs, and agent reasoning locally.

If you enable semantic search / embeddings, text is sent to the embedding provider. Details: docs/PRIVACY.md.

Contributing

See CONTRIBUTING.md.

License

MIT. See LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

intentdb-0.1.0.tar.gz (147.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

intentdb-0.1.0-py3-none-any.whl (40.6 kB view details)

Uploaded Python 3

File details

Details for the file intentdb-0.1.0.tar.gz.

File metadata

  • Download URL: intentdb-0.1.0.tar.gz
  • Upload date:
  • Size: 147.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.7 {"installer":{"name":"uv","version":"0.10.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for intentdb-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e9636176f8866be64d7331e625a2da8b40bce841ba6abf097aa074c66cf64082
MD5 e79ae6999ebae24f9031f21f61814eb0
BLAKE2b-256 1674683e37764417b736b5faf32a342bb1d312ee39fc0abb9745c35f90a92a24

See more details on using hashes here.

File details

Details for the file intentdb-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: intentdb-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 40.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.7 {"installer":{"name":"uv","version":"0.10.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for intentdb-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 da9684da925da844d55083a16bd0f85115748310f2e537679d99ca43392850f1
MD5 5b7a16d3a1b0348bce77084f63b0599c
BLAKE2b-256 3cf790c1d475a9d3e395ff2f3157919777c5def752751ce8225ab731f174076c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page