← all systems
AGENT INFRAAI AGENTOPEN SOURCE

cctx — Agent Context Store

One memory for every agent I run. SQLite full-text search under 100ms. No vector database.

SQLite FTS5 · Turso / libSQL · FastAPI · FastMCP · Claude Code Hooks · Railway + Docker

The Problem

Every agent session starts from zero. Claude Code forgets what Cursor learned; the API call has no idea what happened in the terminal an hour ago. The usual answer is a vector database, an embedding pipeline, and a re-index job — three more things to run before you get one useful retrieval. I wanted the boring version: a single store every agent writes to automatically, keyword retrieval that is fast enough to run on every turn, and nothing to babysit. cctx is that store. It is open source, MIT licensed, and it is the system of record I now run my own work against.

Stack

🗄️
SQLite FTS5
BM25 ranked full-text retrieval, <100ms, no vector DB or embeddings
☁️
Turso / libSQL
Cloud primary with a local embedded replica for fast reads
⚡
FastAPI
9 REST endpoints — capture, search, definitions, sessions
🔌
FastMCP
MCP tool layer so any agent can read and write memory
🪝
Claude Code Hooks
Auto-capture every turn — the corpus is complete by default
🚀
Railway + Docker
Deployed server; per-machine installer

How It Works

The execution path

01Turn Captured
→
02Indexed (FTS5)
→
03Agent Queries
→
04Context Injected
Execution flow
Hook fires on every agent turn— Claude Code · Cursor · Messages API
Write to Turso primary → embedded replica syncs
FTS5 index updates in place— no re-index step
Agent calls search / batch_search via MCP or REST
BM25 ranking → top results in <100ms
Definition files (.def) hold current project truth— history is evidence, .defs are authority
Context injected at session start and at stage checkpoints
The design bet is that BM25 over well-captured context beats embeddings over poorly-captured context. Hooks auto-capture every turn — no paste, no prompt ritual — so the corpus is complete, and SQLite FTS5 returns ranked results in under 100 milliseconds. When I needed a month of work analyzed for a resume, I queried 12,148 of my own messages straight out of production. The store answered questions about itself.

Key Design Decisions

🚫
No Vector Database
FTS5 + BM25 over a complete corpus. No embedding pipeline, no re-index job, no second datastore to keep in sync.
🪝
Capture Is Automatic
Hooks write every turn. The memory is complete because nobody has to remember to save anything.
📜
History vs. Authority
Conversation history is evidence. Definition files hold current truth — ICP, pricing, pivots, the graveyard of rejected approaches.
🔌
One Store, Every Agent
Claude Code, Cursor, the Anthropic API, and Managed Agents all read and write the same memory through MCP and REST.

By The Numbers

<100ms
Retrieval latency
0
Vector databases
9
REST endpoints
MIT
License
← back to all systemsmatthew batterson · gtm engineer