obsidian-cli-automation

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Obsidian CLI Automation

Obsidian CLI 自动化

Overview

概述

Automate Obsidian workflows with deterministic CLI commands. Use this skill to map natural-language requests into safe, repeatable
obsidian
command sequences with explicit verification.
通过确定性的CLI命令自动化Obsidian工作流。使用此技能可将自然语言请求转换为安全、可重复的
obsidian
命令序列,并附带明确的验证步骤。

When to Use

使用场景

Use this skill when requests include any of the following intents:
  • Automate Obsidian workflows from terminal scripts
  • Batch create, update, move, rename, or delete notes
  • Operate daily notes, tasks, links, tags, aliases, properties
  • Query vault structure, search content, generate hygiene reports
  • Manage plugins, themes, snippets, tabs, workspace, bookmarks
  • Inspect or recover history and Obsidian Sync versions
  • Execute developer diagnostics commands such as
    dev:*
    or
    eval
当请求包含以下任一意图时,可使用此技能:
  • 通过终端脚本自动化Obsidian工作流
  • 批量创建、更新、移动、重命名或删除笔记
  • 操作每日笔记、任务、链接、标签、别名、属性
  • 查询库结构、搜索内容、生成健康报告
  • 管理插件、主题、代码片段、标签页、工作区、书签
  • 检查或恢复历史记录与Obsidian Sync版本
  • 执行开发者诊断命令,如
    dev:*
    eval

Quick Start

快速开始

  1. Confirm CLI availability:
    bash
    command -v obsidian
    obsidian version
  2. Discover vault names:
    bash
    obsidian vaults
  3. Pin target vault and run a read-only probe:
    bash
    VAULT='My Vault'
    obsidian vault="$VAULT" vault info=path
    obsidian vault="$VAULT" files total
  1. 确认CLI可用:
    bash
    command -v obsidian
    obsidian version
  2. 查看库名称:
    bash
    obsidian vaults
  3. 固定目标库并运行只读探测:
    bash
    VAULT='My Vault'
    obsidian vault="$VAULT" vault info=path
    obsidian vault="$VAULT" files total

Execution Workflow

执行流程

  1. Discover command surface before automation.
    • Run
      obsidian --help
      .
    • Run
      scripts/collect_obsidian_help.sh
      for a complete snapshot.
  2. Resolve targets with deterministic selectors.
    • Prefer
      path=
      over
      file=
      when ambiguity exists.
    • Use
      vault=<name>
      on all non-trivial runs.
  3. Execute read-first probes.
    • Use
      read
      ,
      file
      ,
      tasks
      ,
      properties
      ,
      search
      ,
      sync:history
      before mutation.
  4. Execute minimal mutation steps.
    • Apply
      append
      ,
      prepend
      ,
      create
      ,
      property:set
      ,
      task
      ,
      move
      ,
      rename
      in small steps.
  5. Verify post-change state.
    • Re-run read/query commands and compare expected vs actual output.
  1. 自动化前先了解命令范围。
    • 运行
      obsidian --help
    • 运行
      scripts/collect_obsidian_help.sh
      获取完整的命令快照。
  2. 使用确定性选择器定位目标。
    • 当存在歧义时,优先使用
      path=
      而非
      file=
    • 在所有非简单运行中使用
      vault=<name>
  3. 先执行只读探测。
    • 在执行修改操作前,先使用
      read
      file
      tasks
      properties
      search
      sync:history
      命令。
  4. 执行最小化修改步骤。
    • 分小步执行
      append
      prepend
      create
      property:set
      task
      move
      rename
      等修改命令。
  5. 验证修改后的状态。
    • 重新运行读取/查询命令,对比预期与实际输出。

Command Families

命令分类

  • Vault discovery and structure:
    vaults
    ,
    vault
    ,
    folders
    ,
    files
    ,
    folder
    ,
    file
  • Note lifecycle:
    create
    ,
    read
    ,
    append
    ,
    prepend
    ,
    move
    ,
    rename
    ,
    delete
    ,
    open
  • Daily workflow:
    daily
    ,
    daily:path
    ,
    daily:read
    ,
    daily:append
    ,
    daily:prepend
  • Tasks and links:
    tasks
    ,
    task
    ,
    links
    ,
    backlinks
    ,
    orphans
    ,
    deadends
    ,
    unresolved
  • Metadata:
    tags
    ,
    tag
    ,
    aliases
    ,
    properties
    ,
    property:read
    ,
    property:set
    ,
    property:remove
  • Search and outline:
    search
    ,
    search:context
    ,
    search:open
    ,
    outline
  • Bases:
    bases
    ,
    base:views
    ,
    base:query
    ,
    base:create
  • UI/system controls:
    tabs
    ,
    tab:open
    ,
    workspace
    ,
    command
    ,
    commands
    ,
    reload
    ,
    restart
  • Theme/snippet/plugin management:
    themes
    ,
    theme:*
    ,
    snippets
    ,
    snippet:*
    ,
    plugins
    ,
    plugin:*
    ,
    plugins:restrict
  • Sync/history and recovery:
    sync:*
    ,
    history:*
    ,
    diff
  • Developer diagnostics:
    dev:*
    ,
    devtools
    ,
    eval
    ,
    dev:console
    ,
    dev:errors
    ,
    dev:screenshot
  • 库发现与结构:
    vaults
    ,
    vault
    ,
    folders
    ,
    files
    ,
    folder
    ,
    file
  • 笔记生命周期:
    create
    ,
    read
    ,
    append
    ,
    prepend
    ,
    move
    ,
    rename
    ,
    delete
    ,
    open
  • 日常工作流:
    daily
    ,
    daily:path
    ,
    daily:read
    ,
    daily:append
    ,
    daily:prepend
  • 任务与链接:
    tasks
    ,
    task
    ,
    links
    ,
    backlinks
    ,
    orphans
    ,
    deadends
    ,
    unresolved
  • 元数据:
    tags
    ,
    tag
    ,
    aliases
    ,
    properties
    ,
    property:read
    ,
    property:set
    ,
    property:remove
  • 搜索与大纲:
    search
    ,
    search:context
    ,
    search:open
    ,
    outline
  • 基础功能:
    bases
    ,
    base:views
    ,
    base:query
    ,
    base:create
  • UI/系统控制:
    tabs
    ,
    tab:open
    ,
    workspace
    ,
    command
    ,
    commands
    ,
    reload
    ,
    restart
  • 主题/代码片段/插件管理:
    themes
    ,
    theme:*
    ,
    snippets
    ,
    snippet:*
    ,
    plugins
    ,
    plugin:*
    ,
    plugins:restrict
  • 同步/历史与恢复:
    sync:*
    ,
    history:*
    ,
    diff
  • 开发者诊断:
    dev:*
    ,
    devtools
    ,
    eval
    ,
    dev:console
    ,
    dev:errors
    ,
    dev:screenshot

High-Value Automation Patterns

高价值自动化模式

Daily planning block

每日规划模块

bash
VAULT='My Vault'
obsidian vault="$VAULT" daily:append content=$'## Plan\n- [ ] Top 1\n- [ ] Top 2\n'
obsidian vault="$VAULT" daily:read
bash
VAULT='My Vault'
obsidian vault="$VAULT" daily:append content=$'## Plan\n- [ ] Top 1\n- [ ] Top 2\n'
obsidian vault="$VAULT" daily:read

Batch frontmatter update for a folder

批量更新文件夹前置元数据

bash
VAULT='My Vault'
obsidian vault="$VAULT" files folder='Projects' ext=md | while IFS= read -r p; do
  [ -z "$p" ] && continue
  obsidian vault="$VAULT" property:set path="$p" name=reviewed value=false type=checkbox
done
bash
VAULT='My Vault'
obsidian vault="$VAULT" files folder='Projects' ext=md | while IFS= read -r p; do
  [ -z "$p" ] && continue
  obsidian vault="$VAULT" property:set path="$p" name=reviewed value=false type=checkbox
done

Vault hygiene snapshot

库健康快照

bash
VAULT='My Vault'
obsidian vault="$VAULT" unresolved total
obsidian vault="$VAULT" orphans total
obsidian vault="$VAULT" deadends total
obsidian vault="$VAULT" recents total
bash
VAULT='My Vault'
obsidian vault="$VAULT" unresolved total
obsidian vault="$VAULT" orphans total
obsidian vault="$VAULT" deadends total
obsidian vault="$VAULT" recents total

Sync inspection before restore

恢复前的同步检查

bash
VAULT='My Vault'
TARGET='Projects/Example.md'
obsidian vault="$VAULT" sync:history path="$TARGET"
obsidian vault="$VAULT" sync:read path="$TARGET" version=1
bash
VAULT='My Vault'
TARGET='Projects/Example.md'
obsidian vault="$VAULT" sync:history path="$TARGET"
obsidian vault="$VAULT" sync:read path="$TARGET" version=1

Safety Guardrails

安全防护

  • Avoid destructive commands (
    delete permanent
    ,
    sync:restore
    ,
    history:restore
    ,
    theme:uninstall
    ,
    plugin:uninstall
    ) without explicit confirmation.
  • Use mutation commands only after a read probe confirms target scope.
  • Split large automations into idempotent, restart-safe steps.
  • Log command output for rollback decisions when running bulk operations.
  • 若无明确确认,避免执行破坏性命令(
    delete permanent
    ,
    sync:restore
    ,
    history:restore
    ,
    theme:uninstall
    ,
    plugin:uninstall
    )。
  • 仅在只读探测确认目标范围后,再执行修改命令。
  • 将大型自动化拆分为幂等、可重启的步骤。
  • 执行批量操作时,记录命令输出以便回滚决策。

Bundled Resources

捆绑资源

  • scripts/collect_obsidian_help.sh
    : Dump top-level help, all command helps, and a markdown report.
  • references/automation-recipes.md
    : Copy-paste automation recipes for recurring workflows.
  • references/obsidian-cli-full-help.md
    : Full command traversal output for
    obsidian
    CLI.
  • scripts/collect_obsidian_help.sh
    :导出顶级帮助信息、所有命令帮助信息,生成Markdown报告。
  • references/automation-recipes.md
    :可直接复制使用的自动化配方,适用于重复工作流。
  • references/obsidian-cli-full-help.md
    obsidian
    CLI的完整命令遍历输出。

Validation Checklist

验证清单

  1. Run target command(s) with explicit
    vault=
    and
    path=
    .
  2. Run verification command(s) immediately after each mutation step.
  3. Report changed files, properties, tasks, or sync versions with exact command evidence.
  1. 使用明确的
    vault=
    path=
    参数运行目标命令。
  2. 每个修改步骤后立即运行验证命令。
  3. 附带确切的命令证据,报告已修改的文件、属性、任务或同步版本。