Obsidian Vault Discipline 标志

Obsidian Vault Discipline

社区
bacnh85
obsidian-vault-discipline

所有知识库文件操作都必须使用 Obsidian 工具(而非 bash)。当用户提到 Obsidian、知识库、笔记、移动知识库中的文件、归档笔记,或在 Obsidian 知识库路径中进行任何文件操作时触发。如果智能体准备对包含“obsidian”“hermes”“vault”“.obsidian”或类似知识库标识的路径使用 bash mv/cp/rm/rename,也要触发。智能体通常会默认使用 bash 操作文件;此技能可避免这一错误。涉及知识库路径的任何文件操作之前都要使用。

Add to TypingMind

概览

发布者bacnh85
代码仓库pi-extensions
技能名称obsidian-vault-discipline
星标数
42
复刻数
15
附带文件
1
链接
  • Markdown 格式的指令

    模型按需加载 SKILL.md 文件,因此只有在请求确实与该技能匹配时才会消耗 Token。

  • 兼容任何大语言模型

    AI 技能采用纯 Markdown,而非特定提供商的代码,因此可搭配 GPT、Claude、Gemini、Grok 或本地模型使用。

  • 1 个附带文件

    模型执行任务时可读取的脚本、模板和参考资料。这些文件为只读文件,绝不会被执行。

  • 开源

    由 bacnh85 发布于 GitHub。请在安装前查看技能的源文件。

安装

在 TypingMind 中安装 Obsidian Vault Discipline AI 技能,即可搭配任意大语言模型使用;也可以将其放入其他支持读取 SKILL.md 的智能体中。

1

安装到 TypingMind

TypingMind 可直接从 GitHub 文件夹安装技能:读取 SKILL.md,打包资源文件,并将结果保存在本地。

  1. 打开应用,前往“插件 → 技能”。
  2. 选择“从 GitHub 安装”。
  3. 粘贴下方的技能文件夹 URL 并确认。
    https://github.com/bacnh85/pi-extensions/tree/main/pi-obsidian/skills/obsidian-vault-discipline
  4. 请在每个需要使用该技能的聊天中启用它。
依次选择“插件 → 技能 → 添加技能 → 从 GitHub URL 导入”,然后粘贴文件夹 URL 并点击“继续”。
2

安装到其他智能体

任何支持 Agent Skills 格式的智能体都可以使用此技能,只需将文件夹复制到该智能体的技能目录中。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/bacnh85/pi-extensions.git /tmp/pi-extensions
mkdir -p .claude/skills
cp -r /tmp/pi-extensions/pi-obsidian/skills/obsidian-vault-discipline .claude/skills/obsidian-vault-discipline
复制后,请重启 Claude Code,以加载新技能。

在 TypingMind 中使用此技能

在任意 TypingMind 聊天中启用 Obsidian Vault Discipline,后续即可交由模型处理。技能的名称和描述会放在系统提示词中,一旦请求匹配,模型就会自动加载完整指令,无需您手动调用,且在实际使用前不会消耗 Token。

一旦请求与技能匹配,模型就会自动加载 Obsidian Vault Discipline。

兼容任何 AI 模型

AI 技能是纯 Markdown 指令,而非特定提供商的代码,因此 Obsidian Vault Discipline 不局限于最初适配的模型。只需在 TypingMind 中安装一次,即可搭配 GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 或您自行运行的本地模型使用,全程使用您自己的 API 密钥。

  • 仅在需要时加载

    系统提示词中仅包含技能名称和描述。首次遇到匹配的请求时才会加载完整指令,因此技能未使用时,这些指令不会消耗 Token。

  • 在聊天中切换模型

    技能是指令而非代码,因此切换模型不会导致技能失效,新模型会读取同一个 SKILL.md。

技能指令

这是模型会加载的 SKILL.md 内容。请在安装前阅读,因为技能就是模型将遵循的指令。

Obsidian Vault Discipline

Why this exists

The Obsidian CLI maintains its own file index separate from the filesystem. Using bash mv, bash cp, or bash rm on vault files bypasses this index: the file moves on disk but Obsidian can't find it. Search, backlinks, graph view, and all vault-aware operations break silently.

This skill ensures every vault file operation goes through Obsidian's API.

Rules

ALWAYS use the obsidian tool for vault file operations

OperationCommand
Readread file="Note Name"
Createcreate path="folder/note.md" content="..."
Write/overwritewrite file="note.md" content="..." overwrite=true
Move/renamemove file="Note" to="New Path"
Rename in placerename file="Note" name="New Name"
Deletedelete path="old.md" permanent=true
Appendappend file="Note.md" content="\nMore text"
Prependprepend file="Note.md" content="# Header\n"

For bulk operations, use eval with Obsidian's JS API

The eval command runs JavaScript inside the Obsidian app with full access to app.vault API. This is the right tool for batch operations.

Quoting rules for eval

code= follows shell quoting rules — get these wrong and the JS fails with a confusing Unexpected token / Unexpected identifier error.

  • Outer wrapper: single quotes code='...' — literal, no escape decoding. Multi-line is fine; single quotes don't stop at whitespace or newlines.
  • Inner JS strings: always double quotes "...". A single quote inside single-quoted code closes the value early (e.g. code='x = 'hi'' breaks).
  • Avoid code="..." (double) for JS — \n / \t decode to real control chars before the JS engine sees them. Use single-quote mode instead.
  • Escape hatch: if code needs both quote types, use eval file=NoteName — it reads the note body as code, so quoting is a non-issue: eval file="Scripts/bulk-move".

Move files matching a pattern:

eval code='
const files = app.vault.getFiles().filter(f =>
  f.path.startsWith("source/folder/") && f.name.includes("keyword")
);
let n = 0;
for (const f of files) {
  const dest = "dest/folder/" + f.name;
  const folder = dest.split("/").slice(0, -1).join("/");
  if (!app.vault.getAbstractFileByPath(folder))
    await app.vault.createFolder(folder, true);
  await app.vault.rename(f, dest);
  n++;
}
return "Moved " + n + " files.";
'

Delete test/temp files:

eval code='
const files = app.vault.getFiles().filter(f =>
  f.name.startsWith("__test") || f.name.startsWith("Untitled")
);
let n = 0;
for (const f of files) { await app.vault.delete(f, true); n++; }
return "Deleted " + n + " files.";
'

Rename a property in frontmatter (scoped to one file):

eval code='
const f = app.vault.getAbstractFileByPath("path/to/note.md");
let c = await app.vault.read(f);
c = c.replace(/^old_property:/m, "new_property:");
await app.vault.modify(f, c);
return "Renamed.";
'

List files by criteria:

eval code='
return app.vault.getFiles()
  .filter(f => f.stat.size > 100000)
  .map(f => f.path + " (" + f.stat.size + " bytes)")
  .join("\n");
'

Batch update frontmatter across many files:

eval code='
const files = app.vault.getFiles().filter(f =>
  f.path.startsWith("folder/")
);
let n = 0;
for (const f of files) {
  let c = await app.vault.read(f);
  let m = c.match(/^---\s*\n([\s\S]*?)\n---/);
  if (!m || m[1].includes("status: archived")) continue;
  c = c.replace(/^status: active/m, "status: archived");
  await app.vault.modify(f, c);
  n++;
}
return "Updated " + n + " files.";
'

(See references/api-examples.md for more patterns.)

NEVER use bash for vault operations

These commands bypass Obsidian's index and must not be used on vault paths:

❌ Wrong✅ Right
bash mv file.md Archive/move file="file" to="Archive/file.md"
bash rm *.mddelete path="file.md" permanent=true
bash cp note.md backup/eval code="..." with app.vault.copy()
bash find vault -exec mv {} dest/ \;eval code="..." with app.vault.rename()
bash cat > file.md <<EOFcreate path="file.md" content="..."
bash sed -i 's/old/new/' file.mdeval code="..." with app.vault.modify()

Detecting vault paths

A path belongs to an Obsidian vault if any of these are true:

  • Running vault shows a vault whose path is a prefix of the target path
  • The path or any parent directory contains .obsidian/
  • The user explicitly says "vault", "obsidian", "my notes", "my vault"
  • The target directory is known from a previous vault operation in the session

When in doubt, check first: run vault to confirm the vault root, then check if your target path falls under it.

Frontmatter tag validation

The YAML # comment gotcha

In YAML, # starts a comment. An unquoted tag value like:

yaml
tags:
  - #type/research     # ← YAML sees this as a COMMENT, not a value

is silently discarded — Obsidian's tag pane shows nothing. Always quote:

yaml
tags:
  - "#type/research"   # ← YAML sees this as a string value

To detect this, never use bash grep '#type/' — that matches raw text and can't tell the difference. Use the validate-tags subcommand which uses Obsidian's own YAML parser:

obsidian run="files validate-tags" vault="My Vault"

This reports any file where the raw text has #type/ or #domain/ but Obsidian's parser sees zero tags (the unquoted-# bug). By default it checks for type/ and domain/ dimensions. Check custom dimensions:

obsidian run="files validate-tags=type/,domain/,status/" vault="My Vault"

Set list properties correctly

When setting array properties (tags, aliases), use type=list:

obsidian run="property:set name=tags type=list value=#type/research,#domain/ai-agents file=Note"
  • name= (not key=)
  • type=list for array values
  • Values are comma-separated, no brackets, no extra quotes

Verification checklist

Before submitting any change involving vault files, confirm:

  • No bash commands (mv, cp, rm, rename, sed, cat, find) were used on vault paths
  • All file operations used the obsidian tool or eval with Obsidian JS API
  • For bulk ops, the eval script handles folders that don't exist yet
  • Test files created during the session were cleaned up via the obsidian tool

Common pitfalls

  • bash mv is fast, but wrong. One mv command saves 2 seconds but breaks the vault. If you need to move many files, use one eval call with a loop instead of 26 move calls.
  • "But I already used bash and it looks fine." The file is on disk but Obsidian's index is stale. Run obsidian search query="filename" — if it returns nothing, the index is broken. Fix by using eval with app.vault.rename() to move it back through Obsidian's API, then move it properly.
  • cat > file.md in bash. This creates a file on disk that Obsidian doesn't know about. Use create path="..." content="..." instead.

附带文件

技能加载后,模型会按需读取这些文件。它们仅作为可读文件提供,绝不会被执行。

常见问题

Obsidian Vault Discipline AI 技能有什么作用?

所有知识库文件操作都必须使用 Obsidian 工具(而非 bash)。当用户提到 Obsidian、知识库、笔记、移动知识库中的文件、归档笔记,或在 Obsidian 知识库路径中进行任何文件操作时触发。如果智能体准备对包含“obsidian”“hermes”“vault”“.obsidian”或类似知识库标识的路径使用 bash mv/cp/rm/rename,也要触发。智能体通常会默认使用 bash 操作文件;此技能可避免这一错误。涉及知识库路径的任何文件操作之前都要使用。

为什么在 TypingMind 中使用 Obsidian Vault Discipline?

因为您只需安装一次,就能搭配任何模型使用。Obsidian Vault Discipline 采用纯 Markdown 格式,而非特定提供商专用的代码,因此同一技能可用于 GPT-5、Claude、Gemini、Grok 或本地模型。您甚至可以在聊天中途切换模型,而不会影响技能的正常使用。TypingMind 使用您自己的 API 密钥,因此您直接向提供商付费,而不是按席位订阅;您的技能和聊天记录也都保留在您自己的存储空间中。

如何在 TypingMind 中安装 Obsidian Vault Discipline?

在 TypingMind 中打开“插件 → 技能 → 从 GitHub 安装”,然后粘贴 https://github.com/bacnh85/pi-extensions/tree/main/pi-obsidian/skills/obsidian-vault-discipline。TypingMind 会读取其中的 SKILL.md,打包相关文件,并将其安装为技能,供您在各个聊天中按需启用。

哪些 AI 模型可以使用 Obsidian Vault Discipline?

您在 TypingMind 中连接的任何模型都可以。AI 技能采用纯 Markdown 指令,而非特定提供商专用的代码,因此 GPT、Claude、Gemini、Grok 和本地模型都能在请求匹配时加载此技能。

Obsidian Vault Discipline 可以搭配多少个 AI 模型使用?

数量不限。只要模型支持技能,您就可以将它与 Obsidian Vault Discipline 搭配使用。GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 等模型都可以通过您自己的 API 密钥接入 TypingMind。

Obsidian Vault Discipline AI 技能免费吗?

bacnh85 已在 GitHub 上发布了该技能。请查看代码仓库了解许可条款。您只需向自己的 AI 提供商支付所用 Token 的费用。

什么是 AI 技能?

AI 技能是一组可复用的指令,用于教会 AI 模型完成某项特定任务。它遵循开放的 Agent Skills 格式:包含名称和描述的 SKILL.md 文件,以及模型可能需要的脚本、模板或参考文件。模型仅在您的请求与技能匹配时才会读取这些指令,因此已安装的技能在使用前不会产生任何费用。

AI 技能与插件或 MCP 服务器有何不同?

插件或 MCP 服务器为模型提供可调用的新工具,也就是在某处运行并返回结果的代码。AI 技能则为模型提供知识和流程:如何处理任务、遵循哪些步骤,以及怎样的输出才算优质。技能采用纯 Markdown 格式,因此不需要服务器、API 密钥或运行时环境,并且适用于任何模型。

查看全部

立即创建您自己的 AI 工作区

订阅我们的电子简报,获取新功能和后续赠奖活动的通知 👇