obsidian
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseObsidian Skill
Obsidian技能
Routing Policy
路由策略
Use the backend that best matches user intent:
-
MCP (default for vault data operations)
- Read/write/patch/move/search notes
- Frontmatter and tag updates
- Metadata and batch note operations
-
Obsidian CLI/App context (only when app context is needed)
- Open a note in Obsidian from URI
- Trigger app/plugin workflows that MCP cannot perform
-
CLI git (sync/backup workflows)
- Initialize repo, configure remote, commit, pull, push
- Periodic or manual vault backup/sync requests
When a request is ambiguous, pick MCP first unless the user explicitly asks for sync/backup/git/app behavior.
使用最符合用户意图的后端:
-
MCP(知识库数据操作的默认选择)
- 读取/写入/修改/移动/搜索笔记
- Frontmatter和标签更新
- 元数据和批量笔记操作
-
Obsidian CLI/应用上下文(仅当需要应用上下文时使用)
- 通过URI在Obsidian中打开笔记
- 触发MCP无法执行的应用/插件工作流
-
CLI git(同步/备份工作流)
- 初始化仓库、配置远程地址、提交、拉取、推送
- 定期或手动的知识库备份/同步请求
当请求含义模糊时,优先选择MCP,除非用户明确要求同步/备份/git/应用相关行为。
Gotchas
注意事项
-
patch_note rejects multi-match by default. With, if
replaceAll: falseappears more than once the call fails and returnsoldString. SetmatchCountonly when you mean it, or add surrounding context to make the match unique.replaceAll: true -
patch_note matches inside frontmatter. The replacement runs against the full file including the YAML block. A generic string likewill match frontmatter fields. Include enough context to target the right occurrence.
title: -
patch_note forbids empty strings. Bothand
oldStringmust be non-empty and non-whitespace. To delete text, usenewStringwith a single space or restructure the note withnewString.write_note -
search_notes returns minified JSON. Fields are abbreviated:(path),
p(title),t(excerpt),ex(matchCount),mc(lineNumber),ln(obsidianUri). Hard cap of 20 results regardless ofuri.limit -
search_notes multi-word queries score terms individually AND as a phrase. Each term is OR-matched, so a document matching any term appears in results. The full phrase gets an additional scoring boost.
-
write_note auto-creates directories. Parent folders are created recursively. In/
appendmode, if the note doesn't exist it's created. Frontmatter is merged (new keys override) in append/prepend; replaced entirely in overwrite.prepend -
delete_note requires exact path confirmation.must be character-identical to
confirmPath. No normalization, no trailing-slash tolerance. Mismatch silently fails withpath.success: false -
move_file needs double confirmation. Bothand
confirmOldPathmust exactly match their counterparts. UseconfirmNewPathfor markdown renames (text-aware, no confirmation needed); usemove_noteonly for binary files or when you need binary-safe moves.move_file -
manage_tags reads from two sources but writes to one.merges frontmatter tags + inline
list.#hashtags/addonly modify the frontmatterremovearray. Inline tags are never touched.tags -
read_multiple_notes never rejects. Usesinternally. Failed files appear in the
allSettledarray; successful ones inerr. Always check both. Hard limit of 10 paths per call.ok
-
patch_note默认拒绝多匹配。当时,如果
replaceAll: false出现多次,调用会失败并返回oldString。仅当你确实需要时才设置matchCount,或者添加上下文让匹配唯一。replaceAll: true -
patch_note会匹配frontmatter内部内容。替换会对包含YAML块的完整文件生效,类似的通用字符串会匹配frontmatter字段,请包含足够的上下文来定位到正确的匹配项。
title: -
patch_note禁止空字符串。和
oldString都必须是非空且非全空格的。要删除文本,请将newString设为单个空格,或者使用newString重构笔记。write_note -
search_notes返回压缩后的JSON。字段会被缩写:(路径)、
p(标题)、t(摘要)、ex(匹配次数)、mc(行号)、ln(obsidianUri)。无论uri设置为多少,最多返回20条结果。limit -
search_notes多词查询会分别对单个词和短语打分。每个词是OR匹配,所以匹配任意词的文档都会出现在结果中,完整短语会获得额外的分数加成。
-
write_note会自动创建目录。会递归创建父文件夹。在/
append模式下,如果笔记不存在会自动创建。追加/前置模式下frontmatter会合并(新键覆盖旧键);覆盖模式下会完全替换frontmatter。prepend -
delete_note需要精确的路径确认。必须和
confirmPath字符完全一致。没有标准化处理,也不兼容末尾斜杠。不匹配时会静默失败,返回path。success: false -
move_file需要双重确认。和
confirmOldPath都必须和对应的路径完全匹配。markdown文件重命名使用confirmNewPath(文本感知,无需确认);仅当处理二进制文件或需要二进制安全移动时使用move_note。move_file -
manage_tags从两个源读取但只写入一个源。操作会合并frontmatter标签和行内
list。#hashtags/add操作仅修改frontmatter的remove数组,永远不会修改行内标签。tags -
read_multiple_notes永远不会抛出错误。内部使用处理,失败的文件会出现在
allSettled数组中,成功的在err数组中。请始终检查两个数组,每次调用最多支持10个路径。ok
Error Recovery
错误恢复
| Error | Next step |
|---|---|
| patch_note "Found N occurrences" | Add surrounding lines to |
| delete_note / move_file confirmation mismatch | Re-read the note path with |
| search_notes returns 0 results | Try single keywords instead of phrases, toggle |
read_multiple_notes partial | Verify failed paths with |
| 错误 | 下一步操作 |
|---|---|
| patch_note "Found N occurrences" | 给 |
| delete_note / move_file 确认不匹配 | 使用 |
| search_notes 返回0条结果 | 尝试使用单个关键词代替短语,切换 |
read_multiple_notes 部分 | 使用 |
Git Sync Mode
Git同步模式
When the user asks to "sync", "backup", or "store my vault with git", use CLI git with this behavior:
-
Run a preflight before changing anything:
- available
git - current directory is a git repo (or prompt to initialize)
- and
git config user.nameare setgit config user.email - at least one remote exists for push/pull sync
-
If preflight is incomplete, ask exactly one targeted question with a recommended default.
- Use askuserquestion for decisions that materially change behavior.
- Good examples:
- "No git repo found. Initialize one in this vault now? (Recommended: Yes)"
- "No remote configured. Set up GitHub remote now via gh if available, or provide remote URL? (Recommended: Set up via gh)"
- "Local and remote diverged. Try now? (Recommended: Yes)"
git pull --rebase
-
Safe sync sequence (never force push by default):
git add -A- (skip commit if no changes)
git commit -m "vault sync: YYYY-MM-DD HH:mm" git pull --rebasegit push
-
is optional:
gh- Use only for remote bootstrapping (create repo / set origin) when requested.
gh - Do not require for normal sync once remote is configured.
gh
- Use
-
Stop on conflicts and report clear next steps.
- Do not auto-resolve merge conflicts silently.
- Explain what failed and what user should run next.
当用户要求"同步"、"备份"或"用git存储我的知识库"时,使用CLI git并遵循以下行为:
-
做任何修改前先运行预检:
- 可用
git - 当前目录是git仓库(否则提示初始化)
- 已设置和
git config user.namegit config user.email - 至少有一个可用于推拉同步的远程仓库
-
如果预检未完成,仅询问一个针对性的问题并给出推荐默认值。
- 对于会实质性改变行为的决策使用askuserquestion。
- 正面示例:
- "未找到git仓库,是否现在在该知识库中初始化一个?(推荐:是)"
- "未配置远程仓库,是否现在通过可用的gh设置GitHub远程仓库,或者提供远程URL?(推荐:通过gh设置)"
- "本地和远程分支分叉,是否现在尝试?(推荐:是)"
git pull --rebase
-
安全同步序列(默认永远不会强制推送):
git add -A- (如果没有变更则跳过提交)
git commit -m "vault sync: YYYY-MM-DD HH:mm" git pull --rebasegit push
-
是可选的:
gh- 仅当用户要求时使用进行远程仓库初始化(创建仓库/设置origin)。
gh - 远程仓库配置完成后,正常同步不需要。
gh
- 仅当用户要求时使用
-
遇到冲突时停止并报告清晰的下一步操作。
- 不要静默自动解决合并冲突。
- 说明失败原因和用户接下来应该执行的操作。
Resources
资源
Load these only when needed, not on every invocation.
- Tool Patterns - read when you need a tool's response shape, mode details, or the move_note vs move_file decision
- Obsidian Conventions - read when creating/writing note content (link syntax, frontmatter fields, daily note format, template variables)
- Git Sync - read when user asks for backup/sync/store-vault workflows with git/gh
仅在需要时加载这些资源,不要每次调用都加载:
- 工具模式 - 当你需要了解工具的响应结构、模式细节,或者决定使用move_note还是move_file时阅读
- Obsidian约定 - 当创建/写入笔记内容时阅读(链接语法、frontmatter字段、每日笔记格式、模板变量)
- Git同步 - 当用户要求使用git/gh进行备份/同步/存储知识库工作流时阅读