← ClaudeAtlas

obsidian-api-basicslisted

This skill should be used when the user asks to "create an Obsidian plugin", "plugin lifecycle", "plugin settings", "vault API", "register command", "add ribbon icon", or mentions Obsidian plugin fundamentals like onload, onunload, saveData, or loadData.
hsb3/dotfiles-agents · ★ 0 · API & Backend · score 70
Install: claude install-skill hsb3/dotfiles-agents
# Obsidian API Basics Provides foundational guidance for building Obsidian plugins, covering the plugin lifecycle, settings patterns, vault operations, and command registration. ## Core Concepts ### Plugin Class Structure Every Obsidian plugin extends the `Plugin` base class and implements lifecycle methods: ```typescript import { Plugin } from 'obsidian'; export default class MyPlugin extends Plugin { async onload() { // Plugin initialization console.debug('Plugin loaded'); } async onunload() { // Cleanup console.debug('Plugin unloaded'); } } ``` **Critical rules:** - Keep `main.ts` small - delegate functionality to separate modules - Use `onload()` for initialization, registration, and setup - Use `onunload()` for cleanup (most cleanup happens automatically) - Never use the plugin instance as a Component to avoid memory leaks ### Settings Pattern Implement user-configurable settings with persistence: ```typescript interface MyPluginSettings { serverUrl: string; apiKey: string; enabled: boolean; } const DEFAULT_SETTINGS: MyPluginSettings = { serverUrl: 'http://localhost:3000', apiKey: '', enabled: true, }; export default class MyPlugin extends Plugin { settings: MyPluginSettings; async onload() { await this.loadSettings(); this.addSettingTab(new MySettingTab(this.app, this)); } async loadSettings() { this.settings = Object.assign({}, DEFAULT_SETTINGS, await this.loadData()); } async saveSettings() {