/tf-diagram:tf-diagramfrom tf-diagram
Generates enterprise-grade architecture diagrams from Terraform projects (.tf/.hcl). Parses resources, modules, providers and produces editable .drawio files with cloud icons and PNG previews.
Ships in tf-diagram. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
# 1. Install dependency (once)
pip install python-hcl2 --break-system-packages
# 2. Download icons (once, ~34MB)
python3 scripts/download_icons.py
# 3. Generate diagram
python3 scripts/tf_to_diagram.py <terraform_dir> --output my_arch.drawio
# 4. Optional: also export PNG
python3 scripts/tf_to_diagram.py <terraform_dir> --output my_arch.drawio --png my_arch.png
Ask the user for the Terraform project path if not already known.
If they paste .tf code, save it to /tmp/tf_project/ first.
python3 scripts/tf_to_diagram.py <dir> --output arch.drawio --png arch.png --verbose
The --verbose flag prints a full resource table with providers, tiers, regions, and
tag compliance. Always use it so you can report back to the user.
Tell the user the absolute path to the generated files:
.drawio file: open at https://app.diagrams.net (drag & drop) or VS Code Draw.io Integration extension.png file: preview in any image viewerIf running inside the Claude.ai webapp, copy files and call present_files:
cp arch.drawio /mnt/user-data/outputs/arch.drawio
cp arch.png /mnt/user-data/outputs/arch.png
Always tell the user:
app.diagrams.net (drag & drop) or VS Code Draw.io Integration extensionscripts/download_icons.pyDownloads the diagrams Python package wheel from PyPI and extracts
~1,500 official PNG icons for AWS, GCP, Azure, and Kubernetes to scripts/icons/.
Safe to run multiple times (skips if already downloaded).
scripts/tf_to_diagram.pyMain entrypoint. Orchestrates:
lib/parser.py — Parse HCL/YAML, extract resources/modules/depslib/drawio.py — Build multi-page draw.io XMLlib/renderer.py — Render PNG preview with real icons (company style)scripts/lib/parser.py.tf and .hcl files (skips .terraform/)python-hcl2, falls back to regex for malformed HCLaws_*, google_*, azurerm_*, etc.)${resource.name} interpolationdepends_on referencesscripts/lib/drawio.pytags or labels (compliance)data sourcesscripts/lib/renderer.py| Situation | Action |
|---|---|
| No .tf files found | Check path; try find <dir> -name "*.tf" |
| Icons not downloaded | Run python3 scripts/download_icons.py first |
Region shows unknown-region | Add region to provider block or use Terragrunt path convention |
| Pasted code | Save to /tmp/tf_project/main.tf, run from there |
| 100+ resources dense layout | Tell user: draw.io → Edit > Select All → Arrange > Auto Layout (Organic) |
| Malformed HCL | Regex fallback runs automatically; partial parse continues |
| Terragrunt multi-account | Path <account>/<region>/<module>/main.tf auto-detected for page split |
references/icon_map.md — Full icon path map for all supported resource typesreferences/providers.md — Provider prefix → cloud mapping, tier classificationWhat SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub anllacarpro/tf-diagram-skill --plugin tf-diagram