Interact with Obsidian vaults using the Obsidian CLI to read, create, search, and manage notes, tasks, properties, and more. Also supports plugin and theme development with commands to reload plugins, run JavaScript, capture errors, take screenshots, and inspect the DOM. Use when the user asks to interact with their Obsidian vault, manage notes, search vault content, perform vault operations from the command line, or develop and debug Obsidian plugins and themes.
Obsidian CLI
使用 obsidian CLI 與正在執行的 Obsidian 實例互動。需要先開啟 Obsidian。
指令參考
執行 obsidian help 查看所有可用指令。這份清單永遠是最新的。完整文件:https://help.obsidian.md/cli
語法
參數 使用 = 帶入值。若值包含空格請用引號括起來:
obsidian create name="My Note" content="Hello world"
旗標 是布林開關,不帶值:
obsidian create name="My Note" silent overwrite
多行內容請使用 \n 表示換行,\t 表示縮排。
檔案定位
許多指令接受 file 或 path 來指定目標檔案。若兩者皆未提供,則使用目前作用中的檔案。
file=<name>— 類似 wikilink 解析(只需名稱,無需路徑或副檔名)path=<path>— 從筆記庫根目錄開始的完整路徑,例如folder/note.md
筆記庫定位
指令預設針對最近聚焦的筆記庫。使用 vault=<name> 作為第一個參數來指定特定筆記庫:
obsidian vault="My Vault" search query="test"
常見用法
obsidian read file="My Note"
obsidian create name="New Note" content="# Hello" template="Template" silent
obsidian append file="My Note" content="New line"
obsidian search query="search term" limit=10
obsidian daily:read
obsidian daily:append content="- [ ] New task"
obsidian property:set name="status" value="done" file="My Note"
obsidian tasks daily todo
obsidian tags sort=count counts
obsidian backlinks file="My Note"
在任何指令後加上 --copy 可將輸出複製到剪貼簿。使用 silent 可避免開啟檔案。在列表指令後加上 total 可取得總數。
外掛開發
開發/測試循環
修改外掛或主題的程式碼後,請依以下流程操作:
- 重新載入 外掛以套用變更:
obsidian plugin:reload id=my-plugin - 檢查錯誤 — 若有錯誤,修正後重複步驟 1:
obsidian dev:errors - 視覺驗證 透過截圖或 DOM 檢查:
obsidian dev:screenshot path=screenshot.png obsidian dev:dom selector=".workspace-leaf" text - 檢查主控台輸出 是否有警告或非預期的日誌:
obsidian dev:console level=error
其他開發者指令
在應用程式環境中執行 JavaScript:
obsidian eval code="app.vault.getFiles().length"
檢查 CSS 值:
obsidian dev:css selector=".workspace-leaf" prop=background-color
切換行動裝置模擬:
obsidian dev:mobile on
執行 obsidian help 查看其他開發者指令,包括 CDP 和除錯器控制項。






