Skill63 repo starsupdated 12d ago
tldraw-skill
This skill generates hand-drawn whiteboard-style diagrams in .tldr JSON format and exports them to PNG or SVG using the tldraw-cli tool. Use it when users explicitly request diagrams, flowcharts, architecture charts, or visualizations, or proactively when explaining systems with multiple interacting components, multi-step processes, data flows, or relationships that benefit from visual representation. Route to drawio-skill instead for polished business presentations or precise vector geometry.
Install in Claude Code
Copygit clone --depth 1 https://github.com/Agents365-ai/tldraw-skill /tmp/tldraw-skill && cp -r /tmp/tldraw-skill/skills/tldraw-skill ~/.claude/skills/tldraw-skillThen start a new Claude Code session; the skill loads automatically.
Definition
SKILL.md
# tldraw Whiteboard Diagrams ## Overview Generate modern whiteboard-style diagrams as `.tldr` JSON files and export to PNG/SVG using `@kitschpatrol/tldraw-cli`. tldraw produces clean hand-drawn aesthetic diagrams with rich shape libraries and smooth arrow routing — well-suited for casual or whiteboard-style visualizations. **Format:** `.tldr` JSON **Export:** PNG, SVG (via `@kitschpatrol/tldraw-cli`) **Aesthetic:** Hand-drawn whiteboard style by default; switchable to clean fonts via `font` prop. ## When to Use **Explicit triggers:** user says "diagram", "flowchart", "draw", "visualize", "whiteboard diagram", "tldraw diagram", "architecture diagram", "sketch this out". **Proactive triggers:** - Explaining a system with 3+ interacting components - Describing a multi-step process, data flow, or pipeline - Showing relationships between services/modules - Architecture overviews, sequence flows, decision trees, ML model layers **Skip when:** a simple list or table suffices, the user wants a polished business-presentation diagram (prefer drawio-skill), or the user is in a quick Q&A flow. **When NOT to use it — route elsewhere:** - Logos / solid-color graphics / filled icons: tldraw has **no opaque fill** (`solid` = light tint; white-on-dark can't be reproduced) → use the **drawio** skill or the original vector file. - Precise vector geometry or strict (hollow-arrow) UML → **drawio** (or **plantuml** for UML). - Auto-layout of many nodes → **mermaid** (tldraw needs manual coordinates). - A pixel-faithful copy of an existing image → not a diagram-skill task. ## Prerequisites ```bash # Install tldraw-cli npm install -g @kitschpatrol/tldraw-cli # Verify tldraw --version ``` Works identically on macOS, Windows, and Linux. **First-export note:** `tldraw export` renders through a pinned Chrome build via puppeteer. The first export can fail with `Could not find Chrome (ver. <x>)`. The error names the exact version it needs — install it once, then exports work: ```bash # The error message names the version; substitute it here npx puppeteer browsers install chrome@<version-from-error> ``` (Installs to `~/.cache/puppeteer`; only needed once per CLI version.) ## Workflow Before starting, assess whether the user's request is specific enough. If key details are missing, ask 1-3 focused questions: - **Diagram type** — which preset? (Architecture, Flowchart, Sequence, ML/DL, ERD, UML, or general) - **Output format** — PNG (default), SVG? - **Output location** — default is the user's working dir; honor any explicit path the user gives (e.g. "put it in `./artifacts/`"). Don't ask if they didn't mention one. - **Scope/fidelity** — how many components? Any specific technologies or labels? Skip clarification if the request already specifies these details or is clearly simple (e.g., "draw a flowchart of X"). 1. **Check deps** — verify `tldraw --version` succeeds; if missing, run `npm install -g @kitschpatrol/tldraw-cli`. 2. **Plan** — identify shapes (geo type per node), connections (arrows with source/target), and layout (TB or LR, group by tier/role). Sketch a coordinate grid before writing JSON. 3. **Generate** — write the `.tldr` JSON file. Default output dir is the user's working dir; if the user specified a path or directory (e.g. `./artifacts/`), `mkdir -p` it first and write there. Apply the same dir choice to PNG/SVG exports in steps 4 and 7. 4. **Export draft** — run CLI to produce a PNG for preview. 5. **Self-check** — use the agent's built-in vision capability to read the exported PNG, catch obvious issues, auto-fix before showing the user (requires a vision-enabled model such as Claude Sonnet/Opus). If vision is unavailable, skip this step. 6. **Review loop** — show image to user, collect feedback, apply targeted JSON edits, re-export, repeat until approved. 7. **Final export** — export the approved version to all requested formats; report file paths for both the `.tldr` source and exported image(s). ### Step 5: Self-Check After exporting the draft PNG, use the agent's vision capability (e.g., Claude's image input) to read the image and check for these issues before showing the user. If the agent does not support vision, skip self-check and show the PNG directly. tldraw's own AI agent flags exactly three structural defects — **text overflow** (a box too small for its label), **overlapping text**, and **friendless arrows** (an arrow with an unbound end). The first three rows below target those; size boxes correctly up front (see "Sizing boxes to fit labels") and they rarely occur. | Check | What to look for | Auto-fix action | |-------|-----------------|-----------------| | Text overflow | Label spills past the shape's border, or the box looks taller than you set (tldraw auto-grows an undersized box) | Increase `w`/`h` to fit the label — see the sizing formula below | | Overlapping text | Two text-bearing shapes' labels touch or overlap, hurting legibility | Shift shapes apart by ≥200px | | Friendless arrow | An arrow with one end not connected to a shape (floats loose) | Bind both ends: every arrow's `start` and `end` need a `boundShapeId` matching an existing shape | | Off-canvas shapes | Shapes at negative coordinates or far from the main group | Move to positive coordinates near the cluster | | Arrow-shape overlap | An arrow visually crosses through an unrelated shape | Adjust `bend` value or move endpoints to a different `normalizedAnchor` side | | Stacked arrows | Multiple arrows overlap each other on the same path | Distribute `normalizedAnchor` across the shape perimeter (use different x/y values) | - Max **2 self-check rounds** — if issues remain after 2 fixes, show the user anyway. - Re-export after each fix and re-read the new PNG. ### Step 6: Review Loop After self-check, show the exported image and ask the user for feedback. **Targeted edit rules** — for each type of feedback, apply the minimal JSON change: | User request | JSON edit action | |-------------|----