💡 摘要
生成高质量的 draw.io 图表,具有字体管理和日文支持等功能。
🎯 适合人群
🤖 AI 吐槽: “该项目可能通过外部依赖和 PNG 生成的 shell 执行暴露风险。确保验证和清理输入以减轻潜在的命令注入漏洞。”
该项目可能通过外部依赖和 PNG 生成的 shell 执行暴露风险。确保验证和清理输入以减轻潜在的命令注入漏洞。
Claude Skill: draw.io Diagram Generator
A Claude Code skill for generating high-quality draw.io diagrams with proper font settings, arrow placement, and Japanese text support.
Features
- Font Management: Ensures
fontFamilyis set on all text elements - Arrow Layering: Correct Z-order placement (arrows behind boxes)
- Japanese Text Support: Proper width allocation for CJK characters
- PNG Validation: Pre-commit hooks for automatic PNG generation
- Best Practices: Comprehensive checklist and examples
Installation
Plugin Installation (Recommended)
# Via Claude Code marketplace /plugin marketplace add ekusiadadus/draw-mcp # Or install directly /plugin add https://github.com/ekusiadadus/draw-mcp
Manual Installation
Clone to your Claude Code skills directory:
# Global (personal use) git clone https://github.com/ekusiadadus/draw-mcp ~/.claude/skills/draw-io # Project-specific git clone https://github.com/ekusiadadus/draw-mcp .claude/skills/draw-io
Usage
Once installed, Claude Code will automatically use this skill when you ask to create draw.io diagrams.
Example Prompts
Create a simple flowchart showing: Start -> Process -> End
Draw an architecture diagram with Web Server, API, and Database
Create a sequence diagram for user login flow
Manual Trigger
If needed, you can explicitly request the skill:
Using the draw-io skill, create a flowchart for the authentication process
Requirements
draw.io CLI (for PNG export)
macOS:
brew install --cask drawio
Linux: Download from draw.io Desktop Releases
Python (for tests and validation)
pip install pytest
Project Structure
draw-mcp/
├── .claude-plugin/
│ ├── plugin.json # Plugin manifest
│ └── marketplace.json # Marketplace configuration
├── skills/
│ └── draw-io/
│ ├── SKILL.md # Main skill definition
│ ├── reference.md # XML structure reference
│ ├── examples.md # Production-ready examples
│ └── checklist.md # Validation checklist
├── scripts/
│ └── convert-drawio-to-png.sh
├── tests/
│ └── test_drawio_skill.py
├── docs/
│ └── RULE.md
├── .pre-commit-config.yaml
├── .gitignore
├── LICENSE
└── README.md
Key Rules
1. Font Settings
<!-- In mxGraphModel --> <mxGraphModel defaultFontFamily="Noto Sans JP" ...> <!-- In EVERY text element --> <mxCell style="...fontFamily=Noto Sans JP;fontSize=18;..." />
2. Arrow Placement
Arrows must be declared FIRST in XML to render behind other elements:
<root> <!-- Arrows first (background) --> <mxCell id="arrow1" edge="1" ... /> <!-- Boxes after (foreground) --> <mxCell id="box1" vertex="1" ... /> </root>
3. Japanese Text Width
Allocate 30-40px per Japanese character:
<!-- 6 characters × 35px = 210px --> <mxGeometry width="220" ... />
4. PNG Verification
Always export to PNG and verify visually:
drawio -x -f png -s 2 -t -o diagram.png diagram.drawio
Pre-commit Hooks
This project includes pre-commit hooks for:
- XML Validation: Check font settings and structure
- PNG Conversion: Auto-generate PNG on commit
- Python Tests: Run skill validation tests
Setup:
pip install pre-commit pre-commit install
Running Tests
# Run all tests pytest tests/ -v # Run specific test file pytest tests/test_drawio_skill.py -v
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Run tests:
pytest tests/ -v - Submit a pull request
License
MIT License - see LICENSE
Related Resources
Changelog
v1.0.0 (2025-12-16)
- Initial release
- Core skill with font, arrow, and text handling
- Pre-commit hooks for validation
- Comprehensive documentation and examples
优点
- 支持日文文本和正确的字体设置
- 通过预提交钩子自动生成 PNG
- 全面的文档和示例
缺点
- 需要外部 draw.io CLI 进行 PNG 导出
- 对初学者来说安装可能较复杂
- 仅限于 draw.io 格式
相关技能
免责声明:本内容来源于 GitHub 开源项目,仅供展示和评分分析使用。
版权归原作者所有 ekusiadadus.
