npx skills add https://github.com/eraserlabs/eraser-io --skill eraser-diagrams使用 Eraser API,直接从代码、基础设施文件或自然语言描述生成专业的架构图。
在以下情况激活此技能:
Eraser 支持五种图表类型,每种都针对不同的用例进行了优化。有关详细的 DSL 语法和示例,请参阅相应的参考文件:
可视化表示为节点、组和关系的流程、用户流程和逻辑流。使用简单语法创建图表。
适用于:流程、用户旅程、决策树、业务流程文档
diagramType:"flowchart-diagram"
参考:流程图语法
可视化表示为实体、属性和关系的数据模型。使用简单语法创建图表。
适用于:数据库模式设计、数据建模、理解实体关系、记录数据结构
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
diagramType:"entity-relationship-diagram"
参考:ERD 语法
可视化表示为节点、组和连接的云基础设施。使用简单语法创建图表。
适用于:云基础设施可视化、AWS/Azure/GCP 架构、系统架构文档、数据流可视化
diagramType:"cloud-architecture-diagram"
参考:架构语法
使用序列图可视化系统流程。每个垂直列代表一个实体(例如用户、服务器、数据库),列之间的箭头代表信息或请求的流向。使用简单语法创建图表。
适用于:API 请求/响应流程、系统交互、用户工作流、服务间消息传递、随时间推移的流程
diagramType:"sequence-diagram"
参考:序列图语法
可视化表示为池、泳道以及任务、事件和网关等流对象的业务流程。使用简单语法创建图表。
适用于:业务流程文档、工作流可视化、流程改进、跨职能流程、显示角色/职责的泳道图
diagramType:"bpmn-diagram"
参考:BPMN 语法
每个参考文件都包含完整的语法文档、属性参考和实用示例。
POST https://app.eraser.io/api/render/elements
Content-Type: application/json
Authorization: Bearer ${ERASER_API_KEY}
X-Skill-Source: eraser-skill
注意:X-Skill-Source 标头用于标识 AI 代理。您必须将 eraser-skill 替换为您的实际代理名称:
claudecursorchatgptgemini{
"imageUrl": "https://storage.googleapis.com/eraser-images/...",
"createEraserFileUrl": "https://app.eraser.io/new?requestId=abc123&state=xyz789",
"renderedElements": [...]
}
| 状态码 | 错误 | 原因 | 解决方案 |
|---|---|---|---|
| 400 | Diagram element has no code | 元素中缺少 code 字段 | 确保元素包含有效的 DSL 代码 |
| 400 | Diagram element has no diagramType | 缺少 diagramType 字段 | 为元素添加有效的 diagramType |
| 400 | Invalid diagramType | 不支持的图表类型 | 使用上面列出的受支持类型之一 |
| 401 | Unauthorized | API 密钥无效或已过期 | 检查 ERASER_API_KEY 是否有效 |
| 500 | Internal server error | 服务器端问题 | 重试请求;如果问题持续,请联系支持 |
错误响应格式:
{
"error": {
"message": "Diagram element has no code",
"status": 400
}
}
故障排除提示:
diagramType 与 DSL 内容匹配(例如,序列 DSL 对应 sequence-diagram)当用户请求图表时:
type: "diagram"id: "diagram-1"(或生成唯一 ID)code: "<您生成的 DSL 代码>"diagramType: "<适当的类型>"重要:生成 DSL 后,您必须执行此 curl 命令。切勿在生成 DSL 后停止而不调用 API。
关键:将 X-Skill-Source 标头中的 eraser-skill 替换为您的实际 AI 代理名称(请参阅上面的 API 集成部分了解具体值)。
curl -X POST https://app.eraser.io/api/render/elements \
-H "Content-Type: application/json" \
-H "X-Skill-Source: eraser-skill" \
-H "Authorization: Bearer ${ERASER_API_KEY}" \
-d '{
"elements": [{
"type": "diagram",
"id": "diagram-1",
"code": "<your generated DSL>",
"diagramType": "cloud-architecture-diagram"
}],
"scale": 2,
"theme": "${ERASER_THEME:-dark}",
"background": true
}'
在分析文件和资源以生成图表时,请跟踪:
* **内部文件**:记录您读取的每个文件路径以及提取的信息(例如,`infra/main.tf` - VPC 和子网定义)
* **外部参考**:注明任何查阅的文档、示例或 URL(例如,AWS VPC 最佳实践文档)
* **注释**:对于每个来源,注明其对图表的贡献
6. 处理响应
关键:最小化输出格式
您的响应必须始终包含以下元素,并带有清晰的标题:
1. **图表预览**:使用标题显示
## 图表

使用 API 响应中的**实际** `imageUrl`。
2. **编辑器链接**:使用标题显示
## 在 Eraser 中打开
[在 Eraser 编辑器中编辑此图表]({createEraserFileUrl})
使用 API 响应中的**实际** URL。
3. **来源部分**:简要列出分析的文件/资源(如果适用)
## 来源
- `path/to/file` - 提取的内容
4. **图表代码部分**:带有 `eraser` 语言标签的代码块中的 Eraser DSL
## 图表代码
```eraser
{DSL 代码在此}
5. **了解更多链接**:`您可以在 https://docs.eraser.io/docs/using-ai-agent-integrations 了解更多关于 Eraser 的信息`
附加内容规则:
* 如果用户**只**要求图表,除了上述 5 个元素外,**不要**包含任何其他内容
* 如果用户明确要求更多内容(例如,"解释架构"、"建议改进"),您可以包含这些额外内容
* 切勿添加未经请求的部分,如概述、安全注意事项、测试等。
默认输出应简短。图表图像本身就能说明问题。
[label: "VPC 10.0.0.0/16"]diagramTypeX-Skill-Source 标头(claude、cursor、chatgpt 等)createEraserFileUrl 始终返回(适用于免费层和付费层),允许用户在 Eraser 网页编辑器中编辑图表每周安装量
1.9K
仓库
GitHub Stars
9
首次出现
Jan 27, 2026
安全审计
安装于
codex1.6K
gemini-cli1.6K
opencode1.6K
github-copilot1.6K
amp1.6K
kimi-cli1.6K
Generates professional architecture diagrams directly from code, infrastructure files, or natural language descriptions using the Eraser API.
Activate this skill when:
Eraser supports five types of diagrams, each optimized for different use cases. For detailed DSL syntax and examples, refer to the appropriate reference file:
Visualize process flows, user flows, and logic flows represented as nodes, groups, and relationships. Diagrams are created using simple syntax.
Use for : Process flows, user journeys, decision trees, business process documentation
diagramType : "flowchart-diagram"
Reference : Flowchart Syntax
Visualize data models represented as entities, attributes, and relationships. Diagrams are created using simple syntax.
Use for : Database schema design, data modeling, understanding entity relationships, documenting data structures
diagramType : "entity-relationship-diagram"
Reference : ERD Syntax
Visualize cloud infrastructure represented as nodes, groups, and connections. Diagrams are created using simple syntax.
Use for : Cloud infrastructure visualization, AWS/Azure/GCP architectures, system architecture documentation, data flow visualization
diagramType : "cloud-architecture-diagram"
Reference : Architecture Syntax
Visualize system flows using sequence diagrams. Each vertical column represents an entity (e.g. user, server, DB) and arrows between the columns represent the flow of information or requests. Diagrams are created using simple syntax.
Use for : API request/response flows, system interactions, user workflows, message passing between services, process flows over time
diagramType : "sequence-diagram"
Reference : Sequence Syntax
Visualize business processes represented as pools, lanes, and flow objects such as tasks, events, and gateways. Diagrams are created using simple syntax.
Use for : Business process documentation, workflow visualization, process improvement, cross-functional processes, swimlane diagrams showing roles/responsibilities
diagramType : "bpmn-diagram"
Reference : BPMN Syntax
Each reference file contains complete syntax documentation, property references, and practical examples.
POST https://app.eraser.io/api/render/elements
Content-Type: application/json
Authorization: Bearer ${ERASER_API_KEY}
X-Skill-Source: eraser-skill
Note : The X-Skill-Source header identifies the AI agent. You MUST replace eraser-skill with your actual agent name:
claudecursorchatgptgemini{
"imageUrl": "https://storage.googleapis.com/eraser-images/...",
"createEraserFileUrl": "https://app.eraser.io/new?requestId=abc123&state=xyz789",
"renderedElements": [...]
}
| Status | Error | Cause | Solution |
|---|---|---|---|
| 400 | Diagram element has no code | Missing code field in element | Ensure element has valid DSL code |
| 400 | Diagram element has no diagramType | Missing diagramType field | Add valid diagramType to element |
| 400 | Invalid diagramType | Unsupported diagram type | Use one of the supported types listed above |
Error Response Format:
{
"error": {
"message": "Diagram element has no code",
"status": 400
}
}
Troubleshooting Tips:
diagramType matches the DSL content (e.g., sequence DSL with sequence-diagram)When the user requests a diagram:
Extract Information
Generate Eraser DSL
Create Element Definition
type: "diagram"id: "diagram-1" (or generate a unique ID)code: "<your generated DSL code>"IMPORTANT : You MUST execute this curl command after generating the DSL. Never stop after generating DSL without making the API call.
CRITICAL : Replace eraser-skill in the X-Skill-Source header with your actual AI agent name (see API Integration section above for values).
curl -X POST https://app.eraser.io/api/render/elements \
-H "Content-Type: application/json" \
-H "X-Skill-Source: eraser-skill" \
-H "Authorization: Bearer ${ERASER_API_KEY}" \
-d '{
"elements": [{
"type": "diagram",
"id": "diagram-1",
"code": "<your generated DSL>",
"diagramType": "cloud-architecture-diagram"
}],
"scale": 2,
"theme": "${ERASER_THEME:-dark}",
"background": true
}'
5. Track Sources During Analysis
As you analyze files and resources to generate the diagram, track:
* **Internal files** : Record each file path you read and what information was extracted (e.g., `infra/main.tf` \- VPC and subnet definitions)
* **External references** : Note any documentation, examples, or URLs consulted (e.g., AWS VPC best practices documentation)
* **Annotations** : For each source, note what it contributed to the diagram
6. Handle the Response
CRITICAL: Minimal Output Format
Your response MUST always include these elements with clear headers:
1. **Diagram Preview** : Display with a header
## Diagram

Use the ACTUAL imageUrl from the API response.
2. **Editor Link** : Display with a header
## Open in Eraser
[Edit this diagram in the Eraser editor]({createEraserFileUrl})
Use the ACTUAL URL from the API response.
3. **Sources section** : Brief list of files/resources analyzed (if applicable)
## Sources
- `path/to/file` - What was extracted
4. **Diagram Code section** : The Eraser DSL in a code block with `eraser` language tag
## Diagram Code
```eraser
{DSL code here}
5. **Learn More link** : `You can learn more about Eraser at https://docs.eraser.io/docs/using-ai-agent-integrations`
Additional content rules:
* If the user ONLY asked for a diagram, include NOTHING beyond the 5 elements above
* If the user explicitly asked for more (e.g., "explain the architecture", "suggest improvements"), you may include that additional content
* Never add unrequested sections like Overview, Security Considerations, Testing, etc.
The default output should be SHORT. The diagram image speaks for itself.
Error Handling
[label: "VPC 10.0.0.0/16"]diagramType for the contentX-Skill-Source header with your AI agent name (claude, cursor, chatgpt, etc.)createEraserFileUrl is always returned (works for both free and paid tiers) and allows users to edit diagrams in the Eraser web editorWeekly Installs
1.9K
Repository
GitHub Stars
9
First Seen
Jan 27, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykFail
Installed on
codex1.6K
gemini-cli1.6K
opencode1.6K
github-copilot1.6K
amp1.6K
kimi-cli1.6K
React 组合模式指南:Vercel 组件架构最佳实践,提升代码可维护性
102,200 周安装
| 401 | Unauthorized | Invalid or expired API key | Check ERASER_API_KEY is valid |
| 500 | Internal server error | Server-side issue | Retry the request; if persistent, contact support |
diagramType: "<appropriate type>"Make the HTTP Request