/obsidian-pack:obsidian-common-errorsfrom obsidian-pack
Diagnoses and fixes the six most common Obsidian plugin errors including workspace-not-ready, load failures, and manifest issues with copy-paste fixes.
Ships in obsidian-pack. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Diagnostic guide for the six most frequent Obsidian plugin development errors, with root causes and copy-paste fixes.
Accessing app.workspace.activeLeaf or app.workspace.getActiveViewOfType() before the layout is initialized returns null.
// BROKEN: accessing workspace immediately in onload
async onload() {
const view = this.app.workspace.getActiveViewOfType(MarkdownView);
// TypeError: Cannot read properties of null (reading 'editor')
view.editor.replaceSelection('hello');
}
// FIXED: wait for layout-ready event
async onload() {
this.app.workspace.onLayoutReady(() => {
const view = this.app.workspace.getActiveViewOfType(MarkdownView);
if (view) {
view.editor.replaceSelection('hello');
}
});
}
For commands that need workspace access later (not at load time), guard with a null check:
this.addCommand({
id: 'my-command',
name: 'Do Something',
checkCallback: (checking: boolean) => {
const view = this.app.workspace.getActiveViewOfType(MarkdownView);
if (view) {
if (!checking) {
// safe to use view.editor here
view.editor.replaceSelection('inserted');
}
return true;
}
return false;
}
});
This error appears in the console when Obsidian cannot parse your built main.js or your manifest.json is invalid.
Check 1: Build output exists and compiles cleanly
set -euo pipefail
npm run build 2>&1
# Look for TypeScript errors in output
ls -la main.js # Must exist in plugin root
Check 2: manifest.json has all required fields
{
"id": "my-plugin",
"name": "My Plugin",
"version": "1.0.0",
"minAppVersion": "0.15.0",
"description": "Does something useful",
"author": "Your Name",
"isDesktopOnly": false
}
Missing id, name, version, or minAppVersion causes a silent load failure. The id must match the folder name under .obsidian/plugins/.
Check 3: Default export
// BROKEN: named export
export class MyPlugin extends Plugin { ... }
// FIXED: default export required
export default class MyPlugin extends Plugin { ... }
Obsidian auto-loads styles.css from the plugin root directory. It must be named exactly styles.css (not style.css, not in a subdirectory).
set -euo pipefail
# Verify all three required files exist in plugin root
ls -la styles.css manifest.json main.js
If you use a CSS preprocessor, ensure the build outputs to ./styles.css:
{
"scripts": {
"build:css": "sass src/styles.scss styles.css",
"build": "npm run build:css && node esbuild.config.mjs"
}
}
Common gotcha: the file must be styles.css (plural), not style.css.
Commands registered outside onload() or after the plugin is enabled won't appear in the command palette.
// BROKEN: adding command in a separate method called conditionally
async onload() {
await this.loadSettings();
// command never added because registerCommands is not called
}
registerCommands() {
this.addCommand({ id: 'test', name: 'Test', callback: () => {} });
}
// FIXED: add all commands directly in onload
async onload() {
await this.loadSettings();
this.addCommand({
id: 'test',
name: 'Test',
callback: () => {
new Notice('Working!');
}
});
}
If a command should only be available when a markdown file is open, use editorCallback instead of callback — Obsidian automatically hides it when no editor is active:
this.addCommand({
id: 'editor-only',
name: 'Editor Only Command',
editorCallback: (editor: Editor) => {
editor.replaceSelection('inserted text');
}
});
vault.read() and vault.cachedRead() throw if the file doesn't exist. Always check first.
// BROKEN: assumes file exists
async readConfig() {
const content = await this.app.vault.adapter.read('config.json');
return JSON.parse(content);
}
// FIXED: check existence, handle missing file
async readConfig(): Promise<MyConfig> {
const path = 'config.json';
const exists = await this.app.vault.adapter.exists(path);
if (!exists) {
return { ...DEFAULT_CONFIG };
}
try {
const content = await this.app.vault.adapter.read(path);
return JSON.parse(content);
} catch (e) {
console.error('Failed to parse config:', e);
return { ...DEFAULT_CONFIG };
}
}
For vault files (TFile objects), use getAbstractFileByPath:
const file = this.app.vault.getAbstractFileByPath('notes/target.md');
if (file instanceof TFile) {
const content = await this.app.vault.read(file);
// process content
} else {
new Notice('File not found: notes/target.md');
}
The most common settings bug: modifying the settings object without calling saveData.
// BROKEN: settings change lost on restart
this.settings.theme = 'dark';
// forgot to call saveData!
// FIXED: always save after modifying
this.settings.theme = 'dark';
await this.saveData(this.settings);
In settings tabs, save on every change:
new Setting(containerEl)
.setName('Theme')
.addDropdown(dropdown => dropdown
.addOption('light', 'Light')
.addOption('dark', 'Dark')
.setValue(this.plugin.settings.theme)
.onChange(async (value) => {
this.plugin.settings.theme = value;
await this.plugin.saveSettings(); // calls this.saveData(this.settings)
}));
Load settings with defaults to prevent undefined fields after plugin updates:
async loadSettings() {
// loadData() returns null on first run — Object.assign handles this safely
this.settings = Object.assign({}, DEFAULT_SETTINGS, await this.loadData());
}
Object.assign merges saved data over defaults, so new fields added in later versions get their default value instead of undefined.
| Error | Cause | Solution |
|---|---|---|
TypeError: Cannot read properties of null | Workspace not ready | Use onLayoutReady or null-check |
Plugin failed to load | Build error or bad manifest | Check console, verify manifest.json fields |
| CSS has no effect | Wrong filename or path | Must be styles.css in plugin root |
| Command missing from palette | Not added in onload() | Move addCommand into onload |
Error: ENOENT on vault read | File doesn't exist | Check with adapter.exists() first |
| Settings reset on restart | Missing saveData call | Call saveData after every mutation |
When a plugin fails to load, check these in order:
main.js, manifest.json, and styles.css exist in plugin foldermanifest.json has id, name, version, minAppVersionmain.ts uses export default classnpm run build and reload Obsidian (Ctrl/Cmd+R)// Add to your plugin class for temporary debugging
private debug(msg: string, ...args: any[]) {
if (this.settings.debugMode) {
console.log(`[${this.manifest.id}] ${msg}`, ...args);
}
}
For comprehensive debugging workflows, see obsidian-debug-bundle.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
24 skills in this plugin
/obsidian-ci-integrationSet up GitHub Actions CI/CD for Obsidian plugin development.
Use when automating builds, tests, and releases for your plugin,
or setting up continuous integration for Obsidian projects.
Trigger with phrases like "obsidian CI", "obsidian github actions",
"obsidian automated build", "obsidian CI/CD".
/obsidian-core-workflow-aCreate an Obsidian plugin from scratch with full project scaffolding.
Covers Plugin class, ribbon icons, commands, settings tab, esbuild config,
manifest.json, and building/testing. Use when starting a new plugin,
scaffolding a project, or learning the plugin lifecycle.
Trigger with "create obsidian plugin", "scaffold obsidian plugin",
"new obsidian plugin", "obsidian plugin from scratch".
/obsidian-core-workflow-bBuild advanced Obsidian plugin features: custom views (ItemView), modals,
editor commands with selection manipulation, status bar, context menus,
and Vault API file creation/modification. Use when adding UI components
to a plugin, building sidebar views, or creating modal dialogs.
Trigger with "obsidian modal", "obsidian custom view", "obsidian sidebar",
"obsidian context menu", "obsidian editor command", "obsidian UI".
/obsidian-cost-tuningOptimize Obsidian resource usage, sync storage, Publish hosting, and
third-party plugin API costs. Use when managing vault size, reducing
Sync bandwidth, controlling Publish costs, or optimizing external API
consumption from community plugins.
Trigger with phrases like "obsidian costs", "obsidian sync storage",
"optimize obsidian", "reduce obsidian costs", "obsidian publish costs".
/obsidian-data-handlingImplement vault data backup, sync, and recovery strategies.
Use when building backup features, implementing data export,
or handling vault synchronization in your plugin.
Trigger with phrases like "obsidian backup", "obsidian sync",
"obsidian data export", "vault backup strategy".
/obsidian-debug-bundleCollect Obsidian plugin debug evidence for support and troubleshooting.
Use when encountering persistent issues, preparing bug reports,
or collecting diagnostic information for plugin problems.
Trigger with phrases like "obsidian debug", "obsidian diagnostic",
"collect obsidian logs", "obsidian support bundle".
npx claudepluginhub flight505/skill-forge --plugin obsidian-packOther plugins' skills for the same job