obsidian-sdk-patterns

Featured

Production-ready Obsidian plugin patterns: typed settings with migration, safe vault operations, event auto-cleanup, workspace layout, metadata cache, and debounced file handlers. Use when hardening a plugin for release, refactoring for reliability, or learning idiomatic Obsidian TypeScript. Trigger with "obsidian patterns", "obsidian best practices", "obsidian production code", "idiomatic obsidian plugin".

AI & Automation 2,944 stars 440 forks Updated today MIT

Install

View on GitHub

Quality Score: 99/100

Stars 20%
100
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# Obsidian SDK Patterns ## Overview Six production patterns that prevent the most common Obsidian plugin bugs: lost settings on upgrade, null-reference crashes on deleted files, memory leaks from unregistered events, stale metadata, and UI jank from rapid file changes. Each pattern is self-contained and copy-pasteable. ## Prerequisites - A working Obsidian plugin (see `obsidian-core-workflow-a`) - TypeScript strict mode enabled (`"strictNullChecks": true` in tsconfig) - Familiarity with `Plugin.onload()` / `onunload()` lifecycle ## Instructions ### Step 1: Typed settings with versioned migration Settings break when you add or rename fields between releases. Version the settings object and migrate on load so existing users keep their data. ```typescript // src/settings.ts interface PluginSettingsV1 { apiKey: string; interval: number; } interface PluginSettingsV2 { version: 2; apiKey: string; syncInterval: number; // renamed from "interval" excludedFolders: string[]; // new field theme: "default" | "minimal"; } // Current version is always the latest type PluginSettings = PluginSettingsV2; const DEFAULTS: PluginSettings = { version: 2, apiKey: "", syncInterval: 300, excludedFolders: [], theme: "default", }; export async function loadSettings(plugin: Plugin): Promise<PluginSettings> { const raw = (await plugin.loadData()) as any; if (!raw) return { ...DEFAULTS }; // Migrate v1 -> v2 if (!raw.version || raw.version < 2) { raw....

Details

Author
jeremylongshore
Repository
jeremylongshore/claude-code-plugins-plus-skills
Created
1 years ago
Last Updated
today
Language
Python
License
MIT

Integrates with

Bundled in these plugins

Similar Skills

Semantically similar based on skill content — not just same category