Summary

A practical case study of building a Claude Code Skill that automatically generates and updates Excalidraw architecture diagrams from Terraform codebases. The author solves the “always outdated diagrams” problem (common in infrastructure-as-code projects) by teaching Claude the Excalidraw JSON format once via a Skill file, then using it to scan codebases and produce valid .excalidraw files with proper labels and elbow arrows. Applied to an EKS AI/ML stack with Karpenter, GPU workloads, and Rafay orchestration.

解決基礎設施即代碼專案中「架構圖永遠過時」問題的 Claude Code Skill 案例。透過一個 Skill 文件教會 Claude Excalidraw JSON 格式,即可從 Terraform 代碼庫自動生成和更新有效的架構圖。

Key Points

  • Problem: Mermaid diagrams get cluttered with 15+ resources; manual Excalidraw requires constant updates (always stale)
  • Solution: Claude Code Skill teaches the Excalidraw JSON format once; reusable across all infrastructure repos
  • Skills chosen over ad-hoc prompts/plugins because they’re the simplest approach to test quality before investing in MCP servers or hooks
  • Generated diagrams understand old diagram context when updating — produces more accurate incremental changes vs. full regeneration
  • Code available on GitHub (ooiyeefei/ccc) for the skill; sample EKS repo at (ooiyeefei/rafay-templates)

Insights

The approach of “teach format once, reuse everywhere” via Skills is a generalizable pattern for any output format that Claude doesn’t natively understand (custom JSON schemas, domain-specific file formats, proprietary config structures). The key insight that updating an existing diagram with context produces better results than regenerating from scratch is because the model can reason about what changed rather than trying to infer the full intent from scratch. This parallels how good engineers work on incremental refactors rather than rewrites.

Connections

Raw Excerpt

As I continue working on the project, Claude Code can update the diagram, by understanding the up-to-date codebase, comparing against the old diagram which give useful contexts sometimes.