agent-canvas
CLAUDE.md33 starsChanged 11 months agoMITView on GitHub
Agent Canvas is an AI agent skill + CLI tool that provides an Excalidraw canvas interface for AI agents. It consists of: Important: When developing, always use bun dev:cli instead of the globally installed agent-canvas command. The global version is the published release and won't include your local changes. bun run dev (or bun dev:cli start --dev) starts a development server with Vite HMR: Workflow: 1. Run bun run dev to start dev server (Vite HMR + WS relay) 2.…
The file
We split this CLAUDE.md into the rules it gives an agent
7 rules. About 0 are common, 1 is distinctive, and 6 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 42
Important: When developing, always use bun dev:cli instead of the globally installed agent-canvas command.
- Very specific: line 58
Run bun run dev to start dev server (Vite HMR + WS relay)
- Very specific: line 61
Test CLI commands with bun dev:cli <command>
- Very specific: line 116
When drawing complex diagrams, chain commands with && for efficiency:
- Very specific: line 162
When optimizing drawing tutorials in skills/agent-canvas/references/, use this iterative workflow:
- Very specific: line 202
Use agent-canvas read to verify actual vs specified dimensions
- Distinctive: line 203
Test both simple and complex scenarios before committing
≈ “Common” is an estimate: at least 1 in 5 of the 29,248 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Project Overview
Agent Canvas is an AI agent skill + CLI tool that provides an Excalidraw canvas interface for AI agents. It consists of:
- skills/agent-canvas/: Agent skill (teaches AI agents how to use the CLI)
- packages/: NPM packages in a Turborepo monorepo
- web-app: Browser frontend with Excalidraw
- cli: Command-line interface with built-in HTTP/WebSocket server
Tech Stack
- Package Manager: Bun
- Monorepo: Turborepo
- Web App: Vite + React + @excalidraw/excalidraw (0.18.0)
- CLI: Commander.js + ws (WebSocket client)
- Language: TypeScript
Development Commands
# Install dependencies (from root)
bun install
# Start dev server (Vite HMR + WS relay, auto-opens browser)
bun run dev
# Run CLI commands during development (use this instead of global `agent-canvas`)
bun dev:cli <command>
# Example: bun dev:cli add-shape -t rectangle -x 100 -y 100
# Build all packages
bun run build
# Type check
bun run typecheckImportant: When developing, always use bun dev:cli instead of the globally installed agent-canvas command. The global version is the published release and won't include your local changes.
Dev Mode (start --dev)
bun run dev (or bun dev:cli start --dev) starts a development server with Vite HMR:
- WS relay on port 7900 (dev default, overridable via
AGENT_CANVAS_WS_PORT) - Vite dev server on port 5173 (Vite default) with hot module replacement
- No
bun run buildneeded — web-app changes auto-reload in browser
| WS Port | HTTP Port | |
Production (start) | 7890 | 7891 |
Dev (start --dev) | 7900 | 5173 (Vite) |
Workflow:
- Run
bun run devto start dev server (Vite HMR + WS relay) - Make code changes in
packages/web-app/src/— browser auto-reloads - For CLI changes in
packages/cli/src/, restart the dev server - Test CLI commands with
bun dev:cli <command>
Architecture
CLI (ws-client) <--WebSocket:7890--> CLI Server (relay) <--WebSocket:7890--> Browser
|
HTTP:7891 (static files)- HTTP server serves web-app static files on port 7891
- WebSocket server relays messages on port 7890
- Browser connects as WebSocket client, identified by
browserConnectmessage
Protocol
Messages are defined in cli/src/lib/protocol.ts and follow a typed message pattern with type discriminator. Each request has an id for response matching.
CLI Commands
Application Control
agent-canvas start- Start server and open browseragent-canvas start --dev- Dev mode: Vite HMR + WS relay (no build needed)agent-canvas load <path>- Load .excalidraw file into current canvas
Canvas Management
agent-canvas list- List all canvases (* marks active)agent-canvas new -n <name> [--use]- Create new canvas, optionally switch to itagent-canvas use <name>- Switch to canvas by nameagent-canvas rename <name>- Rename current canvas
Drawing Commands
agent-canvas add-shape -t <rectangle|ellipse|diamond> -x <n> -y <n>- Add shapeagent-canvas add-text -t <text> -x <n> -y <n>- Add textagent-canvas add-line -x <n> -y <n> --end-x <n> --end-y <n>- Add lineagent-canvas add-arrow -x <n> -y <n> --end-x <n> --end-y <n>- Add arrowagent-canvas add-polygon -p '<json-points>'- Add polygon
Element Manipulation
agent-canvas delete-elements -i <ids>- Delete elements (batch)agent-canvas rotate-elements -i <ids> -a <degrees>- Rotate elements (batch)agent-canvas move-elements -i <ids> --delta-x <n> --delta-y <n>- Move elementsagent-canvas resize-elements -i <ids> [--top <n>] [--bottom <n>] [--left <n>] [--right <n>]- Resize shapesagent-canvas group-elements -i <ids>- Group elementsagent-canvas ungroup-element -i <id>- Ungroup element
Scene Operations
agent-canvas read- Read scene (TOON format)agent-canvas read --json- Read scene (JSON format)agent-canvas save <filepath>- Save to .excalidraw fileagent-canvas export -o <path>- Export to PNGagent-canvas clear- Clear all elements from the canvas
Drawing Tips for Agents
When drawing complex diagrams, chain commands with && for efficiency:
bun dev:cli add-shape -t rectangle -x 100 -y 100 -w 200 -h 100 -l "Box 1" && \
bun dev:cli add-shape -t rectangle -x 100 -y 250 -w 200 -h 100 -l "Box 2" && \
bun dev:cli add-arrow -x 200 -y 200 --end-x 200 --end-y 250Key Files
| File | Purpose |
cli/src/index.ts | CLI commands |
cli/src/server/index.ts | HTTP + WebSocket server |
cli/src/commands/start.ts | Start command |
cli/src/lib/ws-client.ts | WebSocket client |
cli/src/lib/protocol.ts | WebSocket message types |
web-app/src/App.tsx | Excalidraw + WebSocket handler |
skills/agent-canvas/SKILL.md | Agent skill - CLI command reference |
skills/agent-canvas/references/ | Drawing tutorials for diagram types |
Agent Skill Structure
skills/agent-canvas/
├── SKILL.md # CLI command reference (main skill file)
└── references/
├── REFERENCE.md # Tutorial index
├── flowchart.md # Flowchart tutorial
├── architecture.md # Architecture diagram tutorial
├── mindmap.md # Mind map tutorial
└── ui-mockup.md # UI mockup tutorialVersion Bump Checklist
CLI Version (when CLI code changes)
packages/cli/package.json- version fieldpackages/cli/src/index.ts-.version('x.x.x')(hardcoded)skills/agent-canvas/SKILL.md- Installation section (CLI version in install commands)
Skill Version (when SKILL.md or references change)
skills/agent-canvas/SKILL.md- metadataversionfield only
Reference Tutorial Optimization Workflow
When optimizing drawing tutorials in skills/agent-canvas/references/, use this iterative workflow:
┌─────────────────────────────────────────────────────────────┐
│ 1. Read current tutorial │
│ - Read SKILL.md + references/<type>.md │
└─────────────────────┬───────────────────────────────────────┘
▼
┌─────────────────────────────────────────────────────────────┐
│ 2. Subagent test │
│ - Use Task tool to launch a subagent │
│ - Subagent reads ONLY the docs, draws a test diagram │
│ - Subagent has isolated context (not polluted) │
│ - Ask subagent to report: commands executed, any issues │
└─────────────────────┬───────────────────────────────────────┘
▼
┌─────────────────────────────────────────────────────────────┐
│ 3. Evaluate result │
│ - Export PNG and visually inspect │
│ - Check: alignment, colors, arrows, layout, aesthetics │
│ - Record issues found │
└─────────────────────┬───────────────────────────────────────┘
▼
┌─────────────────────────────────────────────────────────────┐
│ 4. Optimize documentation │
│ - Update SKILL.md or references/<type>.md │
│ - Add rules, examples, or clarifications │
│ - Clear canvas, go back to step 2 │
└─────────────────────┬───────────────────────────────────────┘
▼
┌─────────────────────────────────────────────────────────────┐
│ 5. Repeat until satisfied │
│ - Test with simple and complex diagrams │
│ - Commit changes when quality is good │
└─────────────────────────────────────────────────────────────┘Key principles:
- Subagent isolation ensures unbiased testing (no prior context pollution)
- Debug by asking subagent to report executed commands and size calculations
- Use
agent-canvas readto verify actual vs specified dimensions - Test both simple and complex scenarios before committing
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

