Prompt To Drawio
Use this skill to run a CLI-only version of Next AI Draw.io capabilities.
Capability Set
- 1. Prompt ->
.drawio generation. - Prompt-driven edit on existing diagrams (ID-based operations).
- Optional image export (
png, svg, pdf, jpg). - Context ingestion from local files (
txt/md/json/csv/pdf/image) and URLs. - Shape library documentation injection (
aws4, gcp2, azure2, kubernetes, etc.). - Visual quality validation with retry loops.
- History snapshot backup before edits.
Runtime Script
Primary entrypoint:
Subcommands:
- - INLINECODE11
- INLINECODE12
- INLINECODE13
- INLINECODE14
- INLINECODE15
Compatibility:
- - Legacy usage without subcommand is treated as
generate.
Runtime Modes
Mode A (default, recommended): in-session LLM mode
- - If the assistant is directly executing this skill inside a Codex/LLM session, generation/edit can be done by the session model itself.
- In this mode,
DRAWIO_LLM_API_KEY is not required by the skill workflow.
Mode B: standalone CLI mode
- - If you run
prompt_to_drawio.py generate|edit|validate as an independent subprocess that must call a model API by itself, then API key is required. - Supported env key names:
DRAWIO_LLM_API_KEY (preferred) or OPENAI_API_KEY. - Default key-loading rule: script auto-loads nearest
.env from current working directory upward (first match), then reads key variables from it. - Override dotenv path with
DRAWIO_DOTENV_FILE=/absolute/path/.env. - Precedence: CLI flag
--api-key/--validation-api-key > existing process env > auto-loaded .env. - New runtime controls:
-
--no-dotenv: disable
.env auto-loading.
-
--dotenv-file /abs/path/.env: use specific dotenv file.
-
--no-config-summary: silence startup effective-config print.
-
--no-model-preflight: skip provider-side model existence preflight.
Optional env overrides for standalone CLI mode:
CODEBLOCK0
Google OpenAI-Compatible Example
CODEBLOCK1
Model naming notes:
- - Recommended baseline:
gemini-3-pro-preview (or latest model shown by provider model listing). - Avoid stale/nonexistent names such as
gemini-3-pro unless your provider explicitly lists it.
Workflows
1) Create Diagram
CODEBLOCK2
2) Create Diagram from Image/PDF/URL Context
CODEBLOCK3
3) Edit Existing Diagram
CODEBLOCK4
4) Export Only
CODEBLOCK5
5) Validation Only
CODEBLOCK6
6) Shape Library Discovery
CODEBLOCK7
Output Contract
Always surface generated file paths exactly as printed by script:
- - INLINECODE33
- INLINECODE34 (if requested and successful)
- INLINECODE35 (for edits)
- INLINECODE36 block when validation runs
Diagnostics:
- - On startup, script prints effective runtime config summary to
stderr (dotenv source, effective model/base-url, key presence mask). - On JSON parse failures, raw model response is dumped to a temp file and the error includes that path.
Do not claim export success unless target file exists.
Prompt To Drawio
使用此技能运行Next AI Draw.io功能的纯CLI版本。
能力集
- 1. 提示词 -> .drawio 生成。
- 基于提示词对现有图表进行编辑(基于ID的操作)。
- 可选图片导出(png、svg、pdf、jpg)。
- 从本地文件(txt/md/json/csv/pdf/image)和URL导入上下文。
- 形状库文档注入(aws4、gcp2、azure2、kubernetes等)。
- 带重试循环的视觉质量验证。
- 编辑前进行历史快照备份。
运行时脚本
主要入口点:
- - /Users/zhaofengli/.codex/skills/prompt-to-drawio/scripts/prompttodrawio.py
子命令:
- - generate
- edit
- export
- validate
- library
兼容性:
- - 不使用子命令的旧版用法视为 generate。
运行模式
模式A(默认,推荐):会话内LLM模式
- - 如果助手直接在Codex/LLM会话内执行此技能,生成/编辑可由会话模型本身完成。
- 在此模式下,技能工作流不需要 DRAWIOLLMAPI_KEY。
模式B:独立CLI模式
- - 如果以独立子进程方式运行 prompttodrawio.py generate|edit|validate,且必须自行调用模型API,则需要API密钥。
- 支持的环境变量键名:DRAWIOLLMAPIKEY(首选)或 OPENAIAPIKEY。
- 默认密钥加载规则:脚本从当前工作目录向上自动加载最近的 .env 文件(首次匹配),然后从中读取密钥变量。
- 使用 DRAWIODOTENV_FILE=/absolute/path/.env 覆盖dotenv路径。
- 优先级:CLI标志 --api-key/--validation-api-key > 现有进程环境变量 > 自动加载的 .env。
- 新的运行时控制:
- --no-dotenv:禁用 .env 自动加载。
- --dotenv-file /abs/path/.env:使用特定的dotenv文件。
- --no-config-summary:静默启动时的有效配置打印。
- --no-model-preflight:跳过提供方侧的模型存在性预检。
独立CLI模式的可选环境变量覆盖:
bash
export DRAWIOLLMAPI_KEY=
export DRAWIOLLMBASE_URL=https://api.openai.com/v1
export DRAWIOLLMMODEL=gpt-4.1
export DRAWIOVALIDATIONMODEL=gpt-4.1
export DRAWIOVALIDATIONAPIKEY=$DRAWIOLLMAPIKEY
export DRAWIOVALIDATIONBASEURL=$DRAWIOLLMBASEURL
Google OpenAI兼容示例
bash
export DRAWIOLLMAPIKEY=aistudiokey>
export DRAWIOLLMBASE_URL=https://generativelanguage.googleapis.com/v1beta/openai/
export DRAWIOLLMMODEL=gemini-3-pro-preview
export DRAWIOVALIDATIONAPIKEY=$DRAWIOLLMAPIKEY
export DRAWIOVALIDATIONBASEURL=$DRAWIOLLMBASEURL
export DRAWIOVALIDATIONMODEL=gemini-3-pro-preview
模型命名说明:
- - 推荐基线:gemini-3-pro-preview(或提供方模型列表中显示的最新模型)。
- 避免使用过时/不存在的名称,如 gemini-3-pro,除非您的提供方明确列出。
工作流
1) 创建图表
bash
python3 /Users/zhaofengli/.codex/skills/prompt-to-drawio/scripts/prompttodrawio.py generate \
--prompt 创建用户登录 + MFA + 会话流程图 \
--out-drawio /absolute/path/auth-flow.drawio \
--out-image /absolute/path/auth-flow.png \
--validate \
--validate-soft
2) 从图片/PDF/URL上下文创建图表
bash
python3 /Users/zhaofengli/.codex/skills/prompt-to-drawio/scripts/prompttodrawio.py generate \
--prompt 复制架构风格并提高可读性 \
--file /absolute/path/reference-arch.png \
--file /absolute/path/requirements.pdf \
--url https://example.com/spec \
--shape-library aws4 \
--out-drawio /absolute/path/cloud.drawio \
--out-image /absolute/path/cloud.svg
3) 编辑现有图表
bash
python3 /Users/zhaofengli/.codex/skills/prompt-to-drawio/scripts/prompttodrawio.py edit \
--in-drawio /absolute/path/cloud.drawio \
--prompt 在ALB前添加WAF,并将应用层拆分为两个服务 \
--out-drawio /absolute/path/cloud-v2.drawio \
--out-image /absolute/path/cloud-v2.png \
--validate
4) 仅导出
bash
python3 /Users/zhaofengli/.codex/skills/prompt-to-drawio/scripts/prompttodrawio.py export \
--in-drawio /absolute/path/cloud-v2.drawio \
--out-image /absolute/path/cloud-v2.pdf
5) 仅验证
bash
python3 /Users/zhaofengli/.codex/skills/prompt-to-drawio/scripts/prompttodrawio.py validate \
--in-drawio /absolute/path/cloud-v2.drawio \
--fail-on-critical
6) 形状库发现
bash
python3 /Users/zhaofengli/.codex/skills/prompt-to-drawio/scripts/prompttodrawio.py library --list
python3 /Users/zhaofengli/.codex/skills/prompt-to-drawio/scripts/prompttodrawio.py library --name aws4
输出约定
始终按脚本打印的准确路径显示生成的文件路径:
- - DRAWIOFILE=...
- IMAGEFILE=...(如果请求且成功)
- BACKUPFILE=...(用于编辑)
- 运行验证时显示 VALIDATIONJSON= 块
诊断信息:
- - 启动时,脚本将有效运行时配置摘要打印到 stderr(dotenv来源、有效模型/基础URL、密钥存在掩码)。
- 当JSON解析失败时,原始模型响应将转储到临时文件,错误信息中包含该路径。
除非目标文件存在,否则不要声称导出成功。