Excalidraw Agent
Overview
Use this skill to deliver end-to-end Excalidraw work in host apps: integration, API-driven scene updates, Mermaid conversion, library operations, export/import pipelines, collaboration patterns, and runtime diagnostics.
Prefer this workflow: triage the task, load only the relevant reference file, execute using deterministic scripts when possible, validate output, and report exact outcomes.
Core Workflow
- Triage the request type.
- Load only the required reference file(s) from
references/.
- Run environment check when scripts are involved:
- Execute the task path.
- Validate the result (script checks + structural checks + behavior checks).
- Report what changed, what was verified, and remaining risks.
Task Triage
- Installation or framework embedding: load
references/excalidraw-install-and-integration.md
- Props and imperative API usage: load
references/excalidraw-props-and-api.md
- Serialization, restore, and export/import: load
references/excalidraw-utils-restore-export.md
- Editor composition (
MainMenu, Sidebar, WelcomeScreen, Footer): load references/excalidraw-ui-composition.md
- Mermaid conversion workflows: load
references/excalidraw-mermaid-conversion.md
- Collaboration architecture and remote update behavior: load
references/excalidraw-collaboration-pattern.md
- Account-linked import/publish via authenticated browser session: load
references/excalidraw-account-linking.md
- Client setup/portability across Codex, Claude Code, Cursor, and Zed: load
references/excalidraw-client-compatibility.md
- Runtime or build failures: load
references/excalidraw-troubleshooting.md
- Skills protocol constraints and metadata behavior: load
references/agent-skills-protocol-notes.md
Hard Integration Requirements
Apply these on every Excalidraw integration unless the user explicitly asks otherwise:
- Import Excalidraw stylesheet:
import "@excalidraw/excalidraw/index.css";
- Render in a container with non-zero height and width.
- Use
excalidrawAPI callback for imperative control; do not use removed legacy ref API patterns.
- For Next.js, disable SSR for Excalidraw rendering via dynamic import.
- If self-hosting fonts/assets, set
window.EXCALIDRAW_ASSET_PATH correctly.
Script Interfaces
Run scripts from this skill root or by absolute path.
scripts/check_env.sh
scripts/mermaid_to_scene.mjs --input <mmd|-> --output <scene.excalidraw> --font-size <n> --regenerate-ids <true|false> --pretty <true|false>
scripts/scene_lint.mjs --input <scene.excalidraw> --strict-diagram <true|false>
scripts/library_merge.mjs --base <a.excalidrawlib> --other <b.excalidrawlib> --output <merged.excalidrawlib> --default-status <published|unpublished>
scripts/import_to_excalidraw.sh --input <path> --destination <plus|excalidraw> --kind <auto|scene|library> --mode <headed|headless> --session <name> --output-dir <path> --timeout-sec <n> --dry-run <true|false> --close-on-complete <true|false> --pwcli <path>
scripts/self_test.sh
Deterministic Execution Notes
- Scripts resolve Excalidraw dependencies from
process.cwd() first, then from the skill directory.
- Recommended runtime is Node + pnpm.
- For conversions and merges, run from a project directory where
@excalidraw/excalidraw and @excalidraw/mermaid-to-excalidraw are available, or install them in a temporary working directory first.
- If
@excalidraw/excalidraw cannot be loaded in the active Node runtime, scripts emit a warning and apply deterministic fallback normalization so workflows continue.
- The account-link import script supports multiple agent environments by resolving Playwright in this order:
- explicit
--pwcli or PWCLI
- known wrapper paths under
~/.codex, ~/.claude, ~/.cursor, and ~/.config/zed
- global
playwright-cli
npx --yes --package @playwright/mcp playwright-cli
- API-level account linking is not available in this skill. Account linking is implemented as authenticated UI import on
excalidraw.com or plus.excalidraw.com.
Multi-Agent Compatibility
- Core Agent Skills contract is
SKILL.md + optional references/, scripts/, and assets/.
agents/openai.yaml is optional metadata for Codex UX and can be ignored by other clients.
- This skill is designed to be portable: all operational instructions are rooted in
SKILL.md, script paths are skill-root relative, and account-link import can run with any Playwright CLI provider via --pwcli.
- For client-specific setup and invocation patterns, load
references/excalidraw-client-compatibility.md.
Execution Paths
1) Embed Excalidraw in a Host App
- Load
references/excalidraw-install-and-integration.md.
- Implement base integration for React/Next.js/Preact as needed.
- Confirm CSS import and non-zero container dimensions.
- Validate editor rendering and input behavior.
2) Implement API-Driven Scene or UI Behavior
- Load
references/excalidraw-props-and-api.md.
- Use
excalidrawAPI callback to capture API instance.
- Use
updateScene and captureUpdate semantics intentionally:
- local undoable updates:
IMMEDIATELY
- async grouped updates:
EVENTUALLY
- remote/collab updates:
NEVER
- Verify behavior via event subscriptions (
onChange, pointer handlers).
3) Convert Mermaid to .excalidraw
- Load
references/excalidraw-mermaid-conversion.md.
- Run conversion:
node scripts/mermaid_to_scene.mjs --input diagram.mmd --output diagram.excalidraw --font-size 16 --regenerate-ids true --pretty true
- Validate output:
node scripts/scene_lint.mjs --input diagram.excalidraw --strict-diagram true
- If parser fallback behavior appears, report which nodes were downgraded.
- If import layout is unreadable (for example tall single-column collapse), simplify labels/graph, reconvert, and expect a manual arrangement pass in Excalidraw.
4) Merge and Normalize Libraries
- Load
references/excalidraw-utils-restore-export.md.
- Merge:
node scripts/library_merge.mjs --base lib-a.excalidrawlib --other lib-b.excalidrawlib --output merged.excalidrawlib --default-status unpublished
- Confirm merged output contains normalized
libraryItems and expected dedupe behavior.
5) Build Collaboration Glue
- Load
references/excalidraw-collaboration-pattern.md.
- Keep transport and persistence in host app; keep editor as client state surface.
- Apply remote updates with non-undo capture behavior.
- Verify collaborator map rendering and local-vs-remote conflict handling.
6) Troubleshoot Runtime Failures
- Load
references/excalidraw-troubleshooting.md.
- Diagnose by category: SSR/build, CSS/layout, browser quirks, asset path, env flags.
- Validate fixed state with a minimal reproducible integration.
7) Link Generated Content to Excalidraw Account
- Load
references/excalidraw-account-linking.md.
- Run import script in headed mode for interactive login:
bash scripts/import_to_excalidraw.sh --input diagram.excalidraw --destination plus --mode headed
- Complete manual login/MFA at checkpoint.
- Let script run deterministic import strategy sequence and UI assertions.
- Confirm persistence checkpoint for
plus destination.
- Collect screenshot proof path and
RESULT_JSON output.
8) Configure Skill for a Specific Agent Client
- Load
references/excalidraw-client-compatibility.md.
- Place or symlink the skill directory into the client's skill root.
- Validate script execution from that environment:
bash scripts/check_env.sh
bash scripts/import_to_excalidraw.sh --input assets/examples/scene-minimal.excalidraw --dry-run true
- If Playwright is not discovered automatically, set
--pwcli explicitly.
- Confirm the client can load
SKILL.md and access references/ and scripts/.
Validation Checklist
- Skill metadata and structure validate cleanly.
- Script CLIs run with documented flags.
- Converted scenes parse and lint successfully.
- Merged libraries are normalized and readable by Excalidraw tooling.
- Recommendations reference the correct framework constraints (React/Next/Preact).
- Cross-client setup guidance is present and does not assume a single agent runtime.
Skill Maintenance
- Keep
SKILL.md concise and procedural.
- Keep deep details in
references/.
- Keep references one hop from
SKILL.md.
- Re-run validation after edits:
python <path-to-skill-creator>/scripts/quick_validate.py <path-to-skill-dir>
skills-ref validate <path-to-skill-dir>
1---2name: excalidraw-agent3description: Integrate and automate Excalidraw in React and Next.js apps, convert Mermaid to .excalidraw scenes, merge/normalize .excalidrawlib libraries, and troubleshoot Excalidraw runtime issues. Use when users mention Excalidraw, Mermaid diagrams, .excalidraw or .excalidrawlib files, Excalidraw API props/methods, export/import flows, or host-app collaboration wiring.4---56# Excalidraw Agent78## Overview910Use this skill to deliver end-to-end Excalidraw work in host apps: integration, API-driven scene updates, Mermaid conversion, library operations, export/import pipelines, collaboration patterns, and runtime diagnostics.1112Prefer this workflow: triage the task, load only the relevant reference file, execute using deterministic scripts when possible, validate output, and report exact outcomes.1314## Core Workflow15161. Triage the request type.172. Load only the required reference file(s) from `references/`.183. Run environment check when scripts are involved:19 - `scripts/check_env.sh`204. Execute the task path.215. Validate the result (script checks + structural checks + behavior checks).226. Report what changed, what was verified, and remaining risks.2324## Task Triage2526- Installation or framework embedding: load `references/excalidraw-install-and-integration.md`27- Props and imperative API usage: load `references/excalidraw-props-and-api.md`28- Serialization, restore, and export/import: load `references/excalidraw-utils-restore-export.md`29- Editor composition (`MainMenu`, `Sidebar`, `WelcomeScreen`, `Footer`): load `references/excalidraw-ui-composition.md`30- Mermaid conversion workflows: load `references/excalidraw-mermaid-conversion.md`31- Collaboration architecture and remote update behavior: load `references/excalidraw-collaboration-pattern.md`32- Account-linked import/publish via authenticated browser session: load `references/excalidraw-account-linking.md`33- Client setup/portability across Codex, Claude Code, Cursor, and Zed: load `references/excalidraw-client-compatibility.md`34- Runtime or build failures: load `references/excalidraw-troubleshooting.md`35- Skills protocol constraints and metadata behavior: load `references/agent-skills-protocol-notes.md`3637## Hard Integration Requirements3839Apply these on every Excalidraw integration unless the user explicitly asks otherwise:40411. Import Excalidraw stylesheet:42 - `import "@excalidraw/excalidraw/index.css";`432. Render in a container with non-zero height and width.443. Use `excalidrawAPI` callback for imperative control; do not use removed legacy `ref` API patterns.454. For Next.js, disable SSR for Excalidraw rendering via dynamic import.465. If self-hosting fonts/assets, set `window.EXCALIDRAW_ASSET_PATH` correctly.4748## Script Interfaces4950Run scripts from this skill root or by absolute path.5152- `scripts/check_env.sh`53- `scripts/mermaid_to_scene.mjs --input <mmd|-> --output <scene.excalidraw> --font-size <n> --regenerate-ids <true|false> --pretty <true|false>`54- `scripts/scene_lint.mjs --input <scene.excalidraw> --strict-diagram <true|false>`55- `scripts/library_merge.mjs --base <a.excalidrawlib> --other <b.excalidrawlib> --output <merged.excalidrawlib> --default-status <published|unpublished>`56- `scripts/import_to_excalidraw.sh --input <path> --destination <plus|excalidraw> --kind <auto|scene|library> --mode <headed|headless> --session <name> --output-dir <path> --timeout-sec <n> --dry-run <true|false> --close-on-complete <true|false> --pwcli <path>`57- `scripts/self_test.sh`5859## Deterministic Execution Notes6061- Scripts resolve Excalidraw dependencies from `process.cwd()` first, then from the skill directory.62- Recommended runtime is Node + pnpm.63- For conversions and merges, run from a project directory where `@excalidraw/excalidraw` and `@excalidraw/mermaid-to-excalidraw` are available, or install them in a temporary working directory first.64- If `@excalidraw/excalidraw` cannot be loaded in the active Node runtime, scripts emit a warning and apply deterministic fallback normalization so workflows continue.65- The account-link import script supports multiple agent environments by resolving Playwright in this order:66 1. explicit `--pwcli` or `PWCLI`67 2. known wrapper paths under `~/.codex`, `~/.claude`, `~/.cursor`, and `~/.config/zed`68 3. global `playwright-cli`69 4. `npx --yes --package @playwright/mcp playwright-cli`70- API-level account linking is not available in this skill. Account linking is implemented as authenticated UI import on `excalidraw.com` or `plus.excalidraw.com`.7172## Multi-Agent Compatibility7374- Core Agent Skills contract is `SKILL.md` + optional `references/`, `scripts/`, and `assets/`.75- `agents/openai.yaml` is optional metadata for Codex UX and can be ignored by other clients.76- This skill is designed to be portable: all operational instructions are rooted in `SKILL.md`, script paths are skill-root relative, and account-link import can run with any Playwright CLI provider via `--pwcli`.77- For client-specific setup and invocation patterns, load `references/excalidraw-client-compatibility.md`.7879## Execution Paths8081### 1) Embed Excalidraw in a Host App82831. Load `references/excalidraw-install-and-integration.md`.842. Implement base integration for React/Next.js/Preact as needed.853. Confirm CSS import and non-zero container dimensions.864. Validate editor rendering and input behavior.8788### 2) Implement API-Driven Scene or UI Behavior89901. Load `references/excalidraw-props-and-api.md`.912. Use `excalidrawAPI` callback to capture API instance.923. Use `updateScene` and `captureUpdate` semantics intentionally:93 - local undoable updates: `IMMEDIATELY`94 - async grouped updates: `EVENTUALLY`95 - remote/collab updates: `NEVER`964. Verify behavior via event subscriptions (`onChange`, pointer handlers).9798### 3) Convert Mermaid to `.excalidraw`991001. Load `references/excalidraw-mermaid-conversion.md`.1012. Run conversion:102 - `node scripts/mermaid_to_scene.mjs --input diagram.mmd --output diagram.excalidraw --font-size 16 --regenerate-ids true --pretty true`1033. Validate output:104 - `node scripts/scene_lint.mjs --input diagram.excalidraw --strict-diagram true`1054. If parser fallback behavior appears, report which nodes were downgraded.1065. If import layout is unreadable (for example tall single-column collapse), simplify labels/graph, reconvert, and expect a manual arrangement pass in Excalidraw.107108### 4) Merge and Normalize Libraries1091101. Load `references/excalidraw-utils-restore-export.md`.1112. Merge:112 - `node scripts/library_merge.mjs --base lib-a.excalidrawlib --other lib-b.excalidrawlib --output merged.excalidrawlib --default-status unpublished`1133. Confirm merged output contains normalized `libraryItems` and expected dedupe behavior.114115### 5) Build Collaboration Glue1161171. Load `references/excalidraw-collaboration-pattern.md`.1182. Keep transport and persistence in host app; keep editor as client state surface.1193. Apply remote updates with non-undo capture behavior.1204. Verify collaborator map rendering and local-vs-remote conflict handling.121122### 6) Troubleshoot Runtime Failures1231241. Load `references/excalidraw-troubleshooting.md`.1252. Diagnose by category: SSR/build, CSS/layout, browser quirks, asset path, env flags.1263. Validate fixed state with a minimal reproducible integration.127128### 7) Link Generated Content to Excalidraw Account1291301. Load `references/excalidraw-account-linking.md`.1312. Run import script in headed mode for interactive login:132 - `bash scripts/import_to_excalidraw.sh --input diagram.excalidraw --destination plus --mode headed`1333. Complete manual login/MFA at checkpoint.1344. Let script run deterministic import strategy sequence and UI assertions.1355. Confirm persistence checkpoint for `plus` destination.1366. Collect screenshot proof path and `RESULT_JSON` output.137138### 8) Configure Skill for a Specific Agent Client1391401. Load `references/excalidraw-client-compatibility.md`.1412. Place or symlink the skill directory into the client's skill root.1423. Validate script execution from that environment:143 - `bash scripts/check_env.sh`144 - `bash scripts/import_to_excalidraw.sh --input assets/examples/scene-minimal.excalidraw --dry-run true`1454. If Playwright is not discovered automatically, set `--pwcli` explicitly.1465. Confirm the client can load `SKILL.md` and access `references/` and `scripts/`.147148## Validation Checklist149150- Skill metadata and structure validate cleanly.151- Script CLIs run with documented flags.152- Converted scenes parse and lint successfully.153- Merged libraries are normalized and readable by Excalidraw tooling.154- Recommendations reference the correct framework constraints (React/Next/Preact).155- Cross-client setup guidance is present and does not assume a single agent runtime.156157## Skill Maintenance158159- Keep `SKILL.md` concise and procedural.160- Keep deep details in `references/`.161- Keep references one hop from `SKILL.md`.162- Re-run validation after edits:163 - `python <path-to-skill-creator>/scripts/quick_validate.py <path-to-skill-dir>`164 - `skills-ref validate <path-to-skill-dir>`