Install any skill in seconds. Free to start, no credit card required.
Get Started Free →處理 Obsidian 筆記中 frontmatter 標籤(tags)的技能的技能,包括新增、驗證、格式化與提取。 Triggers when user mentions: - "添加 Obsidian 標籤" - "管理 Obsidian tags" - "Obsidian 前頁標籤 / frontmatter tags" - "obsidian 標籤格式 / tag format" - "驗證 Obsidian 標籤 / validate Obsidian tags"
| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-08 | ✗→✓ | ▲ Improved | 53% | 0% |
| case-02 | ✗→✓ | ▲ Improved | 168% | 0% |
| case-07 | ✗→✓ | ▲ Improved | 2% | 0% |
| case-14 | ✗→✓ | ▲ Improved | 62% | 0% |
| case-17 | ✗→✓ | ▲ Improved | 27% | 0% |
此技能協助在 Obsidian 筆記的 frontmatter 中正確管理 tags 欄位,確保標籤符合 Obsidian 的標籤格式規範。
Obsidian 的 tags 位於 frontmatter(YAML 區塊)中,格式為文字陣列。
標籤可使用以下字元:
| 類別 | 字元 | |------|------| | 字母 | A-Z, a-z | | 數字 | 0-9 | | 底線 | _ (Underscore) | | 連字號 | - (Hyphen) | | 斜線 | /(用於巢狀標籤 / Nested tags) | | Unicode | 通用 Unicode 字元 |
#1984 無效,但 #y1984 有效。適度使用巢狀標籤,僅在有意義的層級關係時使用 / 分隔。不需要所有標籤都使用巢狀格式,也不需要同一份檔案中的所有標籤共享相同的上級標籤。每個標籤獨立表達自身的領域路徑。
yaml--- tags: - git # ✅ 無層級關係時,使用獨立標籤 - github # ✅ 獨立標籤 - github/cli # ✅ 僅在有必要層級時才巢狀 - github/cli/workflow # ✅ 進一步細分 - powershell # ✅ 跨領域標籤,無需強制巢狀 ---
| 情境 | 做法 | 範例 | |------|------|------| | 有明確層級關係 | 使用巢狀 / | nodejs/vitest/cli | | 無上下層關係 | 使用獨立標籤 | git + github (非 git/github) | | 跨領域標籤 | 獨立標籤,無需強制巢狀 | powershell 不應硬套為 github/powershell | | 同一檔案多標籤 | 各標籤獨立表達自身領域路徑 | git + github/cli 共存 |
yaml# ❌ 強制所有標籤共享上級(git 不應巢狀於 github 下) tags: - git/github - git/github/cli - git/github/cli/workflow # ❌ 跨領域標籤被硬套巢狀 tags: - github/cli/powershell # powershell 不是 github 的子領域
yaml# ✅ 各標籤獨立表達自身層級 tags: - git - github - github/cli - github/cli/workflow - powershell
yaml--- tags: - tag1 - tag2 - project/active - area/health ---
> 僅限系統限制時使用
yaml--- tags: [tag1, tag2, project/active] ---
透過 Obsidian REST API 的 vault_patch 工具操作:
typescript// 使用操作:在 frontmatter 的 tags 陣列中附加 await mcp-obsidian-local-rest-api-http_vault_patch({ path: "note.md", targetType: "frontmatter", target: "tags", operation: "append", contentType: "application/json", content: ["new-tag", "project/active"], createTargetIfMissing: true, });
使用 scripts/validate-tags.ts 驗證一組標籤是否合法:
bashtsx ".opencode/skills/obsidian-fm-tags/scripts/validate-tags.ts" "tag1" "project/active" "1984"
使用 scripts/extract-tags.ts 從 markdown 檔案提取 tags:
bashtsx ".opencode/skills/obsidian-fm-tags/scripts/extract-tags.ts" "path/to/note.md"
scripts/ 目錄下的工具腳本:
| 腳本 | 用途 | 執行方式 | |------|------|---------| | validate-tags.ts | 驗證標籤字串是否符合 Obsidian 規則 | tsx scripts/validate-tags.ts <tag1> <tag2> ... | | extract-tags.ts | 從 markdown 檔案提取 frontmatter tags | tsx scripts/extract-tags.ts <file-path> |
❌ 不行。 Obsidian 的 tags 不允許空格。若需要多詞標籤,請使用:
code-reviewcode_reviewcodeReview✅ 可以。 但 Obsidian 在顯示時會保留原始大小寫。建議統一使用小寫以維持一致性。
目前 Obsidian Local REST API 不支援直接從陣列中移除單一元素。需先讀取完整 tags 陣列,在用戶端過濾後,再使用 replace 操作覆寫:
typescript// 1. 讀取當前 tags const note = await vault_read({ path: "note.md" }); const currentTags = note.frontmatter.tags; // ["tag1", "tag2", "tag3"] // 2. 過濾掉要移除的標籤 const filteredTags = currentTags.filter(t => t !== "tag2"); // 3. 覆寫 tags await vault_patch({ path: "note.md", targetType: "frontmatter", target: "tags", operation: "replace", contentType: "application/json", content: filteredTags, });
✅ 大部分通用 Unicode 字元皆可,包含:
專案/進行中プロジェクト/完了為了避免語意重複的標籤,請參閱 tag-normalization.md 參照檔案。
Node.js → nodejscode review → code-reviewC++ → cpp, C# → csharpOther measured skills in the registry, with their headline benchmark lift.