obsidian-pkm-plugin
CLAUDE.md13 starsChanged 10 months agoMITView on GitHub
This is a Claude Code plugin that provides an MCP server and supporting tools for bidirectional knowledge flow between Claude Code and an Obsidian vault. It packages 20 MCP tools, Claude Code hooks, and a setup skill under the vault-pkm plugin identity. The project consists of three parts: MCP Server: A Node.js ES module server implementing the Model Context Protocol. The main entry point is index.js (tool definitions and request routing), with pure helper functions extracted to helpers.js. It provides…
- Reads credentials
- Installs packages
In this repository7 other files it gives its agents.
- sample-project/CLAUDE.mdCLAUDE.md
- add-taskSkill
- pkm-exploreSkill
- pkm-session-endSkill
- pkm-writeSkill
- tackle-taskSkill
- triage-tasksSkill
The file
We split this CLAUDE.md into the rules it gives an agent
8 rules. About 0 are common, 2 are distinctive, and 6 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 162
Add annotated wikilinks to a note's section with deduplication.
- Very specific: line 222
Read-only tools (vault_read, vault_peek, vault_links, vault_neighborhood, vault_suggest_links) support fuzzy path resolution:
- Very specific: line 227
Use a more specific path or the folder param to disambiguate
- Very specific: line 234
Write/destructive tools (vault_write, vault_append, vault_edit, vault_update_frontmatter, vault_trash, vault_move, vault_add_links) require …
- Very specific: line 302
All notes use YAML frontmatter with type, status, created fields
- Distinctive: line 310
When creating ANY note via MCP, ALWAYS include frontmatter:
- Very specific: line 329
Document decisions, research findings, and debugging sessions as you work.
- Very specific: line 331
Use vault-pkm:pkm-explore to research what the vault already knows about a topic before creating new content.
≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
PKM: 01-Projects/Obsidian-MCP
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Project Overview
This is a Claude Code plugin that provides an MCP server and supporting tools for bidirectional knowledge flow between Claude Code and an Obsidian vault. It packages 20 MCP tools, Claude Code hooks, and a setup skill under the vault-pkm plugin identity.
Commands
# Install dependencies
npm install
# Run the MCP server (for testing)
VAULT_PATH="/path/to/your/vault" node cli.js
# Vault scaffolding wizard (templates, PARA folders)
node cli.js init
# Start the server
npm start
# Run unit tests
npm test
# Run linter
npm run lintArchitecture
The project consists of three parts:
MCP Server: A Node.js ES module server implementing the Model Context Protocol. The main entry point is index.js (tool definitions and request routing), with pure helper functions extracted to helpers.js. It provides 20 tools for vault interaction:
vault_read- Read note contents (supports pagination:heading,tail,tail_sections[with optionalsection_levelparam, default: 2],chunk,lines; auto-redirects to peek data for files >80k chars;forcebypasses redirect)vault_peek- Inspect file metadata/structure without reading full content (size, frontmatter, indented heading tree, preview)vault_write- Create new notes from templates (enforces frontmatter; settable fields:status,priority,project,deciders,due,source;variablesparam for custom<%...%>substitution in template body)vault_append- Add content to existing files, with optional positional insert (after/before heading, end of section)vault_edit- Surgical string replacement (exact match, single occurrence)vault_update_frontmatter- Update YAML frontmatter fields atomically (set, create, remove fields)vault_search- Full-text search across markdown filesvault_semantic_search- Semantic similarity search using OpenAI embeddings (requiresVAULT_PKM_OPENAI_KEYorOPENAI_API_KEY)vault_suggest_links- Suggest relevant notes to link based on content similarity;graph_context: truefor graph-semantic blending (requiresVAULT_PKM_OPENAI_KEYorOPENAI_API_KEY)vault_list/vault_recent- Directory listing and recent filesvault_links- Wikilink analysis ([[...]]syntax)vault_neighborhood- Graph context exploration via BFS wikilink traversalvault_query- Query notes by YAML frontmatter (type, status,tags[ALL must match],tags_any[ANY must match], dates,custom_fieldsfor arbitrary field matching,sort_by/sort_orderfor result ordering)vault_tags- Discover all tags with per-note counts; supports folder scoping, glob patterns, inline#tagparsingvault_activity- Query/clear activity log (all tool calls with timestamps and session IDs)vault_trash- Soft-delete to.trash/(Obsidian convention), warns about broken incoming linksvault_move- Move/rename files with automatic wikilink updating across vault (update_links: falseto skip)vault_add_links- Add annotated wikilinks to a note's section with deduplication (default: ## Related)vault_link_health- Graph health report: orphans, broken links, weakly connected notes, ambiguous links
The server uses VAULT_PATH environment variable (defaults to ~/Documents/PKM) and includes path security to prevent directory escaping. Optional VAULT_PKM_VAULT_NAME overrides the vault name embedded in obsidian:// links in tool output (defaults to basename(VAULT_PATH)); set this only when the on-disk folder name differs from the vault name registered in Obsidian.
vault_neighborhood (Graph Context Exploration)
Explores the graph neighborhood around a note by traversing wikilinks using BFS. Returns notes grouped by hop distance with frontmatter metadata.
- Resolves wikilink targets to actual file paths (handles
[[note]],[[folder/note]],[[note|alias]],[[note#heading]]) - Detects ambiguous links (multiple files with same basename) and annotates them
- Per-call indexes: basename resolution map + incoming link index (no persistent state)
- Params:
path(required),depth(default: 2),direction("both"|"outgoing"|"incoming"),include_semantic(boolean, appends unlinked semantic results),semantic_limit(default: 5) - Implementation:
graph.jsmodule (link resolution, BFS traversal, formatting)
vault_semantic_search (Semantic Similarity Search)
Finds conceptually related notes even when they use different terminology. For example, searching "managing overwhelm" finds notes about "cognitive load" or "information overload".
- Requires
VAULT_PKM_OPENAI_KEYorOPENAI_API_KEYenv var — tool is hidden from tool list when not set - Uses OpenAI
text-embedding-3-large(3072 dimensions) - Index stored at
$VAULT_PATH/.obsidian/semantic-index.db(SQLite + sqlite-vec) - Background
fs.watchkeeps index fresh; startup sync catches changes made while server was stopped - Chunking: whole-note for short notes, heading-based (
##) splits for notes > ~2000 tokens - Params:
query(required),limit,folder,threshold(0-1 similarity score),anchor(optional path for graph-distance weighting),graph_weight(0-1, default: 0.3)
// Graph-weighted search biased toward a specific note's neighborhood
vault_semantic_search({ query: "cache eviction strategies", anchor: "research/caching.md", graph_weight: 0.3 })The semantic index is a regenerable cache — deleting semantic-index.db triggers a full re-embed on next startup. The DB syncs across machines via Obsidian Sync (stored in .obsidian/).
vault_write (Template-Based Note Creation)
Notes must be created from templates to ensure proper frontmatter. The tool:
- Loads templates from
05-Templates/at startup - Auto-substitutes
<% tp.date.now("YYYY-MM-DD") %>and<% tp.file.title %> - Accepts
frontmatterparam for tags and other fields (status,priority,project,deciders,due,source) - Validates required fields:
type,created,tags - Validates enum fields for task notes:
status(pending/active/done/cancelled),priority(low/normal/high/urgent) - Errors if file already exists (use
vault_editorvault_appendto modify)
Examples:
vault_write({
template: "adr",
path: "01-Projects/MyApp/development/decisions/ADR-001-database.md",
frontmatter: { tags: ["decision", "database"], deciders: "Team" }
})
vault_write({
template: "task",
path: "01-Projects/MyApp/planning/task-api-refactor.md",
frontmatter: { tags: ["task", "api"], priority: "high", project: "MyApp", due: "2026-03-01" }
})vault_activity (Session Memory / Activity Log)
Logs all MCP tool calls with timestamps and session IDs. Enables cross-session memory — Claude can recall what was read, written, or searched in previous sessions.
- Storage: SQLite DB at
$VAULT_PATH/.obsidian/activity-log.db(separate from semantic index) - Session ID: generated via
crypto.randomUUID()at MCP server startup (each conversation gets its own) - Logs every tool call except
vault_activityitself - Supports filtering by tool name, session ID, date range, and path substring
- Privacy:
action: "clear"deletes entries (with optional filters), or delete the DB file
vault_activity() // Recent 50 entries
vault_activity({ tool: "vault_write" }) // Only writes
vault_activity({ session: "abc12345" }) // Filter by session ID prefix
vault_activity({ since: "2026-02-08" }) // Today's activity
vault_activity({ path: "01-Projects/MyApp" }) // Activity on specific project
vault_activity({ action: "clear" }) // Clear all history
vault_activity({ action: "clear", before: "2026-01-01" }) // Clear old entriesImplementation: activity.js (ActivityLog class)
vault_update_frontmatter (Atomic Frontmatter Updates)
Safely updates YAML frontmatter fields in an existing note without touching the body content. Parses existing frontmatter, applies changes, and writes back.
- Set fields to new values, add new fields, or remove fields by setting to
null - Protected fields (
type,created,tags) cannot be removed (only updated) - Arrays (like
tags) are replaced wholesale - Enum validation: task
statusmust be one ofpending,active,done,cancelled; taskprioritymust be one oflow,normal,high,urgent— non-task types are unconstrained - Requires exact path (no fuzzy resolution — destructive operation)
vault_update_frontmatter({
path: "01-Projects/MyApp/planning/task-api-refactor.md",
fields: { status: "active", priority: "urgent" }
})
// Remove a field by setting to null
vault_update_frontmatter({
path: "01-Projects/MyApp/planning/task-api-refactor.md",
fields: { due: null } // removes the due field
})Implementation: updateFrontmatter pure function in helpers.js, handler in handlers.js
vault_add_links (Atomic Link Insertion)
Add annotated wikilinks to a note's section with deduplication. Validates targets exist, skips duplicates by basename (case-insensitive). Creates the section if missing.
- Requires exact path (no fuzzy resolution — destructive operation)
- Deduplicates by basename:
[[note]]won't be added if[[note]]or[[folder/note]]already in file - Section insertion point: end of section (before next same-or-higher heading, or EOF)
| Parameter | Type | Description |
path | string | Exact vault-relative path (required) |
links | array | Links to add: [{ target, annotation }] (required) |
section | string | Target section heading (default: ## Related) |
create_section | boolean | Create section if missing (default: true) |
vault_add_links({
path: "research/caching.md",
links: [
{ target: "decisions/ADR-003-caching.md", annotation: "supersedes this earlier approach" },
{ target: "research/architecture-patterns.md", annotation: "foundational patterns referenced" }
]
})vault_link_health (Graph Health Report)
Audit link quality across the vault or a specific folder. Returns categorized report of link issues.
- orphans: Notes with zero incoming AND zero outgoing wikilinks
- broken: Wikilinks that resolve to no existing file
- weak: Notes with only 1 total resolved link (incoming + outgoing; broken links don't count)
- ambiguous: Wikilinks where basename resolves to multiple files
| Parameter | Type | Description |
folder | string | Optional: scope to folder (fuzzy resolution supported) |
checks | array | Which checks: orphans, broken, weak, ambiguous (default: all) |
limit | number | Max results per category (default: 20) |
vault_link_health({ folder: "01-Projects/MyApp", checks: ["orphans", "broken"] })Implementation: handleLinkHealth in handlers.js, uses buildIncomingIndex from graph.js for O(M) performance.
vault_query (Enhanced Filtering and Sorting)
In addition to the standard filters (type, status, tags [ALL must match], tags_any [ANY must match], dates, folder), vault_query supports:
custom_fields— filter by arbitrary frontmatter fields (exact match); usenullto match notes where a field is missingsort_by— sort results by any frontmatter field; smart ordering for priority (urgent > high > normal > low), chronological for dates, alphabetical otherwise; nulls sort lastsort_order—"asc"(default) or"desc"
vault_query({ type: "task", custom_fields: { priority: "high" }, sort_by: "due" })
vault_query({ tags: ["task"], sort_by: "priority", sort_order: "asc" })
vault_query({ custom_fields: { project: "MyApp", due: null } }) // tasks with no due dateFuzzy Path Resolution
Read-only tools (vault_read, vault_peek, vault_links, vault_neighborhood, vault_suggest_links) support fuzzy path resolution:
- Exact paths still work as before (zero overhead)
- Short names resolve by basename:
"devlog"→"01-Projects/MyApp/development/devlog.md" .mdextension is optional:"devlog"and"devlog.md"both work- Ambiguous names (multiple files with same basename) return an error listing all candidates
- Use a more specific path or the
folderparam to disambiguate
Folder-scoped tools (vault_list, vault_search, vault_query, vault_tags, vault_recent, vault_link_health) support fuzzy folder resolution:
- Exact folder paths still work as before
- Partial names match by substring:
"MyApp"→"01-Projects/MyApp" - Ambiguous matches return an error listing candidates
Write/destructive tools (vault_write, vault_append, vault_edit, vault_update_frontmatter, vault_trash, vault_move, vault_add_links) require exact paths to prevent accidental modifications.
Implementation: helpers.js (buildBasenameMap, resolveFuzzyPath, resolveFuzzyFolder)
PKM Agents
The plugin provides 3 specialized agents (visible in /agents). Delegate to them proactively:
| Agent | When to Delegate | Mode |
vault-explorer | Before creating notes on a topic, when researching existing knowledge | Foreground |
pkm-capture | After git commits (automatic via hook), after significant work blocks, before session ends | Background |
link-auditor | After creating/modifying multiple vault notes, periodic health checks | Background |
pkm-capture context: When delegating, include whether this is the first capture this session or a subsequent one (with previous entry timestamp). The agent discovers the transcript path itself. It handles both devlog entries and knowledge capture (decisions, research, tasks, bugs) in one pass. Conservative — most exchanges produce nothing worth capturing beyond the devlog entry.
Templates (templates/): Obsidian note templates for project documentation:
project-index.md- Project overview with YAML frontmatteradr.md- Architecture Decision Record formatdevlog.md- Development log with session entriespermanent-note.md- Atomic evergreen notesresearch-note.md- Research findings and analysistroubleshooting-log.md- Bug investigations and fixesfleeting-note.md- Quick captures and temporary thoughtsliterature-note.md- Notes on articles, books, talksmeeting-notes.md- Meeting recordsmoc.md- Maps of Content (index/hub notes)daily-note.md- Daily notestask.md- Structured task notes with status, priority, due date, project, and source fieldsnote.md- Minimal generic note
Sample CLAUDE.md (sample-project/CLAUDE.md): Template for code repositories to specify PKM integration paths, context loading, and documentation rules.
Claude Code Configuration
claude plugin marketplace add anthropics/claude-plugins-community
claude plugin install vault-pkm@claude-communityThen run /vault-pkm:setup in Claude Code to configure vault path, API keys, and permissions.
For vault scaffolding (templates, PARA folders): npx obsidian-pkm init
VAULT_PKM_OPENAI_KEY (or OPENAI_API_KEY) is optional — without it, all tools except vault_semantic_search and vault_suggest_links work normally. The plugin-scoped name avoids conflicts with project-level OpenAI keys. OBSIDIAN_PKM_OPENAI_KEY is still read as a deprecated fallback for users who configured it before the rename.
Vault Structure Convention
Vault/
├── 00-Inbox/
├── 01-Projects/ # Active projects
│ └── ProjectName/
│ ├── _index.md
│ ├── planning/
│ ├── research/
│ └── development/decisions/
├── 02-Areas/
├── 03-Resources/Development/ # Reusable knowledge
├── 04-Archive/
├── 05-Templates/
└── 06-System/Key Conventions
- ADR naming:
ADR-{NNN}-{kebab-title}.md - Project index files:
_index.md - All notes use YAML frontmatter with
type,status,createdfields - Paths passed to MCP tools are relative to vault root
- Version bumps must update BOTH files:
package.jsonAND.claude-plugin/plugin.json. The plugin system reads version fromplugin.json, notpackage.json— forgettingplugin.jsoncauses updates to appear stuck.
Metadata Schema
Canonical reference: 06-System/metadata-schema.md
When creating ANY note via MCP, ALWAYS include frontmatter:
---
type: <type> # Required: see schema for allowed values
created: YYYY-MM-DD # Required
tags: [...] # Required: at least one tag
status: <status> # If applicable for the type
---Common types: fleeting, research, adr, bug, planning, transcript, permanent, task
Never create notes without frontmatter — even quick research docs or ad-hoc files.
PKM Integration
- Vault project:
01-Projects/Obsidian-MCP/ - MCP Server:
vault-pkmplugin
Document decisions, research findings, and debugging sessions as you work. The pkm-capture agent captures devlog entries and PKM-worthy content in the background (triggered automatically after git commits), or use the vault-pkm:pkm-write skill for structured notes with linking.
Use vault-pkm:pkm-explore to research what the vault already knows about a topic before creating new content.
At the end of each session, run vault-pkm:pkm-session-end to update the devlog and capture undocumented work.
Use vault-pkm:triage-tasks to surface and batch-update open task statuses (numbered list, shorthand input like "1,3 done | 2 active"). Use vault-pkm:add-task for fast task capture from the conversation. Use vault-pkm:tackle-task to work on a specific task end-to-end: reads the note, explores vault context, routes to the right workflow (trivial/standard/significant), and closes the task when done.
Referring to vault files
Whenever you mention a vault note, PKM file, or file inside 01-Projects/Obsidian-MCP/ in your response to the user — whether quoting tool output, summarizing what you read, or referring to a file by name — format it as a markdown link to its obsidian:// URI so the user can click to open it in Obsidian:
[01-Projects/Obsidian-MCP/some/note.md](obsidian://open?vault=PKM&file=01-Projects%2FObsidian-MCP%2Fsome%2Fnote)
Encoding rules: percent-encode / as %2F and spaces as %20. Strip the trailing .md from the URL file= parameter, but keep .md in the visible link text. The vault name (PKM) is also visible in any vault-pkm tool output.
The vault-pkm MCP tools already emit paths in this format. Preserve the link form when relaying; don't revert to bare paths like 01-Projects/Obsidian-MCP/... for inline mentions. Apply the same format proactively when mentioning a vault file you haven't just queried (e.g., when answering "what's in the devlog?" or "see ADR-002").
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

