|
| 1 | +--- |
| 2 | +name: tldraw |
| 3 | +version: 2026-04-21 |
| 4 | +triggers: ["draw", "diagram", "sketch", "wireframe", "flowchart", "mind-map", "mind map", "visualize", "lay out", "architecture diagram", "whiteboard"] |
| 5 | +tools: [mcp.tldraw.create_shape, mcp.tldraw.update_shape, mcp.tldraw.delete_shape, mcp.tldraw.get_canvas] |
| 6 | +preconditions: ["tldraw MCP server reachable via the harness's MCP config", "user has http://localhost:3030 open"] |
| 7 | +constraints: ["call get_canvas before update_shape or delete_shape to discover real ids", "at most 200 shapes per create_shape call", "coordinates within 0..1600 x 0..900 unless the user asks otherwise"] |
| 8 | +category: visualization |
| 9 | +--- |
| 10 | + |
| 11 | +# tldraw — draw on a live canvas |
| 12 | + |
| 13 | +The tldraw MCP server exposes a live canvas at `http://localhost:3030`. |
| 14 | +You draw into it; the user watches it fill in. Worthwhile drawings can |
| 15 | +be snapshotted to disk and recalled in future sessions via this skill's |
| 16 | +local store (`store.py`). |
| 17 | + |
| 18 | +## When this skill loads |
| 19 | + |
| 20 | +Any time the user asks to visualize, diagram, sketch, lay out, or map |
| 21 | +something graphically. If they are clearly asking for prose, do not draw. |
| 22 | + |
| 23 | +## Before drawing, once per session |
| 24 | + |
| 25 | +Tell the user: |
| 26 | + |
| 27 | +> Open `http://localhost:3030` to see the canvas. |
| 28 | +
|
| 29 | +If any tool returns `No tldraw browser connected`, repeat the hint and |
| 30 | +stop until they confirm. |
| 31 | + |
| 32 | +## Opt-in MCP setup |
| 33 | + |
| 34 | +This beta does not install MCP wiring during default adapter setup. After the |
| 35 | +user enables `tldraw` in `.agent/memory/.features.json`, they must add the |
| 36 | +server to their harness MCP config. Use this local block as the source of truth: |
| 37 | + |
| 38 | +```json |
| 39 | +{ |
| 40 | + "mcpServers": { |
| 41 | + "tldraw": { |
| 42 | + "command": "npx", |
| 43 | + "args": ["-y", "@tldraw-mcp/server"] |
| 44 | + } |
| 45 | + } |
| 46 | +} |
| 47 | +``` |
| 48 | + |
| 49 | +For Claude Code and Antigravity this usually lives in `.mcp.json`; for Cursor |
| 50 | +it usually lives in `.cursor/mcp.json`. If a config already exists, merge the |
| 51 | +`tldraw` server entry rather than overwriting the file. |
| 52 | + |
| 53 | +## Tools |
| 54 | + |
| 55 | +| tool | purpose | |
| 56 | +|---|---| |
| 57 | +| `create_shape({ shapes: [...] })` | add new shapes | |
| 58 | +| `update_shape({ updates: [{ id, props }] })` | change shapes by id | |
| 59 | +| `delete_shape({ ids: [...] })` | remove shapes | |
| 60 | +| `get_canvas()` | return all current shapes | |
| 61 | + |
| 62 | +Always `get_canvas` first when the user says "add to", "next to", |
| 63 | +"modify", or refers to something already drawn — you need the real ids. |
| 64 | + |
| 65 | +## Coordinate system |
| 66 | + |
| 67 | +- Origin `(0, 0)` top-left. `+x` right, `+y` down. |
| 68 | +- Stay inside `0 <= x <= 1600`, `0 <= y <= 900` unless told otherwise. |
| 69 | +- Default sizes: boxes ~160x80, icons ~60x60. |
| 70 | + |
| 71 | +## Shape vocabulary |
| 72 | + |
| 73 | +| type | required | optional | |
| 74 | +|---|---|---| |
| 75 | +| `geo` | `x, y, w, h` | `geo` (rectangle/ellipse/triangle/diamond/star/...), `color`, `fill`, `text` | |
| 76 | +| `text` | `x, y, text` | `color`, `size` (s/m/l/xl) | |
| 77 | +| `arrow` | `x, y, end:{x,y}` | `color`, `text` (label) | |
| 78 | +| `line` | `x, y, end:{x,y}` | `color` | |
| 79 | +| `draw` | `x, y, points:[{x,y}]` | `color` (freehand, at least 2 points) | |
| 80 | +| `note` | `x, y, text` | `color` (sticky note) | |
| 81 | + |
| 82 | +Colors: `black, grey, light-violet, violet, blue, light-blue, yellow, orange, green, light-green, red`. |
| 83 | +Fills: `none, semi, solid, pattern`. |
| 84 | + |
| 85 | +## Persisting drawings |
| 86 | + |
| 87 | +When a drawing is worth keeping across sessions (architecture decisions, |
| 88 | +recurring diagrams, reference material), snapshot it: |
| 89 | + |
| 90 | +```bash |
| 91 | +# fetch current shapes via MCP get_canvas and pipe the JSON in |
| 92 | +python3 .agent/skills/tldraw/store.py snapshot \ |
| 93 | + --label "auth-flow-v1" --tags architecture,auth \ |
| 94 | + --note "login + refresh token flow agreed 2026-04-21" |
| 95 | +``` |
| 96 | + |
| 97 | +The store reads canvas JSON on stdin, writes a snapshot file under |
| 98 | +`snapshots/`, appends metadata to `snapshots.jsonl`, and re-renders |
| 99 | +`INDEX.md` — all within a single file lock. Later sessions recover a |
| 100 | +drawing with `list` / `load`. Use `archive` to retire a snapshot; the |
| 101 | +JSONL is append-only semantic, so archived records move to |
| 102 | +`snapshots/archive/` rather than being deleted. |
| 103 | + |
| 104 | +## Pitfalls |
| 105 | + |
| 106 | +- `text` shapes need non-empty `text`. |
| 107 | +- `arrow.end` is an absolute point, not a delta. |
| 108 | +- Split large scenes into multiple `create_shape` calls (<= 200 each). |
| 109 | +- Always `get_canvas` before an edit; never assume ids. |
| 110 | + |
| 111 | +## Self-rewrite hook |
| 112 | + |
| 113 | +After any failure, or every 5 uses: |
| 114 | +1. Read the last N tldraw-tagged entries from `memory/episodic/AGENT_LEARNINGS.jsonl`. |
| 115 | +2. If a constraint was violated (shape cap, id-before-edit rule), escalate |
| 116 | + a candidate lesson to `semantic/LESSONS.md` via `tools/learn.py`. |
| 117 | +3. Commit: `skill-update: tldraw, <one-line reason>`. |
0 commit comments