Agentic Slides & Diagrams
Two Claude Code skills I built at an IT consultancy. A repo or plan goes in, and out come slides and architecture diagrams in the company's design.
Python · TS · Claude Code · Agentic Coding · Prompt Engineering · NodeJs · D2 · PptxGenJS · python-pptx · SVG · LibreOffice · Poppler · resvg · ELK · Tabler Icons · Unsplash API · Pexels API · Imgflip
A Repo In, Slides Out
Presenting a project means copying facts into slides and drawing the architecture again, in a new style each time. So I built two Claude Code agent skills. The slides skill turns a repository or a plan into a finished presentation. The diagram skill draws the architecture diagrams for it.
Both use the company's corporate design, so nothing needs restyling afterwards. Everyone in the company can use them, and people do. Getting them to work was quick. Most of the work went into edge cases and layout. The diagrams on this page are redrawn in the style of this site. The originals belong to the company.
The Slides Build Themselves
The slides skill reads the repository or plan and writes an outline. Images come from Unsplash and Pexels, memes from Imgflip. PptxGenJS or python-pptx write a real PPTX file. LibreOffice and Poppler export it as PDF and render a thumbnail per slide. The result can be opened and presented without manual work.
The Model Reviews Its Own Slides
Some layout problems only show once a slide is rendered. The rendered thumbnails go back to the model. It looks at each slide, fixes what's wrong in the source and renders again.
A Spec, Not Hand-Tuned SVG
Diagrams drawn by hand look different every time, and the same happens when an agent hand-tunes SVG. Colors get picked per node and the style changes with every diagram. So the agent never draws. It writes a small spec with tiers, nodes and edges. One function, render_diagram(), turns that into an SVG, and all styling rules live in that function.
Every tier (a deployment unit) has one color, used by its nodes and its border. Edges stay grey. What an edge means is written in its label, f.e. a protocol or a verb.
Mermaid Didn't Make the Cut
I tried Mermaid, Graphviz and draw.io XML first. None of them looked good, even after adjusting them. Now the spec is compiled to D2 and laid out with ELK. ELK routes edges at right angles with rounded corners. D2 also has a grid layout. It gives tidy rows and columns but messy edges, so it isn't used.
Render Twice, Keep What Fits 16:9
You can give ELK a direction, but there is no setting for the aspect ratio. A graph with many branches comes out much too wide or much too tall, and neither fits on a slide. So every diagram is rendered twice, left to right and top to bottom. The skill compares both and keeps the wider one if it still fits 16:9. If neither fits, it keeps the narrower one.
Fixing D2's Output With Regex
D2's raw SVG didn't look right. Edges collided with the tier borders and edge labels sat on top of lines. Titles also sat inside the borders instead of on them. So a post-processing step rewrites the SVG. Every edge gets a white halo that cuts a gap where it crosses a border, and every edge label gets a white box behind it, so the routing doesn't have to avoid labels. Each node gets a chip with its runtime or vendor, f.e. React or NestJS, and the tier title moves onto the border line.
This is regex over another tool's output, and label widths are guessed from the character count. A new D2 version could break it.
Nothing to Install
D2, resvg, the fonts and the icons are heavy. One D2 binary alone is ~48 MB. They are bundled once inside the slides skill, per OS: Windows, macOS on Intel and Apple Silicon, and Linux. The diagram skill picks the right binary at runtime. The Python side only uses the standard library, so there is nothing to install.
The PNG That Lies About the Font
The skill can render a quick PNG preview with resvg. resvg ignores @font-face, so the preview always shows a fallback font. The skill's own instructions say to judge fonts in the SVG and never in the PNG.