feat: Add obsidian-cli skill for Obsidian vault CLI operations

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Misaka_Company
2026-05-27 16:43:40 +08:00
parent 55da2b74a4
commit 687ab5ee28
2 changed files with 767 additions and 0 deletions

View File

@@ -0,0 +1,199 @@
---
name: obsidian-cli
description: >-
Obsidian CLI skill for reading, creating, editing, searching, and managing note content
in Obsidian vaults from the command line. Supports daily notes, tasks, properties, tags,
links, file history, templates, and full file CRUD operations.
Use this skill whenever the user wants to read or edit Obsidian notes, search vault content,
manage tasks or properties, append/prepend content, or perform any vault note operation.
Also triggers when the user mentions "obsidian cli", "obsidian command", "vault" operations,
or "obsidian" in a terminal/CLI context. Always invoke this skill before attempting
Obsidian-related operations to ensure correct command syntax and available parameters.
Requires Obsidian 1.12+ with CLI enabled and the Obsidian app running.
---
# Obsidian CLI
Control Obsidian from the command line. The Obsidian desktop app must be running — the CLI connects to it over a local bridge.
> **Prerequisites:** Obsidian installer 1.12.7+ with CLI enabled (Settings -> General -> Command line interface).
## Syntax
**Parameters** use `key=value`. Quote values containing spaces:
```bash
obsidian create name="My Note" content="Hello world"
```
**Flags** are boolean switches with no value:
```bash
obsidian create name="My Note" open overwrite
```
**Multiline content:** Use `\n` for newline, `\t` for tab.
**Copy output:** Append `--copy` to any command to copy the result to clipboard.
## Targeting
### File targeting
Most file commands accept `file` and/or `path`. If neither is given, the active file is used.
| Parameter | Behavior |
|-----------|----------|
| `file=<name>` | Resolves like a wikilink — name only, no path or extension needed |
| `path=<path>` | Exact vault-relative path, e.g. `folder/note.md` |
### Vault targeting
If your terminal CWD is a vault folder, that vault is used. Otherwise the active vault is used. Override with `vault=<name>` or `vault=<id>` as the first parameter:
```bash
obsidian vault=Notes daily
obsidian vault="My Vault" search query="test"
```
---
## Commands
For the full parameter reference of every command, read `references/commands-reference.md`.
### Daily notes
```bash
obsidian daily # Open today's daily note
obsidian daily:read # Read daily note content
obsidian daily:append content="- [ ] Buy groceries" # Append to daily note
obsidian daily:prepend content="# Summary" # Prepend to daily note
obsidian daily:path # Get daily note file path
```
### Files and folders
```bash
obsidian file file=Recipe # Show file info
obsidian files folder="Projects" ext=md # List files (filter by folder/extension)
obsidian folders # List all folders
obsidian open file=Recipe # Open a file
obsidian read file=Recipe # Read file contents
obsidian create name="New Note" content="# Hello" # Create a note
obsidian create name="Trip" template=Travel open # Create from template and open
obsidian append file=Recipe content="New line" # Append to file
obsidian prepend file=Recipe content="Header text" # Prepend after frontmatter
obsidian move file=Recipe to="Archive/Recipe.md" # Move/rename file
obsidian rename file=Recipe name="New Recipe" # Rename file
obsidian delete file=Recipe # Delete file (to trash)
obsidian delete file=Recipe permanent # Delete permanently
```
### Search
```bash
obsidian search query="meeting notes" # Search vault (returns file paths)
obsidian search query="TODO" path="Projects" limit=10 # Search within a folder
obsidian search:context query="error" # Search with line context (grep-style)
obsidian search:open query="initial query" # Open search in Obsidian UI
```
### Tasks
```bash
obsidian tasks # List all tasks
obsidian tasks todo # Incomplete tasks only
obsidian tasks daily # Tasks from today's daily note
obsidian tasks file=Recipe done verbose # Completed tasks from a file, with line numbers
obsidian tasks daily total # Count tasks in daily note
obsidian task ref="Recipe.md:8" toggle # Toggle task completion
obsidian task daily line=3 done # Mark daily note task as done
obsidian task file=Recipe line=8 status=- # Set custom status character
```
### Properties
```bash
obsidian properties # List all properties in vault
obsidian properties active # Properties of active file
obsidian properties name=status counts # Count occurrences of a property
obsidian property:set name=status value=done file=Recipe # Set a property
obsidian property:read name=status file=Recipe # Read a property value
obsidian property:remove name=draft file=Recipe # Remove a property
obsidian aliases file=Recipe # List aliases for a file
```
### Tags
```bash
obsidian tags # List all tags
obsidian tags sort=count counts # Tags sorted by frequency with counts
obsidian tags active # Tags of active file
obsidian tag name=project verbose # Tag info with file list
```
### Links
```bash
obsidian backlinks file=Recipe # List backlinks to a file
obsidian backlinks file=Recipe counts # With link counts
obsidian links file=Recipe # Outgoing links from a file
obsidian unresolved # List unresolved links
obsidian orphans # Files with no incoming links
obsidian deadends # Files with no outgoing links
```
### Outline
```bash
obsidian outline file=Recipe # Show headings (tree format)
obsidian outline file=Recipe format=json total # JSON format with heading count
```
### File history
```bash
obsidian diff # List versions of active file
obsidian diff file=Recipe from=1 # Compare latest version to current
obsidian diff file=Recipe from=3 to=1 # Compare two versions
obsidian history file=Recipe # Local history versions
obsidian history:read file=Recipe version=2 # Read a history version
obsidian history:restore file=Recipe version=3 # Restore a history version
```
### Templates
```bash
obsidian templates # List templates
obsidian template:read name=Meeting resolve # Read template with variables resolved
obsidian template:insert name=Meeting # Insert template into active file
```
### Vault info
```bash
obsidian vault # Show vault info
obsidian vault info=files # File count only
obsidian vaults verbose # List all known vaults with paths
obsidian wordcount file=Recipe # Word and character count
obsidian wordcount words # Word count only
```
### General
```bash
obsidian help # List all commands
obsidian version # Show Obsidian version
obsidian reload # Reload app window
obsidian restart # Restart app
```
---
## Tips
- **Clipboard:** Add `--copy` to any command to copy output.
- **Counts:** Add `total` to list commands to get a count instead of full output.
- **Output formats:** Many list commands accept `format=json|tsv|csv` for structured output.
- **Help:** Run `obsidian help` for an always-up-to-date command list. Run `obsidian help <command>` for command-specific help.

View File

@@ -0,0 +1,568 @@
# Commands Reference
Full parameter reference for Obsidian CLI note content commands. Required parameters are marked `(required)`.
## Table of contents
- [General](#general)
- [Daily notes](#daily-notes)
- [Files and folders](#files-and-folders)
- [Search](#search)
- [Tasks](#tasks)
- [Properties](#properties)
- [Tags](#tags)
- [Links](#links)
- [Outline](#outline)
- [File history](#file-history)
- [Templates](#templates)
- [Vault](#vault)
- [Wordcount](#wordcount)
---
## General
### `help`
Show available commands or help for a specific command.
| Parameter | Description |
| ----------- | --------------------------------- |
| `<command>` | Show help for a specific command. |
### `version`
Show Obsidian version.
### `reload`
Reload the app window.
### `restart`
Restart the app.
---
## Daily notes
### `daily`
Open daily note.
| Parameter | Description |
| ------------------------------- | ---------------------- |
| `paneType=tab\|split\|window` | Pane type to open in |
### `daily:path`
Get daily note path. Returns the expected path even if the file hasn't been created yet.
### `daily:read`
Read daily note contents.
### `daily:append`
Append content to daily note.
| Parameter | Description |
| ------------------------------- | ---------------------------- |
| `content=<text>` | (required) Content to append |
| `paneType=tab\|split\|window` | Pane type to open in |
| `inline` | Append without newline |
| `open` | Open file after adding |
### `daily:prepend`
Prepend content to daily note.
| Parameter | Description |
| ------------------------------- | ---------------------------- |
| `content=<text>` | (required) Content to prepend|
| `paneType=tab\|split\|window` | Pane type to open in |
| `inline` | Prepend without newline |
| `open` | Open file after adding |
---
## Files and folders
### `file`
Show file info (default: active file). Returns path, name, extension, size, created/modified timestamps.
| Parameter | Description |
| ------------- | ----------- |
| `file=<name>` | File name |
| `path=<path>` | File path |
### `files`
List files in the vault.
| Parameter | Description |
| ----------------- | ------------------------ |
| `folder=<path>` | Filter by folder |
| `ext=<extension>` | Filter by extension |
| `total` | Return file count |
### `folder`
Show folder info.
| Parameter | Description |
| ------------------------------ | -------------------------- |
| `path=<path>` | (required) Folder path |
| `info=files\|folders\|size` | Return specific info only |
### `folders`
List folders in the vault.
| Parameter | Description |
| --------------- | ------------------------ |
| `folder=<path>` | Filter by parent folder |
| `total` | Return folder count |
### `open`
Open a file.
| Parameter | Description |
| ------------- | ---------------- |
| `file=<name>` | File name |
| `path=<path>` | File path |
| `newtab` | Open in new tab |
### `create`
Create or overwrite a file.
| Parameter | Description |
| ------------------ | ------------------------ |
| `name=<name>` | File name |
| `path=<path>` | File path |
| `content=<text>` | Initial content |
| `template=<name>` | Template to use |
| `overwrite` | Overwrite if exists |
| `open` | Open after creating |
| `newtab` | Open in new tab |
### `read`
Read file contents (default: active file).
| Parameter | Description |
| ------------- | ----------- |
| `file=<name>` | File name |
| `path=<path>` | File path |
### `append`
Append content to a file (default: active file).
| Parameter | Description |
| ---------------- | ---------------------------- |
| `file=<name>` | File name |
| `path=<path>` | File path |
| `content=<text>` | (required) Content to append |
| `inline` | Append without newline |
### `prepend`
Prepend content after frontmatter (default: active file).
| Parameter | Description |
| ---------------- | ----------------------------- |
| `file=<name>` | File name |
| `path=<path>` | File path |
| `content=<text>` | (required) Content to prepend |
| `inline` | Prepend without newline |
### `move`
Move or rename a file (default: active file). Auto-updates internal links if enabled.
| Parameter | Description |
| -------------- | ----------------------------- |
| `file=<name>` | File name |
| `path=<path>` | File path |
| `to=<path>` | (required) Destination path |
### `rename`
Rename a file (default: active file). Extension preserved if omitted. Use `move` to rename and move simultaneously.
| Parameter | Description |
| -------------- | ------------------------- |
| `file=<name>` | File name |
| `path=<path>` | File path |
| `name=<name>` | (required) New file name |
### `delete`
Delete a file (default: active file, trash by default).
| Parameter | Description |
| -------------- | ------------------------------ |
| `file=<name>` | File name |
| `path=<path>` | File path |
| `permanent` | Skip trash, delete permanently |
---
## Search
### `search`
Search vault for text. Returns matching file paths.
| Parameter | Description |
| -------------------- | ------------------------------ |
| `query=<text>` | (required) Search query |
| `path=<folder>` | Limit to folder |
| `limit=<n>` | Max files |
| `format=text\|json` | Output format (default: text) |
| `total` | Return match count |
| `case` | Case sensitive |
### `search:context`
Search with matching line context. Returns grep-style `path:line: text` output.
| Parameter | Description |
| -------------------- | ------------------------------ |
| `query=<text>` | (required) Search query |
| `path=<folder>` | Limit to folder |
| `limit=<n>` | Max files |
| `format=text\|json` | Output format (default: text) |
| `case` | Case sensitive |
### `search:open`
Open search view in Obsidian.
| Parameter | Description |
| --------------- | ---------------------- |
| `query=<text>` | Initial search query |
---
## Tasks
### `tasks`
List tasks in the vault.
| Parameter | Description |
| ------------------------ | --------------------------------- |
| `file=<name>` | Filter by file name |
| `path=<path>` | Filter by file path |
| `status="<char>"` | Filter by status character |
| `total` | Return task count |
| `done` | Show completed tasks |
| `todo` | Show incomplete tasks |
| `verbose` | Group by file with line numbers |
| `format=json\|tsv\|csv` | Output format (default: text) |
| `active` | Show tasks for active file |
| `daily` | Show tasks from daily note |
### `task`
Show or update a task.
| Parameter | Description |
| -------------------- | -------------------------- |
| `ref=<path:line>` | Task reference (path:line) |
| `file=<name>` | File name |
| `path=<path>` | File path |
| `line=<n>` | Line number |
| `status="<char>"` | Set status character |
| `toggle` | Toggle task status |
| `daily` | Target daily note |
| `done` | Mark as done |
| `todo` | Mark as todo |
---
## Properties
### `aliases`
List aliases in the vault.
| Parameter | Description |
| ------------- | -------------------- |
| `file=<name>` | File name |
| `path=<path>` | File path |
| `total` | Return alias count |
| `verbose` | Include file paths |
| `active` | Show for active file |
### `properties`
List properties in the vault.
| Parameter | Description |
| ------------------------ | ----------------------------- |
| `file=<name>` | Show properties for file |
| `path=<path>` | Show properties for path |
| `name=<name>` | Get specific property count |
| `sort=count` | Sort by count (default: name) |
| `format=yaml\|json\|tsv` | Output format (default: yaml) |
| `total` | Return property count |
| `counts` | Include occurrence counts |
| `active` | Show for active file |
### `property:set`
Set a property on a file (default: active file).
| Parameter | Description |
| ---------------------------------------------------- | -------------------- |
| `name=<name>` | (required) Property name |
| `value=<value>` | (required) Property value |
| `type=text\|list\|number\|checkbox\|date\|datetime` | Property type |
| `file=<name>` | File name |
| `path=<path>` | File path |
### `property:remove`
Remove a property from a file (default: active file).
| Parameter | Description |
| ------------- | ------------------------ |
| `name=<name>` | (required) Property name |
| `file=<name>` | File name |
| `path=<path>` | File path |
### `property:read`
Read a property value from a file (default: active file).
| Parameter | Description |
| ------------- | ------------------------ |
| `name=<name>` | (required) Property name |
| `file=<name>` | File name |
| `path=<path>` | File path |
---
## Tags
### `tags`
List tags in the vault.
| Parameter | Description |
| ------------------------ | ----------------------------- |
| `file=<name>` | File name |
| `path=<path>` | File path |
| `sort=count` | Sort by count (default: name) |
| `total` | Return tag count |
| `counts` | Include tag counts |
| `format=json\|tsv\|csv` | Output format (default: tsv) |
| `active` | Show for active file |
### `tag`
Get tag info.
| Parameter | Description |
| ------------ | --------------------------- |
| `name=<tag>` | (required) Tag name |
| `total` | Return occurrence count |
| `verbose` | Include file list and count |
---
## Links
### `backlinks`
List backlinks to a file (default: active file).
| Parameter | Description |
| ------------------------ | ----------------------------- |
| `file=<name>` | Target file name |
| `path=<path>` | Target file path |
| `counts` | Include link counts |
| `total` | Return backlink count |
| `format=json\|tsv\|csv` | Output format (default: tsv) |
### `links`
List outgoing links from a file (default: active file).
| Parameter | Description |
| ------------- | ------------------ |
| `file=<name>` | File name |
| `path=<path>` | File path |
| `total` | Return link count |
### `unresolved`
List unresolved links in vault.
| Parameter | Description |
| ------------------------ | ----------------------------- |
| `total` | Return unresolved link count |
| `counts` | Include link counts |
| `verbose` | Include source files |
| `format=json\|tsv\|csv` | Output format (default: tsv) |
### `orphans`
List files with no incoming links.
| Parameter | Description |
| --------- | ------------------- |
| `total` | Return orphan count |
### `deadends`
List files with no outgoing links.
| Parameter | Description |
| --------- | ---------------------- |
| `total` | Return dead-end count |
---
## Outline
### `outline`
Show headings for a file.
| Parameter | Description |
| ------------------------ | ------------------------------- |
| `file=<name>` | File name |
| `path=<path>` | File path |
| `format=tree\|md\|json` | Output format (default: tree) |
| `total` | Return heading count |
---
## File history
### `diff`
List or compare versions from local File recovery and Sync. Versions numbered newest to oldest.
| Parameter | Description |
| ---------------------- | ------------------------------ |
| `file=<name>` | File name |
| `path=<path>` | File path |
| `from=<n>` | Version number to diff from |
| `to=<n>` | Version number to diff to |
| `filter=local\|sync` | Filter by version source |
### `history`
List versions from File recovery only.
| Parameter | Description |
| ------------- | ----------- |
| `file=<name>` | File name |
| `path=<path>` | File path |
### `history:list`
List all files with local history.
### `history:read`
Read a local history version.
| Parameter | Description |
| --------------- | ------------------------------ |
| `file=<name>` | File name |
| `path=<path>` | File path |
| `version=<n>` | Version number (default: 1) |
### `history:restore`
Restore a local history version.
| Parameter | Description |
| --------------- | ------------------------ |
| `file=<name>` | File name |
| `path=<path>` | File path |
| `version=<n>` | (required) Version number|
### `history:open`
Open file recovery.
| Parameter | Description |
| ------------- | ----------- |
| `file=<name>` | File name |
| `path=<path>` | File path |
---
## Templates
### `templates`
List templates.
| Parameter | Description |
| --------- | ---------------------- |
| `total` | Return template count |
### `template:read`
Read template content.
| Parameter | Description |
| ------------------ | --------------------------------------------------- |
| `name=<template>` | (required) Template name |
| `title=<title>` | Title for variable resolution |
| `resolve` | Resolve `{{date}}`, `{{time}}`, `{{title}}` variables |
### `template:insert`
Insert template into active file.
| Parameter | Description |
| ------------------ | ------------------------ |
| `name=<template>` | (required) Template name |
---
## Vault
### `vault`
Show vault info.
| Parameter | Description |
| ---------------------------------------- | -------------------------- |
| `info=name\|path\|files\|folders\|size` | Return specific info only |
### `vaults`
List known vaults.
| Parameter | Description |
| ---------- | -------------------- |
| `total` | Return vault count |
| `verbose` | Include vault paths |
---
## Wordcount
### `wordcount`
Count words and characters.
| Parameter | Description |
| --------------- | ---------------------------- |
| `file=<name>` | File name |
| `path=<path>` | File path |
| `words` | Return word count only |
| `characters` | Return character count only |