Dumping your entire repository into an AI coding agent every time you spin up a session is a surefire way to torch your API credits while getting worse answers in return.
[dvc-benchmark value="170K vs 19.5M" label="Annual token reads" detail="Article comparison from a solo-developer workflow; directional result, not universal benchmark."]
Token burn (annual): ~170K (on-demand retrieval) vs. ~19.5M (blind full-context)
Go-to tech stack: SQLite + FTS5 (built-in full-text search)
Real-world performance: 95.2–95.4% Recall@5 on LongMemEval, pulled off using hierarchical retrieval instead of plain string matching
Cloud vector DB needed: Nope, not unless you're managing sprawling enterprise architecture
Why Shoving Your Entire Repo Into Context Burns Cash
Massive LLM context windows make it dangerously easy to just throw your whole project into every prompt. Sure, that works fine for a quick one-off troubleshooting session, but it will ruin your wallet over a multi-month build. You end up paying for the exact same lines of code over and over again, dozens of times a day.
Worse, burying your prompt under thousands of lines of boilerplate code makes it way easier for the model to lose the thread on what you actually asked it to do.
What 19.5M vs. 170K Actually Looks Like
That massive gap - 170K versus 19.5M tokens - comes straight from one solo dev tracking their daily workflow logs over a year, not some sterile research lab benchmark. Don't treat it as a hard promise, but the takeaway is obvious: have your local agent boot up with just a lean, high-level summary of your project's current state. Then, let it pull in detailed API specs, past bug solutions, or architectural notes only when the current prompt actually calls for them.
The Pragmatic Local Stack: SQLite + FTS5
You honestly don't need an expensive cloud vector database just to give your coding assistant persistent memory. If you're building solo or working on a small team, a single SQLite file sitting right next to your agent code handles business cleanly.
SQLite ships with an FTS5 extension that rips through full-text searches in well under a millisecond. Better yet, you completely skip the tedious hassle of creating, caching, and continuously recalculating vector embeddings every single time you tweak a file.
Why Plain Text Search Routinely Beats Vector Embeddings
Hosted vector stores are fantastic when you only have a vague, high-level idea of what you're looking for. But when you're coding, your agent almost always hunts for exact, literal tokens: an explicit function signature, a specific variable, or a cryptic system error code. For those jobs, fuzzy semantic matching is overkill; you just need clean, deterministic keyword hits.
That's where FTS5 shines. Even with tens of thousands of indexed snippets, a local SQLite lookup runs circles around a cloud vector database simply because there's zero network latency. Plus, your private code never leaves your own hard drive.
A clean setup uses SQLite’s external-content trick: keep your actual records in a regular table, and point an FTS5 virtual index directly at its row IDs:
SQL
CREATE TABLE memory_meta (chunk_id INTEGER PRIMARY KEY, file_path TEXT, commit_hash TEXT, updated_at TEXT, content TEXT);
CREATE VIRTUAL TABLE memory_fts USING fts5(content, content='memory_meta', content_rowid='chunk_id');Hunting down a tricky network bug becomes a dead-simple one-liner: SELECT chunk_id, file_path FROM memory_fts WHERE memory_fts MATCH 'ECONNREFUSED' ORDER BY rank LIMIT 5;. No embedding calls, no external API bills, and the local disk query finishes before your cursor even blinks.
How to Slice Up Markdown and Code Without Losing Context
If you just slice your raw source files into arbitrary 500-character blocks, your agent is going to pull back garbled half-thoughts and give you bad answers. You want your indexing boundaries to follow how the code is actually written.
Markdown chunking: Chop your docs at H2 and H3 tags. That keeps each retrieved block tightly focused on a single topic, guide, or feature.
Code chunking: Keep whole functions, classes, and cohesive logic blocks intact. Never let a naive line counter cut a function in half.
Metadata tagging: Slap the file path, latest commit hash, and timestamp onto every chunk. That way, the agent knows exactly which version it's reading and won't hallucinate patterns from deprecated code.
When You Will Actually Outgrow SQLite
A modest SQLite database will gladly handle tens of thousands of code snippets without breaking a sweat. But if you're dealing with a gigantic monorepo with dozens of engineers shipping code every hour, raw text searches might start missing the forest for the trees.
Knowing When to Bring In pgvector and Neo4j
You only need vector search and graph databases once the complex web of relationships across services starts mattering more than individual code blocks. High-scale enterprise platforms lean on things like pgvector to sift through millions of tokens for conceptually matching patterns across disparate modules.
Graph setups like Neo4j step up when you need to track structural dependencies - like calculating how a breaking change inside your auth gateway ripples down through three separate backend services. That infrastructure makes sense at enterprise scale, but for a personal coding assistant, it's total overkill.
How to Build Your Own Memory Engine (Step-by-Step)
Keep it lean to start: measure your real token consumption, and only add technical complexity when the agent genuinely struggles to find what it needs. A sane trajectory looks like this:
Phase 1 (Solo / Prototype): Run everything out of a single SQLite database with FTS5. Spend your energy writing clean Markdown and chunking code logically. You pay zero cloud hosting bills, and queries resolve instantly.
Phase 2 (Growing Codebase): Stick with SQLite for all your exact code lookups, but layer in a lightweight local embedding model to handle fuzzier, conceptual queries.
Phase 3 (Team Scale): Graduate to a production-grade backend using pgvector alongside Neo4j to manage interconnected microservice graphs and support multiple devs hitting the memory pool simultaneously.
When I built my first agent memory layer, I bought into the hype and went straight to vector embeddings because every tutorial said that was the modern way. Every single context lookup had to wait on an external embedding API call before the agent could even think.
Yet when I asked something concrete like "where did I handle the ECONNREFUSED retry logic," a basic text search for the function name would have grabbed the file instantly. Swapping out the vector setup for raw FTS5 dropped retrieval times from hundreds of milliseconds down to sub-millisecond territory.
Picking which coding agent to build this around isn't nearly as important as getting the memory architecture right. That single choice dictates whether your project stays dirt-cheap or becomes a runaway API expense as your code grows.
