💎

Obsidian

Verified

by Community

Connect to a local Obsidian vault to search notes, read content, find backlinks, and explore your knowledge graph. Useful for retrieving context from your personal knowledge base.

obsidianknowledgenotesvaultpkmmarkdown

Obsidian Skill

Access and search your local Obsidian vault.

Vault Location

Use ONE canonical vault path, and resolve it rather than hardcoding it — the right answer differs per runtime:

  • Hermes: $HERMES_HOME/obsidian-vault (that is /opt/data/obsidian-vault).
  • OpenClaw: $HOME/.openclaw/workspace/obsidian-vault.
  • An explicit OBSIDIAN_VAULT_PATH always wins.

Two reasons this matters. First, consistency: these skills previously named different locations, so an agent could create a second vault beside the one already in use and then search the empty one. Second, durability on OpenClaw, where $HOME is /home/node and ONLY ~/.openclaw is persisted — a vault at ~/.obsidian-vault there is lost on the next container rebuild. On Hermes the agent's home IS the persistent mount (/opt/data), so ~/ paths already persist; the canonical path is about consistency, not rescue.

Every bash block below opens with the two-line resolver that applies this order. Run it even for a one-off command.

A ~/.obsidian-vault symlink points at the real vault so older prompts keep working. On OpenClaw that symlink is outside the persisted directory, so recreate it after an image upgrade — the target vault is unaffected.

First-Time Setup

Run this idempotent block before any sync method, and again after any image upgrade where the symlink is missing:

VAULT="${OBSIDIAN_VAULT_PATH:-${HERMES_HOME:+$HERMES_HOME/obsidian-vault}}"
VAULT="${VAULT:-$HOME/.openclaw/workspace/obsidian-vault}"
LEGACY="$HOME/.obsidian-vault"
STALE="$HOME/.openclaw/workspace/obsidian-vault"

# Adopt a vault an earlier version of these skills left somewhere else, so
# notes are not split across two directories. On OpenClaw the LEGACY path is
# also outside the persisted dir, so moving it prevents real data loss.
# Guards: source is a real directory, and the destination does not already
# exist. Test -L as well as -e: -e is FALSE for a dangling symlink.
for OLD in "$LEGACY" "$STALE"; do
  [ "$OLD" = "$VAULT" ] && continue
  if [ -d "$OLD" ] && [ ! -L "$OLD" ] && [ ! -e "$VAULT" ] && [ ! -L "$VAULT" ]; then
    mkdir -p "$(dirname "$VAULT")"
    mv "$OLD" "$VAULT"
  fi
done

# A broken symlink at the destination makes `mkdir -p` fail (it follows the
# link to a target that is not there), which would otherwise leave no vault
# at all behind a confusing error. Stop and say what to do instead.
if [ -L "$VAULT" ] && [ ! -d "$VAULT" ]; then
  echo "ERROR: $VAULT is a broken symlink. Remove or repoint it, then re-run."
  exit 1
fi

mkdir -p "$VAULT"

# Report any second vault left behind, rather than silently leaving notes
# split in two places. Happens when two old vaults exist, or when the
# destination already had one.
for OLD in "$LEGACY" "$STALE"; do
  [ "$OLD" = "$VAULT" ] && continue
  if [ -d "$OLD" ] && [ ! -L "$OLD" ]; then
    echo "WARNING: another vault directory remains at $OLD."
    echo "         This skill uses $VAULT — merge them so notes are not split."
  fi
done

# Compatibility symlink for older prompts. Only where it cannot clobber data:
# ln -snf into an existing real DIRECTORY silently creates the link INSIDE it.
if [ "$LEGACY" != "$VAULT" ] && { [ ! -e "$LEGACY" ] || [ -L "$LEGACY" ]; }; then
  ln -snf "$VAULT" "$LEGACY"
fi

Vault Design (Optional)

After the directory exists, ask the user whether they want help designing the vault's structure. This is interactive — don't impose a layout without asking.

Ask first:

  • What will the vault be used for? (research, writing, daily journaling, project notes, general knowledge base)
  • Their experience level with Obsidian
  • Any existing folders or tag conventions to preserve

A minimal default most users find useful (customize per use case):

VAULT="${OBSIDIAN_VAULT_PATH:-${HERMES_HOME:+$HERMES_HOME/obsidian-vault}}"
VAULT="${VAULT:-$HOME/.openclaw/workspace/obsidian-vault}"
mkdir -p "$VAULT/Notes" "$VAULT/Daily" "$VAULT/Templates" "$VAULT/Archive"

Customize: academic research vaults often add Literature/ and Sources/; writing vaults use Drafts/ and Published/; PKM vaults sometimes split by MOCs/ (maps of content) and Topics/.

Recommend desktop community plugins by workflow (the bot does NOT install desktop Obsidian plugins — the user installs them in their desktop Obsidian app):

  • Daily journaling: Templater, Calendar, Periodic Notes
  • Research: Citations, Annotator, Excalidraw
  • Writing: Longform, Linter
  • Sync: Obsidian Git or Remotely Save (see sync section below)

A reasonable daily-note template (write to Templates/Daily.md):

# {{date:YYYY-MM-DD}}

## Focus


## Notes


## Tomorrow

Design guidelines:

  • Start with a minimal folder structure that can grow organically — refactoring later is cheap.
  • Use frontmatter (tags:, status:, project:) for metadata the bot can filter on later.
  • Wikilinks ([[note]]) build the graph; encourage linking liberally.
  • Don't over-engineer.

Sync Your Vault Across Devices

Pick ONE sync method when the user asks to keep it in sync with their laptop or phone. Ask which they prefer if they don't say.

Method 1: Obsidian Headless Sync (paid, official, best fidelity)

Use when the user has an Obsidian Sync subscription. Syncs notes, settings, and plugins. Requires Node 22+ (already present).

npm install -g obsidian-headless
ob login                                  # device-code flow; user opens URL on their laptop
ob sync-list-remote                       # show their remote vaults; let user pick one
VAULT="${OBSIDIAN_VAULT_PATH:-${HERMES_HOME:+$HERMES_HOME/obsidian-vault}}"
VAULT="${VAULT:-$HOME/.openclaw/workspace/obsidian-vault}"
ob sync-setup --vault "<vault-name>" --path "$VAULT"
nohup ob sync --path "$VAULT" --continuous > "$VAULT/.sync.log" 2>&1 &

obsidian-headless is a global npm install in the image layer; after an image upgrade, re-run npm install -g obsidian-headless once.

Method 2: Obsidian Git (free, recommended for free users)

Use when the user wants free sync via a private GitHub repo. They must install the "Obsidian Git" community plugin on their desktop and push to a private repo first.

VAULT="${OBSIDIAN_VAULT_PATH:-${HERMES_HOME:+$HERMES_HOME/obsidian-vault}}"
VAULT="${VAULT:-$HOME/.openclaw/workspace/obsidian-vault}"
LEGACY="$HOME/.obsidian-vault"

# If the persistent path already has a non-git directory, archive it first.
if [ -d "$VAULT" ] && [ ! -d "$VAULT/.git" ]; then
  mv "$VAULT" "$VAULT.bak.$(date +%s)"
fi
git clone https://<github_pat>@github.com/<user>/<repo>.git "$VAULT"
cd "$VAULT"
git config user.email "<[email protected]>"
git config user.name "<User Name>"

# Always recreate the legacy symlink so older prompts still work
ln -snf "$VAULT" "$LEGACY"

# Pull every 5 minutes. Not every runtime ships crontab — Hermes does not, and
# exposes its own scheduler instead. Detect rather than fail silently.
PULL_CMD="cd \"$VAULT\" && git pull --rebase --autostash >> \"$VAULT/.gitsync.log\" 2>&1"
if command -v crontab >/dev/null 2>&1; then
  ( crontab -l 2>/dev/null; echo "*/5 * * * * $PULL_CMD" ) | crontab -
else
  echo "No crontab in this runtime. Schedule this every 5 minutes with your own scheduler:"
  echo "$PULL_CMD"
fi

Push Back to GitHub (when the bot writes notes)

Push runs immediately after each Obsidian-skill tool call that mutates the vault — no cron-only delay. Install a small helper script once:

VAULT="${OBSIDIAN_VAULT_PATH:-${HERMES_HOME:+$HERMES_HOME/obsidian-vault}}"
VAULT="${VAULT:-$HOME/.openclaw/workspace/obsidian-vault}"
mkdir -p "$VAULT/.bot"
# Derive the vault from the script's OWN location instead of baking a quoted
# path in: the helper lives at <vault>/.bot/sync-push.sh, so this is correct
# by construction, needs no environment, and cannot be broken by a space or
# an apostrophe in the path. The scheduler runs it with a minimal env that
# has no HERMES_HOME, so resolving from the environment would pick the wrong
# vault or exit 0 silently.
cat > "$VAULT/.bot/sync-push.sh" <<'EOF'
#!/bin/sh
set -eu
VAULT=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd -P) || exit 0
cd "$VAULT" 2>/dev/null || exit 0
git add -A
git diff --cached --quiet && exit 0
git commit -m "bot: ${1:-auto-commit}"
# flock -n: skip if another push is already in flight (background or cron)
flock -n "$VAULT/.git/.push.lock" git push >> "$VAULT/.gitsync.log" 2>&1 || true
EOF
chmod +x "$VAULT/.bot/sync-push.sh"

At the END of every mutating Obsidian tool call (write, append, update), invoke:

VAULT="${OBSIDIAN_VAULT_PATH:-${HERMES_HOME:+$HERMES_HOME/obsidian-vault}}"
VAULT="${VAULT:-$HOME/.openclaw/workspace/obsidian-vault}"
"$VAULT/.bot/sync-push.sh" "<one-line summary of the change>" &
disown 2>/dev/null || true

The & puts it in the background so the bot doesn't block on network. flock -n inside the helper makes overlapping calls safe — they no-op instead of fighting over the index.

Keep an hourly safety net in case a push was killed mid-flight (image upgrade, container restart, network blip):

VAULT="${OBSIDIAN_VAULT_PATH:-${HERMES_HOME:+$HERMES_HOME/obsidian-vault}}"
VAULT="${VAULT:-$HOME/.openclaw/workspace/obsidian-vault}"
if command -v crontab >/dev/null 2>&1; then
  ( crontab -l 2>/dev/null; echo "0 * * * * \"$VAULT/.bot/sync-push.sh\" hourly-retry" ) | crontab -
else
  echo "No crontab in this runtime. Schedule this hourly with your own scheduler:"
  echo "\"$VAULT/.bot/sync-push.sh\" hourly-retry"
fi

Configuration

Set the vault path explicitly to pin it for every later call. On Hermes: OBSIDIAN_VAULT_PATH=$HERMES_HOME/obsidian-vault (that is /opt/data/obsidian-vault). On OpenClaw: OBSIDIAN_VAULT_PATH=$HOME/.openclaw/workspace/obsidian-vault. Persist it where the runtime hands it to later tool calls; a bare shell export dies with the shell.

Search Notes

# Search note titles
find "{vault_path}" -name "*.md" | xargs grep -l "{query}" 2>/dev/null | head -10

# Full-text search with context
grep -rn --include="*.md" -C 2 "{query}" "{vault_path}" | head -50

Read a Note

cat "{vault_path}/{note_name}.md"

Find Backlinks

# Find all notes that link to a given note
grep -rl --include="*.md" "\[\[{note_name}\]\]" "{vault_path}" | head -20

List Recent Notes

find "{vault_path}" -name "*.md" -type f -mtime -7 | sort | head -20

List Tags

grep -roh --include="*.md" "#[a-zA-Z0-9_-]\+" "{vault_path}" | sort | uniq -c | sort -rn | head -20

Guidelines

  • Always verify the vault path exists before searching
  • Respect the user's note organization — don't modify notes without permission
  • When presenting search results, show note title and relevant context
  • For large vaults, use targeted searches rather than listing everything
  • Handle wikilinks ([[note]]) and tags (#tag) in Obsidian format
  • Summarize relevant notes rather than dumping full content