| name | obsidian-cli |
| description | Use the official Obsidian CLI (1.12+) for vault operations. Prefer CLI for index-powered ops (search, backlinks, tags, tasks, properties, bases). Fall back to file tools when Obsidian is not running or for simple read/write.
|
| triggers | ["obsidian cli","vault search","backlinks","vault tags","vault tasks","property set","base query"] |
Obsidian CLI — Agent Reference
When to Use CLI vs File Tools
Use CLI when you need Obsidian's index or app features:
search, backlinks, links, tags, tasks, properties, bases, templates, outline, orphans, unresolved links
Use file tools (Read/Write/Edit/Grep/Glob) for:
simple file read/write, bulk text replacement, grep across files — no app dependency
Rule of thumb: if Obsidian's index adds value, use CLI. If it's plain text manipulation, use file tools.
Syntax Basics
obsidian <command> [param=value ...] [flag ...]
- Vault targeting:
vault="My Vault" as first param, or run from inside vault dir
- File targeting:
path=exact/path.md (vault-relative) vs file=name (link-style resolution)
- Params:
key=value — quote values with spaces: name="My Note"
- Flags: boolean switches, no
= — e.g. silent, overwrite, counts, total
- Multiline:
\n for newline, \t for tab in content strings
- Structured output:
format=json (search, base:query), format=tsv (properties, tags)
- Clipboard: append
--copy to copy output
Key Commands
Read & Write
obsidian read path=<path>
obsidian append path=<path> content="<text>"
obsidian prepend path=<path> content="<text>"
obsidian create name=<name> content="<text>" silent
obsidian create name=<name> template=<template> overwrite silent
obsidian move path=<from> to=<to>
obsidian delete path=<path>
Gotchas:
create without silent opens the file in Obsidian's UI — always add silent during agent operations.
create doesn't auto-create directories — use mkdir -p via Bash first if the parent folder doesn't exist.
create with template= may place the file in the template's configured folder, ignoring path=. Verify the actual path with search or files after creation.
Daily Notes
obsidian daily
obsidian daily:read
obsidian daily:append content="<text>"
obsidian daily:prepend content="<text>"
Properties (Frontmatter)
obsidian property:set name=<key> value=<val> path=<path>
obsidian property:set name=<key> value=<val> type=<type> path=<path>
obsidian property:read name=<key> path=<path>
obsidian property:remove name=<key> path=<path>
obsidian properties path=<path>
obsidian properties path=<path> format=tsv
Search
obsidian search query="<text>"
obsidian search query="<text>" path=<folder> limit=10
obsidian search query="<text>" format=json
obsidian search query="<text>" format=json matches
obsidian search query="<text>" matches
Tip: format=json matches returns [{"file":"path","matches":[{"line":N,"text":"..."}]}] — use this for programmatic search.
Tags & Tasks
obsidian tags all counts
obsidian tags all counts sort=count
obsidian tag name=<tag>
obsidian tasks all todo
obsidian tasks all done
obsidian tasks daily
obsidian tasks path=<path>
obsidian task ref="<path>:<line>" toggle
obsidian task ref="<path>:<line>" done
Note: tags without all lists tags for the active/specified file only.
Note: tasks without a scope (all, daily, path=) defaults to the active file — use tasks all for vault-wide results.
Links & Graph
obsidian backlinks path=<path>
obsidian backlinks path=<path> counts
obsidian links path=<path>
obsidian unresolved
obsidian orphans
obsidian deadends
Structure
obsidian files folder=<path> ext=md
obsidian folders
obsidian outline path=<path>
Bases
obsidian bases
obsidian base:query path=<path> format=json
obsidian base:query path=<path> view=<name> format=json
Templates
obsidian templates
obsidian template:read name=<name>
obsidian template:read name=<name> resolve
Safety Rules
Never run without explicit user request:
eval — arbitrary code execution
delete permanent — bypasses trash
plugin:install / plugin:uninstall — modifies plugin state
dev:cdp — Chrome DevTools protocol access
Prefer safe patterns:
- Use
append / prepend over full file overwrite
create without overwrite flag is safe (won't replace existing files)
- Confirm with user before bulk property changes, file moves, or deletes
Diagnostics
obsidian vault
obsidian version
Error Handling
| Symptom | Likely cause | Action |
|---|
obsidian version fails | CLI not installed or not on PATH | Fall back to file tools |
| Command hangs or times out | Obsidian app not running | Start Obsidian or use file tools |
| "Unknown command" | CLI version too old | Run obsidian help to check available commands |
| Empty results from search/tags | Vault index not ready | Wait a moment, retry, or use Grep as fallback |
General fallback: if CLI is unavailable, use Read/Write/Edit/Grep/Glob for file operations. The CLI requires the Obsidian desktop app to be running.