/obsidian-pack:obsidian-upgrade-migrationfrom obsidian-pack
Migrates Obsidian plugins between API versions, handling breaking changes, settings migration, and manifest updates. Use when upgrading Obsidian plugin code.
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.
!npm list 2>/dev/null | head -20
!cat manifest.json 2>/dev/null || echo 'No manifest.json in cwd'
Upgrade an Obsidian plugin between versions: migrate persisted settings with version checks, replace deprecated API calls, update manifest.json minAppVersion, and test across Obsidian releases.
manifest.json and versions.jsonCheck what your plugin currently targets and what the user's Obsidian version requires:
# Current plugin target
echo "=== manifest.json ==="
cat manifest.json | python3 -c "
import json, sys
m = json.load(sys.stdin)
print(f\"Plugin: {m['id']} v{m['version']}\")
print(f\"minAppVersion: {m['minAppVersion']}\")
"
# Current obsidian type definitions
echo "=== obsidian package version ==="
npm ls obsidian 2>/dev/null || echo "Not found in node_modules"
# Check versions.json for version history
echo "=== versions.json ==="
cat versions.json 2>/dev/null | python3 -m json.tool || echo "No versions.json"
# Update to latest obsidian types
npm install obsidian@latest --save-dev
# Check what changed
npm diff obsidian 2>/dev/null | head -100
Then check for TypeScript errors against the new types:
npx tsc --noEmit 2>&1 | head -50
Every error here is a breaking change you need to address.
Implement a version-aware loadData() pattern so existing users' settings survive upgrades:
interface PluginSettings {
_version: number; // Internal schema version
// v1 fields
enabled: boolean;
// v2 fields (added in plugin v2.0.0)
syncInterval: number;
// v3 fields (added in plugin v3.0.0)
theme: 'light' | 'dark' | 'system';
}
const CURRENT_SETTINGS_VERSION = 3;
const DEFAULT_SETTINGS: PluginSettings = {
_version: CURRENT_SETTINGS_VERSION,
enabled: true,
syncInterval: 300,
theme: 'system',
};
async loadSettings(): Promise<PluginSettings> {
const raw = await this.loadData();
if (!raw) return { ...DEFAULT_SETTINGS };
const version = raw._version ?? 1;
let settings = { ...raw };
// v1 -> v2: add syncInterval
if (version < 2) {
settings.syncInterval = DEFAULT_SETTINGS.syncInterval;
console.log('[your-plugin] Migrated settings v1 -> v2');
}
// v2 -> v3: add theme, rename old field
if (version < 3) {
settings.theme = DEFAULT_SETTINGS.theme;
// Rename deprecated field
if ('darkMode' in settings) {
settings.theme = settings.darkMode ? 'dark' : 'light';
delete settings.darkMode;
}
console.log('[your-plugin] Migrated settings v2 -> v3');
}
settings._version = CURRENT_SETTINGS_VERSION;
await this.saveData(settings); // Persist the migration
return settings as PluginSettings;
}
Common deprecations and their replacements:
Vault API changes:
// DEPRECATED: vault.modify with string path
await this.app.vault.modify(filePath, content);
// REPLACEMENT: use TFile object
const file = this.app.vault.getAbstractFileByPath(filePath);
if (file instanceof TFile) {
await this.app.vault.modify(file, content);
}
// DEPRECATED: vault.create returns void in older versions
this.app.vault.create(path, content);
// REPLACEMENT: returns TFile, handle it
const newFile = await this.app.vault.create(path, content);
Event registration changes:
// DEPRECATED: workspace.on('file-open') with old signature
this.app.workspace.on('file-open', (file) => { ... });
// REPLACEMENT: use registerEvent for proper cleanup
this.registerEvent(
this.app.workspace.on('file-open', (file) => { ... })
);
Editor API (CodeMirror 5 to 6 migration):
// DEPRECATED: accessing CM5 editor instance
const cm = (editor as any).cm;
cm.getValue(); // CM5
// REPLACEMENT: use Obsidian's Editor interface
const content = editor.getValue();
const cursor = editor.getCursor();
editor.replaceRange(text, cursor);
// For CM6-specific features, use EditorView extension:
import { EditorView, ViewPlugin } from '@codemirror/view';
this.registerEditorExtension(
ViewPlugin.fromClass(class {
constructor(view: EditorView) {
// CM6 view access
}
})
);
FileManager changes:
// DEPRECATED: processFrontMatter sync signature
this.app.fileManager.processFrontMatter(file, (fm) => {
fm.tags = ['updated'];
});
// REPLACEMENT: async signature (Obsidian 1.4+)
await this.app.fileManager.processFrontMatter(file, (fm) => {
fm.tags = ['updated'];
});
Bump minAppVersion to the lowest Obsidian version that supports all APIs you use:
{
"id": "your-plugin",
"name": "Your Plugin",
"version": "3.0.0",
"minAppVersion": "1.5.0",
"description": "...",
"author": "...",
"isDesktopOnly": false
}
Update versions.json to map your plugin version to the minimum Obsidian version:
{
"1.0.0": "0.15.0",
"2.0.0": "1.0.0",
"3.0.0": "1.5.0"
}
Build and verify:
# Clean build
rm -rf dist node_modules/.cache
npm install
npm run build
# Check for type errors
npx tsc --noEmit
# Check bundle for leftover deprecated calls
grep -rn 'cm\.getValue\|processFrontMatter.*sync\|vault\.modify.*string' src/ || echo "No deprecated patterns found"
Manual testing checklist:
minAppVersion you declared -- confirm it loads without errorsdata.json from an older version into the plugin directory, reload, verify settings are preserved and upgraded# Update version in package.json and manifest.json
npm version major # or minor/patch
# Ensure versions.json includes the new mapping
python3 -c "
import json
v = json.load(open('versions.json'))
m = json.load(open('manifest.json'))
v[m['version']] = m['minAppVersion']
json.dump(v, open('versions.json', 'w'), indent=2)
print(f\"Added {m['version']} -> {m['minAppVersion']}\")
"
# Build the release artifacts
npm run build
manifest.json with correct minAppVersionversions.json with new version mappingtsc --noEmit with no type errors| Error | Cause | Solution |
|---|---|---|
Property does not exist on type 'Plugin' | API removed in newer obsidian types | Check changelog for replacement API |
Cannot find module 'obsidian' | Types not installed | npm install obsidian@latest --save-dev |
| Settings lost after upgrade | No migration logic for _version jump | Add migration step for each version gap |
TypeError: x is not a function at runtime | API exists in types but not in user's Obsidian | Lower minAppVersion or add runtime version check |
| Plugin loads but features missing | Feature flag not migrated | Check settings migration covers all paths |
Simple version bump: Plugin works fine on new Obsidian, just need to update minAppVersion. Run Step 1 to audit, Step 5 to update manifest, Step 6 to verify.
CodeMirror 5 to 6 migration: Plugin uses editor.cm for custom decorations. Replace CM5 Decoration with CM6 EditorView extensions per Step 4. This is the most common large migration.
Settings schema change: Plugin v2 renamed darkMode: boolean to theme: 'light' | 'dark' | 'system'. Add migration in Step 3 that maps the old boolean to the new enum, preserving user preference.
For CI/CD to automate release testing, see obsidian-ci-integration. For multi-environment testing, see obsidian-multi-env-setup.
What SKILL.md sets; muted values are Claude Code's defaults
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-common-errorsDiagnose and fix common Obsidian plugin errors and exceptions.
Use when encountering plugin errors, debugging failed operations,
or troubleshooting Obsidian plugin issues.
Trigger with phrases like "obsidian error", "fix obsidian plugin",
"obsidian not working", "debug obsidian plugin".
/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".
npx claudepluginhub flight505/skill-forge --plugin obsidian-packOther plugins' skills for the same job