Agent skill
obsidian-plugin
Guide Obsidian plugin development following official guidelines. Use when creating/modifying Obsidian plugins, implementing commands, creating UI elements, or handling file operations.
Stars
163
Forks
31
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/data/obsidian-plugin
SKILL.md
INSTRUCTIONS
Develop Obsidian plugins following official best practices for security, API usage, and UI consistency.
Core Rules
- Use
this.app- Never use globalappobject (debugging only) - Minimize logging - Errors shown by default, not debug messages
- Build DOM safely - See
security.mdfor mandatory patterns - Use managed cleanup -
registerEvent(),addCommand()for auto-cleanup - Replace placeholders - Change
MyPlugin,SampleSettingTabto actual names
When to Use
Apply this skill when:
- Creating new Obsidian plugins
- Adding commands, settings, or views
- Handling file/folder operations
- Building plugin UI components
- Reviewing Obsidian plugin code
Project Structure
my-plugin/
├── main.ts # Plugin entry point
├── settings.ts # Settings tab and defaults
├── commands/ # Command handlers
├── views/ # Custom views
├── modals/ # Modal dialogs
└── styles.css # Plugin styles (use CSS variables)
Resource Management
Always use Obsidian's managed registration:
typescript
// ✅ GOOD: Auto-cleanup on plugin unload
this.registerEvent(
this.app.vault.on('create', (file) => { ... })
);
this.addCommand({
id: 'my-command',
name: 'My Command',
callback: () => { ... }
});
// ❌ BAD: Manual cleanup required (avoid)
this.app.vault.on('create', this.handler);
NEVER detach leaves in onunload() - Obsidian handles this automatically.
Key References
- Security: See
security.mdfor DOM manipulation rules (CRITICAL) - API Patterns: See
api-patterns.mdfor workspace, vault, and editor patterns - UI Components: See
ui-components.mdfor settings, modals, and views
Terminology (for Documentation)
| Use | Avoid |
|---|---|
| keyboard shortcut | hotkey |
| note | file (for .md) |
| folder | directory |
| select | click/tap |
| perform | invoke |
Use sentence case for headings. Bold button text in docs.
Quality Checklist
Before releasing a plugin:
- No
innerHTML,outerHTML, orinsertAdjacentHTMLusage - All events registered via
registerEvent() - User file paths normalized with
normalizePath() - CSS uses Obsidian variables, not hardcoded colors
- Settings have general options at top (no heading)
- Placeholder class names replaced with actual plugin name
- Minimal console logging (errors only)
Didn't find tool you were looking for?