com um clique
text2diagram
使用 D2 语言创建各种类型的图表(流程图、架构图、组织结构图等)并生成 SVG
Instalar com Codex ou Claude Copie este prompt, cole no Codex, Claude ou outro assistente e deixe que ele revise a página da skill e instale para você.
Menu
使用 D2 语言创建各种类型的图表(流程图、架构图、组织结构图等)并生成 SVG
Instalar com Codex ou Claude Copie este prompt, cole no Codex, Claude ou outro assistente e deixe que ele revise a página da skill e instale para você.
Baseado na classificação ocupacional SOC
The only skill for all PPT/presentation creation and editing tasks. Any requests involving PowerPoint, PPT, PPTX, slides or presentations must be processed using this skill, including but not limited to: creating, generating, editing, modifying, redesigning, formatting, beautifying or converting presentations, as well as modifying .pptx files uploaded by users.\nImportant note: Presentation creation must use the PPTD domain-specific language (.pptd/.page) provided by this skill. Direct creation, editing or generation of .pptx files using python-pptx, OpenXML SDK or any other libraries/methods is prohibited.
Git 工作流指南,包括初始化仓库、提交更改、创建分支、合并代码、查看历史、撤销更改等常见操作
| name | text2diagram |
| description | 使用 D2 语言创建各种类型的图表(流程图、架构图、组织结构图等)并生成 SVG |
| trigger | 当用户需要创建、编辑或生成图表、流程图、架构图、组织结构图时使用此技能 |
使用 D2 语言创建各种类型的图表:流程图、架构图、组织结构图、网络图等。
确保系统已安装 D2
d2 --version
如果未安装,请参考 D2 官方文档 或使用:
curl -fsSL https://d2lang.com/install.sh | sh -s --
学习 D2 语法
参考示例
examples/ 目录中的示例文件编写 D2 文件
.d2 文件并编写 D2 代码d2 input.d2 output.svg 生成图表应用主题
d2 --theme 300 input.d2 output.svg 应用主题classes 定义可重用的样式vars 定义全局变量# hello.d2
x -> y
生成图表:
d2 hello.d2 hello.svg
# styled.d2
classes: {
server: {
style: {
fill: "#E1F5FE"
stroke: "#0288D1"
}
}
}
web: Web 服务器 {
class: server
}
db: 数据库 {
shape: cylinder
}
web -> db: 查询
生成图表:
d2 styled.d2 styled.svg
# themed.d2
vars: {
d2-config: {
theme-id: 300 # Terminal 主题
}
}
start -> process -> end
生成图表:
d2 themed.d2 themed.svg
# 或者使用命令行参数
d2 --theme 300 themed.d2 themed.svg
当用户请求创建图表时,按以下步骤操作:
根据需要查阅以下文档:
| 需求 | 查看文档 | 优先级 |
|---|---|---|
| 不熟悉 D2 语法 | quick-start.md | 高 |
| 需要查找特定语法 | SYNTAX.md | 高 |
| 参考类似示例 | EXAMPLES.md 或 examples/ | 高 |
| 需要使用图标 | ICONS.md | 中 |
| 需要设计指导 | BEST_PRACTICES.md | 中 |
| 选择合适的主题 | THEMES.md | 中 |
| 遇到安装问题 | INSTALL.md | 低 |
重要提示:
.d2 文件# 基本生成
d2 input.d2 output.svg
# 使用主题(参考 THEMES.md)
d2 --theme 300 input.d2 output.svg
常见任务的文档指引:
| 任务 | 主要文档 | 辅助文档 |
|---|---|---|
| 学习基础 | quick-start.md | SYNTAX.md, examples/basic/ |
| 创建流程图 | SYNTAX.md, EXAMPLES.md | examples/basic/flow-chart.d2 |
| 创建架构图 | SYNTAX.md, EXAMPLES.md | examples/real-world/ |
| 使用图标 | ICONS.md | SYNTAX.md |
| 选择主题 | THEMES.md | EXAMPLES.md |
| 优化代码 | BEST_PRACTICES.md | SYNTAX.md |
| 解决问题 | SYNTAX.md, BEST_PRACTICES.md | EXAMPLES.md |
| 安装 D2 | INSTALL.md | README.md |
# 基本转换
d2 input.d2 output.svg
# 使用主题
d2 --theme 300 input.d2 output.svg
# 导出为 PNG
d2 input.d2 output.png
# 导出为 PDF
d2 input.d2 output.pdf
# 设置布局引擎
d2 --layout elk input.d2 output.svg
本 skill 包含以下文档,按重要性和使用场景分类:
SYNTAX.md - D2 语法完整参考
quick-start.md - 5 分钟快速入门
README.md - 项目总览
ICONS.md - 图标参考清单
EXAMPLES.md - 示例集合
BEST_PRACTICES.md - 最佳实践
THEMES.md - 主题系统
INSTALL.md - 安装指南
作用:D2 的详细安装步骤、故障排除
何时查看:
重要性:★★☆☆☆ 一次性使用
作用:便捷的 D2 编译脚本,支持主题切换
何时使用:
重要性:★☆☆☆☆ 可选工具
examples/ 目录包含可直接运行的示例:
examples/basic/ - 基础示例(3个)examples/intermediate/ - 中级示例(3个)examples/advanced/ - 高级示例(2个)examples/real-world/ - 真实场景示例(3个)学习顺序(推荐):
工作时的查阅顺序:
examples/basic/ - 基础示例
flow-chart.d2 - 简单流程图tree.d2 - 树形结构network.d2 - 网络图examples/intermediate/ - 中级示例
with-classes.d2 - 使用类grid-layout.d2 - 网格布局styled.d2 - 样式自定义examples/advanced/ - 高级示例
complex-nested.d2 - 复杂嵌套结构vector-grid.d2 - 向量网格examples/real-world/ - 真实场景示例
cicd-pipeline.d2 - CI/CD 流程system-architecture.d2 - 系统架构org-structure.d2 - 组织结构A: D2 是专门为现代软件架构图设计的,具有以下优势:
A: D2 支持 SVG(默认)、PNG 和 PDF 格式。SVG 是推荐格式,因为它是矢量格式,可以无损缩放。
A: 参考 THEMES.md,其中列出了所有 21 个主题及其适用场景。一般来说:
A: 使用网格布局和嵌套结构:
grid-columns: 3, grid-rows: 3parent: { child: Child }direction: down|right|up|leftclasses 重用样式,保持代码整洁# 添加注释,提高代码可读性examples/ 目录中的示例文件