QMD For Codex + Gstack
Purpose
Use qmd as a low-token retrieval layer before large agent prompts.
Verified Commands (2026-04-15)
# Create collections
npx -y @tobilu/qmd collection add /path/to/notes --name notes
npx -y @tobilu/qmd collection add /path/to/meetings --name meetings
# Add context
npx -y @tobilu/qmd context add qmd://notes "Architecture and product notes"
npx -y @tobilu/qmd context add qmd://meetings "Meeting transcripts and decisions"
# Fast lexical retrieval
npx -y @tobilu/qmd search "token optimization" --json -n 10
# Hybrid retrieval for higher quality
npx -y @tobilu/qmd query "codex token optimization" --files -n 10
npx -y @tobilu/qmd query "codex token optimization" --json -n 5
# Fetch full content from result IDs or paths
npx -y @tobilu/qmd get "#abc123"
npx -y @tobilu/qmd multi-get "qmd://notes/*.md" -l 80
Codex Retrieval Pattern
- Start with
qmd search ... --jsonfor fast candidate docs. - Switch to
qmd query ... --fileswhen ranking quality matters. - Pull only top files with
qmd getorqmd multi-get. - Feed only those excerpts into downstream prompts.
Gstack Workflow Pattern
- Keep collections aligned with active project roots.
- Keep context strings short and high-signal.
- Use
--filesfor plan/review skills when you only need file targets. - Use
--jsonfor autonomous summarization or evaluation steps.
Operational Guardrails
- Do not run
qmd collection add/update/embedin parallel on the same index (SQLite lock risk). - Do not run first-time
qmd queryin parallel (model download race can fail withENOENT). - Warm up models once with a single serial
qmd query. - Run
qmd embedafter major content updates for better hybrid quality.
Optional Isolated Test Index
Useful for reproducible local experiments without touching your main index.
XDG_CONFIG_HOME=/tmp/qmd-config \
XDG_CACHE_HOME=/tmp/qmd-cache \
INDEX_PATH=/tmp/qmd-home/test.sqlite \
npx -y @tobilu/qmd status