qi - query engine cli for ai agents and humans

qi indexes your notes and docs into one local SQLite file and answers searches with the exact file and line range of each match, so you and your AI agents can find and cite the right passage without reading whole files. It runs on macOS and Linux, offline.
$ qi search "rollback"
1. Deploy runbook (bm25: 0.0000) [2026-09-01]
qi://notes/runbook.md#L9-L9 [Deploy runbook > Rollback]
qi get 92256d662922d88001924aa57cd56370da30237c5d8d9a870fcd0c9efc347486 --lines 9:9
To roll back a deploy, run make rollback and confirm the previous tag.
Why qi
An agent that answers questions about your notes usually greps the tree and then reads every file that matched. Each file it opens costs tokens and a round trip, and most of what it reads is irrelevant.
qi does the retrieval up front. qi index splits each document into chunks at headings, code fences and paragraph breaks, and stores them in a SQLite database. A search returns one ranked hit per document, each with a snippet, its heading path and a line range. The agent then fetches only those lines with qi get. The repository ships an agent skill and a Claude Code plugin that teach an agent this workflow.
Install
curl -fsSL https://raw.githubusercontent.com/itsmostafa/qi/main/install.sh | sh
The script downloads the latest release for macOS or Linux (amd64 or arm64), checks it against the release's SHA-256 checksums, and installs it to ~/.local/bin. Set QI_INSTALL_DIR to install somewhere else. If that directory is not on your PATH, the script says so.
Run qi update later to replace the binary with the latest release. If its directory is not writable, run sudo qi update.
With a Go toolchain you can build from source instead:
go install github.com/itsmostafa/qi@latest
Claude Code plugin
/plugin marketplace add itsmostafa/qi
/plugin install qi
Quickstart
qi init # write ~/.config/qi/config.yaml and create the database
qi index ~/notes # index a directory; it becomes the collection "notes"
qi search "rollback" # keyword search across every collection
qi init writes a sample collection pointing at ~/notes. Edit or delete it if you keep your notes elsewhere; qi doctor reports a failed check for any collection whose path does not exist.
Then try:
qi index # index the current directory
qi index notes # re-index a collection by name
qi search "rollback" -c notes # search one collection
qi search "rollback" --path 'meetings/*' # only paths matching a glob
qi search "rollback" --since 2026-09-01 # only documents dated on or after
qi search "rollback" -f json # JSON output for scripts and agents
qi query "how do I undo a release" # hybrid search, needs an embedding provider
qi hook install ~/src/monorepo # re-index after every git pull
How search works
qi has two ways to rank chunks and a third that combines them.
- Keyword search (BM25). BM25 is the standard keyword-ranking formula: a chunk scores higher when it contains your terms often and when those terms are rare across the corpus. qi uses SQLite's built-in FTS5 full-text index for it. It needs no setup. If every term must match and nothing does, qi retries with any term matching.
- Vector search. An embedding model turns each chunk and your query into a list of numbers that encodes meaning, and qi ranks chunks by how close their vectors are to the query's. Two passages can match this way with no words in common, such as "undo a release" and "roll back a deploy". It needs an embedding provider (see Configuration).
- Hybrid search.
qi query runs both and merges the two rankings with Reciprocal Rank Fusion (RRF), which scores each document by its rank in each list, so a document near the top of either list ranks well. To stay fast, the vector side scores only the documents keyword search found (topped up with documents matching any query term when that list is short), and scans every chunk only when no document matches any term. On a 424,000-chunk test corpus that took a hybrid query from 1.41 seconds to 0.01 to 0.06 seconds. The cost: when keyword search finds any match, a document with no query term in it cannot surface through vector search; it can only when keyword search finds nothing.