From lazycortex-obsidian
Scaffold the Obsidian render glue for the lazycortex-diagram engine into a vault: install the `mermaid-fit.css` and `ascii-fit.css` snippets, enable them in `appearance.json`, and install the `mermaid-popup` community plugin (click-to-zoom for mermaid fences) via `/lazy-obsidian.update-plugin`. Per-file wizard — asks before creating, shows diff on drift, never auto-overwrites local edits. Re-runnable; idempotent. Project-scope only (no global mode — Obsidian render glue is per-vault). Detects and offers to retire the legacy `mermaid-no-bg.css` snippet (made redundant by the engine's theme directive).
How this skill is triggered — by the user, by Claude, or both
Slash command
/lazycortex-obsidian:lazy-obsidian.diagram-install (no arguments — scaffolds into <repo-root>/.obsidian/)(no arguments — scaffolds into <repo-root>/.obsidian/)This skill is limited to the following tools:
The summary Claude sees in its skill listing — used to decide when to auto-load this skill
Scaffold the Obsidian-side render glue for diagrams emitted by the lazycortex-diagram engine. Three artifacts land in the vault:
Scaffold the Obsidian-side render glue for diagrams emitted by the lazycortex-diagram engine. Three artifacts land in the vault:
| Artifact | Target | Source |
|---|---|---|
mermaid-fit.css snippet | <vault>/.obsidian/snippets/mermaid-fit.css | ${CLAUDE_PLUGIN_ROOT}/templates/obsidian/snippets/mermaid-fit.css |
ascii-fit.css snippet | <vault>/.obsidian/snippets/ascii-fit.css | ${CLAUDE_PLUGIN_ROOT}/templates/obsidian/snippets/ascii-fit.css |
mermaid-popup plugin | <vault>/.obsidian/plugins/mermaid-popup/ | Obsidian community registry (deep-merged with overrides from templates/obsidian/plugin-settings.json) |
The engine ships every mermaid fence with the theme directive %%{init: {'themeVariables':{'background':'transparent'}}}%% so the SVG inherits the Obsidian panel background. mermaid-fit.css fits the SVG to container width without aspect-ratio distortion. ascii-fit.css shrinks ASCII-diagram code blocks (language-text / language-ascii) in Reading Mode so wide diagrams fit the editor column with horizontal scroll fallback. The mermaid-popup plugin adds click-to-zoom on every fence.
Project-local only. There is no global scope — Obsidian render glue is inherently per-vault.
This skill has 7 ordered steps. The executing agent MUST NOT skip, merge, reorder, or silently omit any step. To make dropped steps structurally impossible:
TaskCreate with exactly one task per step below — no merging, no abbreviation, no renaming. The canonical list (use these titles verbatim):
Step 1 — Locate repo root and vaultStep 2 — Sync CSS snippetsStep 3 — Enable snippets in appearance.jsonStep 4 — Install/update mermaid-popupStep 5 — Detect legacy mermaid-no-bg.cssStep 6 — ReportStep 7 — Log the runin_progress on enter and completed on exit. "Completed" means "I executed the step's logic AND produced a report line for it". No-ops count only if they produced an explicit outcome word (e.g. installed, unchanged, kept-local, already-enabled, skipped-per-user-choice, absent).TaskList shows every prior task completed or explicitly skipped with an outcome. A still-pending task is a bug — stop and execute it first.git rev-parse --show-toplevel (fall back to cwd and WARN if not in a git repo).<repo_root>/.obsidian. If .obsidian/ does not exist, abort with: "No Obsidian vault found at <repo-root>/.obsidian/. Initialize Obsidian first, then re-run."mkdir -p <vault>/snippets so later phases can write safely even in greenfield vaults.Outcome: asserted (vault=<path>) or [FAIL] no-vault.
Iterate over the shipped snippet list — order is mermaid-fit, ascii-fit. For each <name>:
${CLAUDE_PLUGIN_ROOT}/templates/obsidian/snippets/<name>.css.<vault>/snippets/<name>.css.State machine per snippet (one AskUserQuestion per file):
AskUserQuestion with:
Install the `<name>.css` snippet into this vault?**What this does:** Copies the shipped snippet to `<targetPath>`. Future installs will show a drift diff, not silently overwrite. Step 3 then enables it in `appearance.json`.
mermaid-fit: **Purpose:** Fits mermaid SVG to container width without aspect-ratio distortion.ascii-fit: **Purpose:** Shrinks ASCII-diagram code blocks (\language-text` / `language-ascii`) in Reading Mode so wide diagrams fit the editor column; adds horizontal scroll fallback.`Bash(diff -u <target> <source>). AskUserQuestion:
<name>.css has drift — overwrite with shipped version?Use Read + Write so diffs are visible to the wizard. Create missing parents with Bash(mkdir -p ...).
Outcome: per-snippet status word from installed / unchanged / overwritten / kept-local / skipped. Record both for the Step 6 report.
Read <vault>/appearance.json. If missing or unparseable, treat its contents as {}.
enabledCssSnippets exists as an array (create empty [] if absent).<name> in [mermaid-fit, ascii-fit]:
"<name>", append it.<vault>/snippets/<name>.css does not exist on disk, do NOT add the entry — pointing enabledCssSnippets at a missing file is dead config. Record per-snippet outcome deferred in this case.appearance.json.tmp → mv) only when the array changed.Per-snippet outcome:
enabled — added to the array this run.already-enabled — entry was already present.deferred — Step 2 left the file absent; refused to register a stale entry.Reload note: Obsidian does not watch appearance.json for changes mid-session. The Step 6 report tells the user to reload Obsidian (or click ↻ next to each snippet in Settings → Appearance → CSS snippets) when any snippet's outcome this step was enabled.
mermaid-popup is the click-to-zoom community plugin (registry id: mermaid-popup). The plugin's data.json is configured via the mermaid-popup override block in ${CLAUDE_PLUGIN_ROOT}/templates/obsidian/plugin-settings.json ({"ZoomRatioValue": "0.1"} — 10% zoom step per scroll wheel tick, calibrated for mermaid fences).
update-plugin is version-aware and idempotent — invoke it unconditionally. "Manifest present" does NOT mean "already current" — that's update-plugin's job.
/lazy-obsidian.update-plugin mermaid-popup.binary=created|updated-<x>-to-<y>|unchanged overrides=applied|unchanged community=registered|already-registered) for the Step 6 report.update-plugin returns FAIL (registry fetch failed, plugin id not in registry, etc.), surface the failure. Diagram rendering still works without mermaid-popup (the snippet alone covers fit + theme color), so DO NOT abort the skill — record failed:<reason> for the Step 6 report and continue.Outcome: state tuple or failed:<reason>.
mermaid-no-bg.cssVaults that previously used the spec-system's spec.draw-diagram skill may carry <vault>/snippets/mermaid-no-bg.css. The new engine's theme directive (background:transparent) makes that snippet redundant — keeping it does no harm but it's dead config.
test -f <vault>/snippets/mermaid-no-bg.css. If absent → state absent, no prompt.AskUserQuestion:
Retire legacy `mermaid-no-bg.css`? It is no longer needed — the diagram engine now emits a transparent-background theme directive on every mermaid fence.**What this does:** Deletes `<vault>/snippets/mermaid-no-bg.css` and removes `"mermaid-no-bg"` from `appearance.json`'s `enabledCssSnippets`. Reversible — re-add the snippet manually if needed.\n\n**Why retire it:** The engine's per-fence theme directive sets `themeVariables.background` to transparent natively, which renders the CSS rule a no-op. Keeping the snippet is harmless but it's stale config.rm <target> AND remove "mermaid-no-bg" from enabledCssSnippets (preserve other entries; rewrite appearance.json only when the array changed). State retired.Never auto-delete — wizard discipline.
One bullet per step, in order — missing bullet = skipped step, back up and run it.
mermaid-fit.css, ascii-fit.css): installed / unchanged / overwritten / kept-local / skipped, with target path.binary=... overrides=... community=...) or failed:<reason>.Next steps shown to user:
mermaid-fit left absent → mermaid SVGs may render with default sizing; ascii-fit left absent → wide ASCII diagrams will overflow the editor column."mermaid-popup is installed; re-run /lazy-obsidian.update-plugin mermaid-popup later or install via Obsidian's Community Plugins UI."Per ./.claude/rules/lazy-log.logging.md:
Bash(mkdir -p ./.logs/claude/lazy-obsidian.diagram-install)Write to ./.logs/claude/lazy-obsidian.diagram-install/<UTC-timestamp>.md with frontmatter (git_sha, git_branch, date, input) and the Step 6 report body.Two-step write: never chain with &&.
/lazy-obsidian.diagram-install aborts: "No Obsidian vault found at <repo-root>/.obsidian/" — .obsidian/ is absent from the repo root → initialize Obsidian in this repo first, then re-run.failed:<reason> for mermaid-popup — the Obsidian community registry was unreachable or mermaid-popup was not found in it → mermaid SVG fit and theme color still work via the CSS snippets alone; re-run /lazy-obsidian.update-plugin mermaid-popup later when the network is available, or install the plugin via Obsidian's Community Plugins UI.Safe to re-run. Drift prompts only fire when content actually differs. Step 3 no-ops when the array entry is already present. Step 4 delegates to /lazy-obsidian.update-plugin, which is itself idempotent. Step 5's prompt fires only while the legacy snippet is still on disk — once retired, re-runs report absent.
/lazy-diagram.draw (engine entry point).lazycortex-diagram is enabled — the CSS + plugin are useful for any vault that contains mermaid fences. The engine is the recommended producer; nothing here requires it./lazy-obsidian.install. That skill offers to chain into this one as part of the standard vault setup. Re-running this skill directly (after install) is the way to pick up template changes after a /plugin update.Creates, edits, and optimizes skills for Claude Code, including drafting, evaluating with test prompts, iterating on performance, and improving skill descriptions for better triggering accuracy.
npx claudepluginhub mebius-san/lazy-cortex --plugin lazycortex-obsidian