| title | SQLite-Memory CLI |
|---|---|
| description | sqlmem command-line workflow and examples for managing sqlite-memory projects. |
| category | platform |
| status | publish |
| slug | sqlite-memory-cli |
sqlmem manages SQLite Memory databases backed by Markdown sources.
The CLI handles project config, optional PDF conversion cache, watch mode, and MCP. Markdown parsing, chunking, embedding, schema, FTS, and vector search stay inside the sqlite-memory extension.
sqlmem init --model /path/to/nomic-embed-text-v1.5.Q8_0.gguf
sqlmem add ./docs
sqlmem search -q "sqlite vector search" --limit 5Remote embeddings use vectors.space when an API key is present:
sqlmem init --api-key "$sqlmem_API_KEY" --model text-embedding-3-smallAPI key precedence is: CLI flag, sqlmem_API_KEY, config.
sqlmem init creates .sqlmem.json in the project root. Edit it manually or use:
sqlmem config
sqlmem config set options.max_results 10If no config is found, commands fail with:
No .sqlmem.json found. Run `sqlmem init` first.
PDF indexing is disabled by default because it needs a separate conversion/OCR step. Enable it explicitly before adding PDF files:
sqlmem config set pdf.enabled truePDFs are then converted to Markdown before indexing. The default converter shells out to glm-ocr and stores cache entries under the global PDF cache:
<pdf-cache>/<sha256>/
source.json
content.md
Override with --pdf-cache-dir or sqlmem_PDF_CACHE_DIR.
sqlmem add ./docs
sqlmem add ./file.pdf
sqlmem add -s ./docs -s ./file.pdf
sqlmem search -q "query" --json
sqlmem watch
sqlmem mcp --transport stdio
sqlmem mcp --transport http --addr 127.0.0.1:8765
sqlmem status
sqlmem clear
sqlmem reindex
sqlmem remove ./docs
sqlmem resetRunning sqlmem without arguments opens an interactive prompt with command history and arrow-key navigation.
Practical examples for common sqlmem workflows.
Create .sqlmem.json, create the SQLite database, and configure the embedding model.
sqlmem init --model /models/nomic-embed-text-v1.5.Q8_0.ggufUse a custom extension cache directory:
sqlmem init \
--extensions-dir ~/.cache/sqlmem/extensions \
--model /models/nomic-embed-text-v1.5.Q8_0.ggufWhen an API key is present, sqlmem configures sqlite-memory for remote embeddings.
sqlmem init \
--api-key "$sqlmem_API_KEY" \
--model text-embedding-3-smallYou can also set the API key through the environment:
export sqlmem_API_KEY="..."
sqlmem init --model text-embedding-3-smallPrecedence is:
--api-keysqlmem_API_KEY.sqlmem.json
Add a directory:
sqlmem add ./docsAdd one Markdown file:
sqlmem add ./README.mdAdd multiple sources in one command:
sqlmem add ./docs ./notes/project.mdUse repeated --source flags:
sqlmem add -s ./docs -s ./notes/project.mdAttach a context label to added content:
sqlmem add ./docs --context product-docsPDF indexing is disabled by default because it requires a separate conversion/OCR step. Enable it explicitly first:
sqlmem config set pdf.enabled truePDF files are then converted to Markdown before indexing.
sqlmem add ./papers/sqlite-memory-overview.pdfUse a custom PDF cache directory:
sqlmem --pdf-cache-dir ~/.cache/sqlmem/pdf add ./papers/report.pdfDisable PDF support again:
sqlmem config set pdf.enabled falseSearch with a positional query:
sqlmem search "hybrid search with sqlite"Search with flags:
sqlmem search -q "embedding cache behavior" --limit 5Return JSON for scripts:
sqlmem search -q "vector extension load order" --limit 10 --jsonPipe JSON to jq:
sqlmem search -q "pdf cache" --json | jq '.[].path'Watch sources already stored in .sqlmem.json:
sqlmem watchWatch explicit paths for the current session:
sqlmem watch ./docs ./notes/project.mdUse a shorter debounce window:
sqlmem watch --debounce 200msShow database path, source count, embedding selection, PDF cache, and indexed counts:
sqlmem statusShow the full configuration:
sqlmem configSet the default search limit:
sqlmem config set options.max_results 10Lower the minimum score:
sqlmem config set options.min_score 0.65Disable embedding cache:
sqlmem config set options.embedding_cache falseSet supported indexed file extensions:
sqlmem config set options.extensions "md,mdx,txt"Opt into reStructuredText explicitly:
sqlmem config set options.extensions "md,mdx,txt,rst"Start the MCP server over stdio:
sqlmem mcp --transport stdioStart the MCP server over HTTP:
sqlmem mcp --transport http --addr 127.0.0.1:8765Available MCP tools:
memory_search
memory_add_file
memory_add_directory
memory_add_text
memory_clear
memory_delete
memory_delete_context
memory_reindex
memory_status
Remove a configured source from .sqlmem.json:
sqlmem remove ./docsReindex all stored memory:
sqlmem reindexClear all memory content:
sqlmem clearReset the project by deleting the configured database and .sqlmem.json:
sqlmem resetRun without a subcommand to open the interactive prompt:
sqlmemInside the prompt:
sqlmem> status
sqlmem> search "release notes"
sqlmem> add ./notes
sqlmem> quit
Command history is available with the up and down arrow keys.
Fail if no results are returned:
results="$(sqlmem search -q "database migration" --json)"
count="$(printf '%s' "$results" | jq 'length')"
test "$count" -gt 0Index all Markdown files changed in the current Git branch:
git diff --name-only main...HEAD -- '*.md' '*.mdx' |
while IFS= read -r file; do
[ -f "$file" ] && sqlmem add "$file"
doneCreate a project-local database name:
sqlmem init --model /models/nomic-embed-text-v1.5.Q8_0.gguf
sqlmem config set database ".cache/project-memory.sqlite"