ワンクリックで
dev-create-diagram
Create a matplotlib diagram for a forge-gpu lesson using the project's dark theme and visual identity
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Create a matplotlib diagram for a forge-gpu lesson using the project's dark theme and visual identity
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
Add PBR texture loading with separate roughness/metallic support to an SDL GPU project using forge_scene.h
Add Cook-Torrance PBR shading with GGX, Schlick-GGX, and Schlick Fresnel to an SDL GPU project alongside forge_scene.h
Add instanced grass rendering with segmented blades, wind animation, LOD density rings, and terrain LOD with geomorphing to an SDL GPU project
Add procedural noise texture generation to the asset pipeline — C tool, Python plugin, web UI with live preview
Add an asset pipeline lesson — hybrid Python + C track for asset processing, procedural geometry, and web frontend
Add an audio lesson — sound playback, mixing, spatial audio, DSP effects, with SDL GPU scenes and forge UI
| name | dev-create-diagram |
| description | Create a matplotlib diagram for a forge-gpu lesson using the project's dark theme and visual identity |
| disable-model-invocation | false |
Create a diagram or visualization for a forge-gpu lesson using the project's matplotlib diagram infrastructure. Diagrams increase reader engagement and help learners understand the topics being taught.
When to use this skill:
/dev-math-lesson, /dev-engine-lesson, or
/dev-gpu-lesson and want to add visual aidsWhen NOT to use this skill:
The user (or you) provides:
math/01, gpu/04, engine/04vector_addition.png, stack_vs_heap.pngIf any are missing, infer from context or ask.
Diagram functions are organized by track and lesson number under
scripts/forge_diagrams/<track>/lesson_NN.py:
scripts/forge_diagrams/math/lesson_NN.py — math lessonsscripts/forge_diagrams/gpu/lesson_NN.py — GPU lessonsscripts/forge_diagrams/engine/lesson_NN.py — engine lessonsscripts/forge_diagrams/ui/lesson_NN.py — UI lessonsscripts/forge_diagrams/assets/lesson_NN.py — asset pipeline lessonsscripts/forge_diagrams/physics/lesson_NN.py — physics lessonsscripts/forge_diagrams/audio/lesson_NN.py — audio lessonsIf a lesson_NN.py file does not exist yet for the lesson, create one.
Add a new function to the appropriate per-lesson module following the existing patterns.
Required imports and helpers:
import matplotlib.patheffects as pe
import matplotlib.pyplot as plt
import numpy as np
from .._common import FORGE_CMAP, STYLE, draw_vector, save, setup_axes
pe is needed for the text readability stroke (path_effects=[pe.withStroke(...)])
used throughout diagram code. FORGE_CMAP is a custom colormap for heatmaps and
gradient visualizations — import it when using imshow() or pcolormesh().
Theme colors — always use STYLE dict values, never hardcoded colors:
| Key | Hex | Use for |
|---|---|---|
bg | #1a1a2e | Figure and axes background |
grid | #2a2a4a | Grid lines, subtle dividers |
axis | #8888aa | Axis labels, tick labels |
text | #e0e0f0 | Primary text, titles |
text_dim | #8888aa | Secondary text, annotations |
accent1 | #4fc3f7 | Cyan — primary vectors, highlights |
accent2 | #ff7043 | Orange — secondary vectors, results |
accent3 | #66bb6a | Green — tertiary elements, normals |
accent4 | #ab47bc | Purple — special elements |
warn | #ffd54f | Yellow — annotations, important highlights |
surface | #252545 | Filled regions, box backgrounds |
Function template:
# ---------------------------------------------------------------------------
# category/NN-lesson-name — diagram_name.png
# ---------------------------------------------------------------------------
def diagram_diagram_name():
"""Brief description of what the diagram shows."""
fig = plt.figure(figsize=(W, H), facecolor=STYLE["bg"])
ax = fig.add_subplot(111)
setup_axes(ax, xlim=(...), ylim=(...))
# --- Draw content here ---
# Title with vertical padding (pad >= 12 to avoid crowding content)
ax.set_title(
"Diagram Title",
color=STYLE["text"],
fontsize=14,
fontweight="bold",
pad=12,
)
fig.tight_layout()
save(fig, "category/NN-lesson-name", "diagram_name.png")
Common figure sizes:
(7, 7) — square(10, 5) — landscape(10, 8) — tall(8, 7) to (10, 7) — balancedAfter writing the diagram function, verify these requirements:
Labels must not overlap each other or be drawn on top of lines/arrows. To prevent overlap:
label_offset parameter in draw_vector() to shift labels away from
arrows and other textax.text() calls, compute positions that avoid other
text elementsfontsize or increase figure dimensionsha (horizontal alignment) and va (vertical alignment) parameters
to anchor text away from crowded areasLines, arrows, and grid elements must not pass through text:
zorder=5 or higher so they render above linespath_effects=[pe.withStroke(linewidth=3, foreground=STYLE["bg"])]
on all text to create a background halo that visually separates text from
crossing linesThere must be visible vertical space between the title and the topmost content element (data points, arrows, labels, boxes). Crowded titles make diagrams feel cramped and reduce readability.
pad=12 or greater in ax.set_title() — this adds points of space
between the title baseline and the axes top edgefig.suptitle() instead, set y=0.97 or lower and ensure the
subplot top margin accommodates it (via fig.subplots_adjust(top=0.90) or
fig.tight_layout(rect=[0, 0, 1, 0.95]))Every color in the diagram must come from the STYLE dictionary:
"red", "blue", "#ff0000"accent1 for the primary subject,
accent2 for secondary/comparison, accent3 for tertiary/reference,
accent4 for special highlightstext for primary labels and text_dim for secondary annotationssurface for filled regions and grid for subtle structural elementsWire up the function so the CLI can find it. Three files need changes:
__init__.py — re-export the function__main__.py — import and register in DIAGRAMS dictExample for a new math lesson (math/NN):
# 1. Function is in scripts/forge_diagrams/math/lesson_NN.py (already written)
# 2. In scripts/forge_diagrams/math/__init__.py — add to __all__ and imports:
from .lesson_NN import diagram_new_concept
# ... and add "diagram_new_concept" to the __all__ list
# 3. In scripts/forge_diagrams/__main__.py:
# Import section:
from .math import diagram_new_concept
# DIAGRAMS dict:
"math/NN": [
("new_concept.png", diagram_new_concept),
],
# LESSON_NAMES:
"math/NN": "math/NN-concept-name",
Run the diagram generator to produce the PNG:
python scripts/forge_diagrams --lesson category/NN
The output goes to lessons/category/NN-name/assets/diagram_name.png at
200 DPI.
After generating, inspect the diagram for:
Add the diagram to the lesson's README.md:

Place diagrams near the text that explains the concept they illustrate — before the detailed explanation, not after it. Seeing the visual first helps the reader build intuition before reading the technical details.
Verify the new code passes linting:
uv run ruff check scripts/forge_diagrams/
uv run ruff format --check scripts/forge_diagrams/
Auto-fix if needed:
uv run ruff check --fix scripts/forge_diagrams/
uv run ruff format scripts/forge_diagrams/
setup_axes(ax, xlim=None, ylim=None, grid=True, aspect="equal")Applies the dark theme to axes: background color, grid styling, tick colors, spine colors. Call this on every axes object before drawing.
draw_vector(ax, origin, vec, color, label=None, label_offset=(0.15, 0.15), lw=2.5)Draws a labeled arrow from origin to origin + vec. The label gets a
background stroke for readability. Use label_offset to prevent overlap with
nearby elements.
save(fig, lesson_path, filename)Saves the figure to lessons/{lesson_path}/assets/{filename} at 200 DPI with
the dark background. Creates the assets directory if needed. Always call this
as the last step — it also closes the figure.
FORGE_CMAPA custom 4-color colormap (bg -> accent1 -> accent2 -> warn) for heatmaps
and gradient visualizations. Use with imshow(), pcolormesh(), etc.
All text over diagram content should use a background stroke:
ax.text(
x, y, "Label",
color=STYLE["accent1"],
fontsize=11,
fontweight="bold",
ha="center", va="center",
path_effects=[pe.withStroke(linewidth=3, foreground=STYLE["bg"])],
)
leg = ax.legend(loc="upper right", fontsize=10, framealpha=0.3,
edgecolor=STYLE["grid"])
for text in leg.get_texts():
text.set_color(STYLE["text"])
For side-by-side comparisons, use subplots and apply setup_axes to each:
fig = plt.figure(figsize=(10, 5), facecolor=STYLE["bg"])
ax1 = fig.add_subplot(121)
ax2 = fig.add_subplot(122)
setup_axes(ax1, ...)
setup_axes(ax2, ...)
from matplotlib.patches import Polygon, Rectangle, FancyBboxPatch
# Use STYLE["surface"] for fills, STYLE["accent*"] for borders
After writing the diagram function, before committing:
y = f(x), the diagram must plot that exact
functionFor a thorough cross-check, invoke /dev-review-diagrams with the lesson key.
"red" or "#ff0000" instead of
STYLE["accent2"]. Every color must come from the theme.path_effects becomes unreadable
when grid lines or other elements pass behind it.pad=0 or omitting pad in set_title(),
causing the title to sit directly on top of the data.DIAGRAMS dict in __main__.py. The CLI won't find unregistered diagrams.lesson_NN.py but not
adding it to the track's __init__.py __all__ list and imports.DIAGRAMS but not importing
the function at the top of __main__.py.ruff check and
ruff format before committing.