qmd
它能做什么
这项技能教智能体如何用 QMD 搜索个人笔记库。QMD 是一种语义搜索工具。它用于查找过去的决定、会议和人员,无需逐个阅读每个文件。
适用场景
- ✓当用户询问笔记中记录的过去的决定、事故、会议或人员时。
- ✓当智能体需要在阅读完整文件之前先找到相关笔记时。
- ✓当用户想知道自己的笔记库对某个主题有什么记载时。
技能链接
https://github.com/breferrari/obsidian-mind/blob/main/.claude/skills/qmd/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“上个季度我们对定价调整做了什么决定?请帮我在笔记库里搜索。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会优先使用 QMD 搜索工具(如果可用),然后使用命令行版本,只有在最后才直接读取文件。它返回相关片段,而不会读取整个文件。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
QMD — Vault Semantic Search
Before reading vault files directly, search with QMD first. It returns relevant snippets without burning context on full file reads.
Tool Surfaces — Preference Order
Pick the highest surface available and stop. All three read the same SQLite store (see Named Index), so they return the same results; the choice is about interface ergonomics and context cost.
- MCP tools (preferred when registered) —
mcp__qmd__query,mcp__qmd__get,mcp__qmd__multi_get,mcp__qmd__status. If these appear in your tool menu, the MCP server is live and pre-scoped to this vault. Call them directly — no--indexargument needed, no shell involved, typed arguments. This is the intended path during a session. - CLI fallback —
qmd --index <name> query|search|vsearch|get|multi-get. Use when the MCP server isn't registered (older vault clones, Windows install drift, disabled in.mcp.json), or for one-off shell checks outside a session. Always pass--index <name>. - Grep / Glob / Read — last resort, only when QMD is not installed at all. These burn context on full file reads and don't rank by relevance.
Never fall through surfaces without cause — if MCP is registered, calling the CLI in a Bash tool is just a slower path to the same result.
Named Index (This Vault)
This vault uses a named QMD index so queries, updates, and context strings stay scoped to this vault — not blended with any other vault that shares the machine. Every QMD command in this document passes --index <name>.
The name resolves the same way on all three surfaces (CLI, MCP, SessionStart hook), so they always point at the same SQLite store:
qmd_indexinvault-manifest.json, when set — an explicit pin.- Otherwise the vault folder name, slugified. The template ships
qmd_indexempty so every install gets its own store without being asked a question.
Pin the field if you want a name that survives renaming the vault folder, or want to keep a store you already built.
Read the resolved name before running commands rather than assuming either branch:
INDEX=$(node -e '
const ok = (s) => typeof s === "string" && /^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(s);
const m = JSON.parse(require("fs").readFileSync("vault-manifest.json", "utf8"));
if (m.qmd_index && !ok(m.qmd_index)) {
process.stderr.write("qmd_index is set to an invalid name: " + JSON.stringify(m.qmd_index) + "\n");
process.exit(1);
}
const slug = require("path").basename(process.cwd()).normalize("NFKD").toLowerCase()
.replace(/[^a-z0-9._-]+/g, "-").replace(/-{2,}/g, "-").replace(/^[^a-z0-9]+|[-._]+$/g, "");
const name = [m.qmd_index, slug, m.template].find(ok);
if (!name) { process.stderr.write("no usable qmd index name — set qmd_index in vault-manifest.json\n"); process.exit(1); }
process.stdout.write(name);
') || exit 1
qmd --index "$INDEX" query "..."
The value is used as both a CLI argument and a filesystem path (~/.cache/qmd/<name>.sqlite), so an invalid pin must fail here rather than propagate — hence the explicit check instead of m.qmd_index || slug.
In-session, substitute the resolved value directly in your commands — it is stable across the vault's lifetime unless the folder is renamed.
Commands
Each operation lists the MCP call first, then the CLI equivalent. Prefer MCP when available.
Search (pick one per query)
- Hybrid (best quality) —
mcp__qmd__querywithsearches=[{type:"lex", query:"..."}, {type:"vec", query:"..."}]and anintentarg. CLI:qmd --index <name> query "..." --json -n 10. Use for complex or conceptual queries. - Keyword (fast BM25) —
mcp__qmd__querywithsearches=[{type:"lex", query:"..."}]. CLI:qmd --index <name> search "..." --json -n 10. Use for exact terms, names, ticket numbers, dates. - Semantic only —
mcp__qmd__querywithsearches=[{type:"vec", query:"..."}]. CLI:qmd --index <name> vsearch "..." --json -n 5. Use for exploratory queries where you don't know the exact words.
Retrieve
- By path —
mcp__qmd__getwithpatharg. CLI:qmd --index <name> get "path/to/file.md". - By docid —
mcp__qmd__getwith#abc123syntax. CLI:qmd --index <name> get "#docid". - Batch by glob —
mcp__qmd__multi_getwithpatternarg. CLI:qmd --index <name> multi-get "org/people/*.md" --json -l 40.
Index Management (CLI only — MCP exposes read surfaces)
- `qmd --index <name> up
常见问题
为什么要先搜索再读取文件?
技能说明,搜索会返回相关片段,不会因为读取完整文件而占用上下文。
如果没有安装 QMD 怎么办?
技能说明,会改用文件搜索工具。这些工具较慢,而且不按相关性排序。
它优先使用哪种工具顺序?
先用 QMD 工具,然后是命令行,再是 grep、glob 和读取文件。
详情
作者的原始描述
Search the vault using QMD semantic search. Use PROACTIVELY before reading files. Preference order: (1) MCP tools — mcp__qmd__query, mcp__qmd__get, mcp__qmd__multi_get, mcp__qmd__status — if they appear in your tool menu, use them first; (2) CLI `qmd --index <name> ...` as fallback; (3) Grep/Glob only when QMD is not installed. Trigger proactively for past decisions, incidents, people, meetings, architecture, patterns, or any vault content — and after creating/editing notes to check for duplicates and related content.
repo: breferrari/obsidian-mind
热度
- GitHub 星标
- 5.5k
- 排名
- #14842
- 许可证
- MIT
- 更新时间
- 2026/10/17
评论
- …