Excalidraw Architect
Overview
Generate structured architecture diagrams in Excalidraw by scripting scene elements (rectangles, text, arrows) through the page runtime API, then iterating quickly based on user feedback.
Workflow
1) Open and verify the Excalidraw tab
Open
https://excalidraw.com/ in the browser tool and keep using the same
targetId for all edits.
If the user already has a board open, reuse that tab instead of creating a new one.
2) Get Excalidraw runtime API from the page
Use an
evaluate action to locate
excalidrawAPI from the React fiber tree.
If API lookup fails, refresh once and retry.
Use this lookup logic (or equivalent):
- - find
.excalidraw root - read INLINECODE5
- traverse child/sibling fibers
- pick node where
memoizedProps.excalidrawAPI.updateScene exists
3) Build scene elements from the requested architecture
Translate the user’s request into:
- - container blocks (rectangles)
- section labels and body text
- directional arrows between blocks
Prefer clear readable layout:
- - title at top
- left-to-right data flow unless user requests otherwise
- enough spacing to avoid overlap
4) Write scene to canvas
Call
api.updateScene({ elements, appState }) and then
api.scrollToContent(elements, { fitToContent: true }).
When user requests changes, rewrite the scene deterministically (do not partially patch random elements unless user asks for tiny edits).
5) Confirm result
Send a short completion message and mention what changed.
Editing Rules
- - Preserve user’s scope boundaries (example: “only draw to Raw Data Pool”).
- Keep language concise and business-readable.
- Prefer complete labels over abbreviations.
- If text is too dense, split into multiple lines.
- If user asks for “only one layer”, remove downstream blocks explicitly.
Reusable Resources
scripts/
- -
scripts/generate_excalidraw_scene.py: convert a JSON spec into Excalidraw element JSON.
references/
- -
references/excalidraw-api-snippets.md: tested API discovery and update snippets for browser evaluate calls.
Use scripts/resources when diagrams are large or need repeatable generation.
Excalidraw 架构师
概述
通过页面运行时 API 编写场景元素(矩形、文本、箭头)在 Excalidraw 中生成结构化架构图,并根据用户反馈快速迭代。
工作流程
1) 打开并验证 Excalidraw 标签页
在浏览器工具中打开 https://excalidraw.com/,所有编辑操作保持使用相同的 targetId。
如果用户已打开画板,则复用该标签页,不创建新标签页。
2) 从页面获取 Excalidraw 运行时 API
使用 evaluate 操作从 React fiber 树中定位 excalidrawAPI。
如果 API 查找失败,刷新一次后重试。
使用以下查找逻辑(或等效方法):
- - 查找 .excalidraw 根元素
- 读取 reactFiber$*
- 遍历子/兄弟 fiber
- 选择 memoizedProps.excalidrawAPI.updateScene 存在的节点
3) 根据请求的架构构建场景元素
将用户请求转换为:
- - 容器块(矩形)
- 分区标签和正文文本
- 块之间的方向箭头
优先采用清晰易读的布局:
- - 顶部放置标题
- 除非用户另有要求,数据流从左到右
- 保持足够间距避免重叠
4) 将场景写入画布
调用 api.updateScene({ elements, appState }),然后调用 api.scrollToContent(elements, { fitToContent: true })。
当用户请求更改时,确定性重写整个场景(除非用户要求微小编辑,否则不部分修补随机元素)。
5) 确认结果
发送简短的完成消息,并说明更改内容。
编辑规则
- - 保留用户的范围边界(例如:只绘制到原始数据池)。
- 保持语言简洁且业务可读。
- 优先使用完整标签而非缩写。
- 如果文本过于密集,拆分为多行。
- 如果用户要求仅一层,明确删除下游块。
可复用资源
scripts/
- - scripts/generateexcalidrawscene.py:将 JSON 规范转换为 Excalidraw 元素 JSON。
references/
- - references/excalidraw-api-snippets.md:经过测试的浏览器 evaluate 调用的 API 发现和更新代码片段。
当图表较大或需要可重复生成时,使用脚本/资源。