terraform-diagrams by eraserlabs/eraser-io
npx skills add https://github.com/eraserlabs/eraser-io --skill terraform-diagrams直接从 Terraform .tf 文件生成架构图。专门解析 Terraform 代码并可视化基础设施资源、模块及其关系。
在以下情况激活此技能:
.tf、.tfvars)并希望可视化其基础设施此技能通过解析 Terraform 代码并直接调用 Eraser API 来生成特定于 Terraform 的图表:
/api/render/elements 并设置 diagramType: "cloud-architecture-diagram"广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
当用户提供 Terraform 代码时:
resource 块(AWS、Azure、GCP 等)
* 提取 module 块及其配置
* 记录 data 源及其依赖项
* 识别 variable 和 output 定义subnet_id = aws_subnet.public.id)
* 按提供商(AWS、Azure、GCP)分组资源
* 将 VPC/VNet 识别为其他资源的容器
* 记录安全组、IAM 角色和网络规则[label: "VPC 10.0.0.0/16"]示例:
main-vpc [label: "VPC 10.0.0.0/16"] {
public-subnet [label: "Public Subnet 10.0.1.0/24"] {
web-server [icon: aws-ec2, label: "Web Server t3.micro"]
load-balancer [icon: aws-elb]
}
private-subnet [label: "Private Subnet"] {
database [icon: aws-rds]
}
}
load-balancer -> web-server
web-server -> database
4. 发起 HTTP 请求
重要:生成 DSL 后,您必须执行此 curl 命令。切勿在生成 DSL 后停止而不进行 API 调用。
关键:在下面的 X-Skill-Source 请求头中,您必须将值替换为您的 AI 代理名称:
* 如果您是 Claude (Anthropic),请使用:`claude`
* 如果您在 Cursor 中运行,请使用:`cursor`
* 如果您是 ChatGPT (OpenAI),请使用:`chatgpt`
* 如果您是 Gemini (Google),请使用:`gemini`
* 否则,请使用您模型/代理名称的小写形式
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. 在分析过程中跟踪来源
在您分析 Terraform 文件和资源以生成图表时,请跟踪:
* **内部文件**:记录您读取的每个 Terraform 文件路径以及提取的资源(例如,`infra/main.tf` - VPC 和子网定义,`infra/rds.tf` - 数据库配置)
* **外部引用**:记录任何查阅的文档、示例或 URL(例如,Terraform AWS 提供商文档、AWS 架构最佳实践)
* **注释**:对于每个来源,注明其对图表的贡献
6. 处理响应
关键:最小输出格式
您的响应必须始终包含以下元素,并带有清晰的标题:
1. **图表预览**:使用标题显示
## 图表

使用 API 响应中的实际 imageUrl。
2. **编辑器链接**:使用标题显示
## 在 Eraser 中打开
[在 Eraser 编辑器中编辑此图表]({createEraserFileUrl})
使用 API 响应中的实际 URL。
3. **来源部分**:简要列出分析的文件/资源(如适用)
## 来源
- `path/to/file` - 提取的内容
4. **图表代码部分**:带有 `eraser` 语言标签的代码块中的 Eraser DSL
## 图表代码
```eraser
{DSL code here}
5. **了解更多链接**:`您可以在 https://docs.eraser.io/docs/using-ai-agent-integrations 了解更多关于 Eraser 的信息`
附加内容规则:
* 如果用户**仅**要求图表,除了上述 5 个元素外,**不要**包含任何其他内容
* 如果用户明确要求更多内容(例如,“解释架构”、“建议改进”),您可以包含这些额外内容
* 切勿添加未经请求的部分,如概述、安全考虑、测试等。
默认输出应简短。图表图像本身就能说明问题。
# AWS Resources
resource "aws_vpc" "main" {
cidr_block = "10.0.0.0/16"
}
resource "aws_subnet" "public" {
vpc_id = aws_vpc.main.id
cidr_block = "10.0.1.0/24"
}
resource "aws_instance" "web" {
subnet_id = aws_subnet.public.id
instance_type = "t3.micro"
}
# Azure Resources (multi-provider)
resource "azurerm_resource_group" "main" {
name = "rg-main"
location = "East US"
}
resource "azurerm_virtual_network" "main" {
name = "vnet-main"
resource_group_name = azurerm_resource_group.main.name
address_space = ["10.1.0.0/16"]
}
# Module usage
module "database" {
source = "./modules/rds"
vpc_id = aws_vpc.main.id
}
解析 Terraform:
生成显示多提供商和模块结构的 DSL:
# AWS Resources
aws-vpc [label: "AWS VPC 10.0.0.0/16"] {
aws-subnet [label: "Public Subnet 10.0.1.0/24"] {
web-server [icon: aws-ec2, label: "Web Server t3.micro"]
}
}
# Azure Resources
resource-group [label: "Resource Group rg-main"] {
azure-vnet [label: "Azure VNet 10.1.0.0/16"]
}
# Module
database-module [label: "Database Module"] {
rds-instance [icon: aws-rds]
}
aws-vpc -> database-module
重要:所有标签文本必须在引号内的一行上。Terraform 特定:将模块显示为容器,按提供商分组,包含资源依赖关系。
diagramType: "cloud-architecture-diagram" 调用 /api/render/elements用户收到一个显示以下内容的图表:
每周安装数
333
仓库
GitHub 星标数
9
首次出现
2026年1月27日
安全审计
安装于
opencode281
github-copilot279
gemini-cli277
codex277
amp250
kimi-cli249
Generates architecture diagrams directly from Terraform .tf files. Specializes in parsing Terraform code and visualizing infrastructure resources, modules, and their relationships.
Activate this skill when:
.tf, .tfvars) and wants to visualize the infrastructureThis skill generates Terraform-specific diagrams by parsing Terraform code and calling the Eraser API directly:
/api/render/elements with diagramType: "cloud-architecture-diagram"When the user provides Terraform code:
Parse the Terraform
resource blocks (AWS, Azure, GCP, etc.)module blocks and their configurationsdata sources and their dependenciesvariable and output definitionsMap Relationships
subnet_id = aws_subnet.public.id)Generate Eraser DSL Convert Terraform resources to Eraser DSL:
Example:
main-vpc [label: "VPC 10.0.0.0/16"] {
public-subnet [label: "Public Subnet 10.0.1.0/24"] {
web-server [icon: aws-ec2, label: "Web Server t3.micro"]
load-balancer [icon: aws-elb]
}
private-subnet [label: "Private Subnet"] {
database [icon: aws-rds]
}
}
load-balancer -> web-server
web-server -> database
4. Make the HTTP Request
IMPORTANT : You MUST execute this curl command after generating the DSL. Never stop after generating DSL without making the API call.
CRITICAL : In the X-Skill-Source header below, you MUST replace the value with your AI agent name:
* If you are Claude (Anthropic), use: `claude`
* If you are running in Cursor, use: `cursor`
* If you are ChatGPT (OpenAI), use: `chatgpt`
* If you are Gemini (Google), use: `gemini`
* Otherwise, use your model/agent name in lowercase
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 Terraform files and resources to generate the diagram, track:
* **Internal files** : Record each Terraform file path you read and what resources were extracted (e.g., `infra/main.tf` \- VPC and subnet definitions, `infra/rds.tf` \- Database configuration)
* **External references** : Note any documentation, examples, or URLs consulted (e.g., Terraform AWS provider documentation, AWS architecture best practices)
* **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.
Handle Multiple Providers
# AWS Resources
resource "aws_vpc" "main" {
cidr_block = "10.0.0.0/16"
}
resource "aws_subnet" "public" {
vpc_id = aws_vpc.main.id
cidr_block = "10.0.1.0/24"
}
resource "aws_instance" "web" {
subnet_id = aws_subnet.public.id
instance_type = "t3.micro"
}
# Azure Resources (multi-provider)
resource "azurerm_resource_group" "main" {
name = "rg-main"
location = "East US"
}
resource "azurerm_virtual_network" "main" {
name = "vnet-main"
resource_group_name = azurerm_resource_group.main.name
address_space = ["10.1.0.0/16"]
}
# Module usage
module "database" {
source = "./modules/rds"
vpc_id = aws_vpc.main.id
}
Parses Terraform:
Generates DSL showing multi-provider and module structure:
# AWS Resources
aws-vpc [label: "AWS VPC 10.0.0.0/16"] {
aws-subnet [label: "Public Subnet 10.0.1.0/24"] {
web-server [icon: aws-ec2, label: "Web Server t3.micro"]
}
}
# Azure Resources
resource-group [label: "Resource Group rg-main"] {
azure-vnet [label: "Azure VNet 10.1.0.0/16"]
}
# Module
database-module [label: "Database Module"] {
rds-instance [icon: aws-rds]
}
aws-vpc -> database-module
Important : All label text must be on a single line within quotes. Terraform-specific: Show modules as containers, group by provider, include resource dependencies.
/api/render/elements with diagramType: "cloud-architecture-diagram"User receives a diagram showing:
Weekly Installs
333
Repository
GitHub Stars
9
First Seen
Jan 27, 2026
Security Audits
Gen Agent Trust HubFailSocketWarnSnykFail
Installed on
opencode281
github-copilot279
gemini-cli277
codex277
amp250
kimi-cli249
Snowflake平台技能:使用CLI、Cortex AI函数和Snowpark构建AI数据云应用
326 周安装
AI代码实施计划编写工具 - 遵循TDD原则的详细开发任务分解指南
326 周安装
Cloudflare Agents SDK:构建AI驱动的自主智能体,支持可恢复流式传输与持久化状态
326 周安装
Cloudflare Vectorize 完整指南:全球分布式向量数据库,实现语义搜索与RAG应用
326 周安装
写作技能卓越版:AI技能开发模板与SEO优化指南
326 周安装
Claude Code 技能开发指南:创建、管理和优化技能的最佳实践
326 周安装
[label: "VPC 10.0.0.0/16"]