Comprehensive toolkit for building Obsidian plugins with TypeScript...
Comprehensive toolkit for creating, building, and deploying Obsidian plugins.
This skill provides everything needed to develop Obsidian plugins, from initial project setup to production deployment. It includes automated scripts for project initialization, practical API usage guides, comprehensive reference documentation, and best practices for plugin development.
Use the initialization script to create a new plugin project:
./scripts/init_plugin.sh my-plugin ./my-plugin
cd my-plugin
This automatically creates:
Link your plugin to an Obsidian vault for live development:
./scripts/setup_dev_env.sh . ~/path/to/vault
npm run dev
Then in Obsidian:
Scripts:
scripts/init_plugin.sh - Create new plugin project with complete setupscripts/setup_dev_env.sh - Link plugin to Obsidian vault for developmentWhen to use: Starting a new plugin project or setting up development environment.
Primary guide: references/api_guide.md contains practical examples for:
When to use: Implementing plugin features or working with Obsidian APIs.
Quick example - Creating a file:
async createNote(filename: string, content: string): Promise<TFile> {
const file = await this.app.vault.create(`${filename}.md`, content);
return file;
}
Quick example - Adding a command:
this.addCommand({
id: 'my-command',
name: 'My Command',
callback: () => {
console.log('Command executed');
}
});
For detailed API reference: See references/api_reference.md for comprehensive documentation of all Obsidian API classes and methods.
Guide: references/build_deploy.md covers:
When to use: Building for production, setting up CI/CD, or preparing for plugin release.
Quick commands:
npm run dev # Development build with watch mode
npm run build # Production build
Guide: references/best_practices.md includes:
When to use: Ensuring plugin quality, reviewing code, or learning proper patterns.
The assets/ directory contains template files for common plugin components:
custom-view-template.ts - Template for custom viewsmodal-template.ts - Template for modal dialogsstyles-template.css - Template for plugin stylesWhen to use: Copy and modify these templates when implementing custom UI components.
init_plugin.shthis.addCommand({
id: 'my-command',
name: 'My Command',
callback: () => {
new Notice('Command executed!');
}
});
npm run devRefer to references/api_guide.md for examples:
app.vault.read(file)app.vault.modify(file, newContent)app.vault.getMarkdownFiles()references/api_guide.md ā "Settings" section for complete exampleassets/custom-view-template.tsthis.registerView(
VIEW_TYPE_EXAMPLE,
(leaf) => new ExampleView(leaf)
);
references/api_guide.md for more detailsnpm install to update dependenciesnpm run dev)references/api_guide.md - Practical examples for all common operationsreferences/api_reference.md - Complete API documentationreferences/build_deploy.md - Build, test, and deploy workflowsreferences/best_practices.md - Code quality and patternsOrganize plugin code by concern:
src/
āāā main.ts # Plugin entry point
āāā settings.ts # Settings tab
āāā commands/ # Command handlers
āāā modals/ # Modal dialogs
āāā views/ # Custom views
āāā utils/ # Utility functions
Before submitting to Community Plugins:
npm run build)references/best_practices.mdFor complete publishing process, see references/build_deploy.md ā "Publishing" section.
registerEvent() for automatic cleanupNotice for operations