Dev final pass

From Nebulavenus/forge-gpu · View interactive version

Dev final pass is an AI agent skill from the GitHub repository Nebulavenus/forge-gpu. Run a quality review pass on a lesson before publishing, catching recurring issues found across project PR history

How to use this skill

Skill file

Run a systematic quality review on any lesson (GPU, math, engine, UI, physics,

audio, or asset pipeline) before creating a PR with /dev-create-pr. This skill

encodes recurring themes from PR review feedback across the project's history.

The user provides:

If missing, infer from the current branch name or most recent lesson directory.

How to run this skill

Work through each section below in order. For each check, read the relevant

files and verify compliance. Report a summary at the end with pass/fail per

section and specific issues found.

Be literal and exhaustive. This is C — no RAII, no garbage collector. Every

resource you acquire must be released on every exit path, every struct field

must be documented, every error must be handled. Do not rationalize away

findings with "it's probably fine" or "the section comment covers it." If the

check says every field, check every field. If it says every error path, trace

every error path.

Use a Task agent (model: haiku) for builds, shader compilation, linting, and

other command execution — never run those directly from the main agent.


0. Required files

Verify the lesson has all required pieces.

What to check:

lessons) — asset lessons may use Python entry points instead

lessons that are pure Python do not need one)

audio lessons) — not just a placeholder

(C lessons only)

Shader directory: Only required if the lesson has its own shaders beyond

what forge_scene.h provides. GPU lessons using forge_scene.h for the

rendering baseline do not need a shaders/ directory unless they add

lesson-specific shaders.


1. SDL GPU bool return checks (40+ PR comments historically)

This is the single most common PR finding. Every SDL function that returns

bool must be checked. Search all .c and .h files in the lesson

directory (not just main.c) for every SDL call and verify each one that

returns bool has error handling.

Functions that return bool (non-exhaustive):

Required pattern:

if (!SDL_SomeFunction(args)) {
    SDL_Log("SDL_SomeFunction failed: %s", SDL_GetError());
    /* clean up any resources allocated so far */
    return false; /* or SDL_APP_FAILURE */
}

What to check:

How to search: Use Grep for patterns like SDL_Submit, SDL_SetGPUSwapchain,

SDL_Init(, SDL_Claim across all .c and .h files in the lesson directory

and verify each has an if (!...) wrapper.

Skip for: math lessons, engine lessons, UI lessons, asset lessons (no SDL

GPU calls).


2. Command buffer lifecycle (acquired from Lesson 24 review)

Every acquired command buffer must be either submitted or canceled. There

is no automatic cleanup — an abandoned command buffer is a resource leak. This

is C: if you acquire it, you release it, on every path.

Key SDL3 constraint: SDL_CancelGPUCommandBuffer is not allowed after

a swapchain texture has been acquired on that command buffer. After swapchain

acquisition, you must submit (even on error).

What to check:

every code path that follows — including early returns from failed

BeginRenderPass, failed ensure_* helpers, etc.

SDL_CancelGPUCommandBuffer(cmd)

SDL_SubmitGPUCommandBuffer(cmd) (submit the partial/empty command buffer)

command buffer and returns SDL_APP_CONTINUE

Skip for: math, engine, UI, asset lessons.


3. Magic numbers (20+ PR comments)

Every numeric literal that represents a tuning parameter, spec-defined default,

buffer size, or domain constant must be a #define or enum at the top of the

file (or in a shared header if reused).

What to check:

alpha cutoff, 0.3f rotation speed, 50.0f light distance)

(#define AABB_SENTINEL 1e30f)

they are inherent to the math (e.g. 2.0 * dot(N, I) in reflection) — but

domain-specific multipliers should be named


4. Resource leaks on error paths (15+ PR comments)

When initialization fails partway through, all resources allocated before the

failure point must be released. This is C — no destructors, no RAII, no GC.

If you allocate it, you must free it on every exit path.

What to check:

and samplers allocated earlier in the same function

can release partial uploads

NULL on failure and don't leak internal resources

in SDL_AppQuit must also be freed in init_fail (including conditional

resources like #ifdef FORGE_CAPTURE)

(some resources recreated, some not) without leaking

Skip for: math, engine, UI, asset lessons (no GPU resources).


5. Naming conventions (15+ PR comments)

Public API (in common/ headers): Prefix_PascalCase for types

(e.g. ForgeGltfScene), prefix_snake_case for functions

(e.g. forge_gltf_load).

Internal typedefs (in lesson main.c): PascalCase for struct typedefs

(e.g. SceneVertex, VertUniforms, GpuPrimitive). This is the project

convention, confirmed in .coderabbit.yaml and consistent across all lessons.

Local variables and app_state: lowercase_snake_case.

What to check:

(e.g. VertUniforms, not vertUniforms or vert_uniforms)

all per-session state and is always lowercase by convention)


6. Per-field intent comments (15+ PR comments)

Every struct field needs an inline comment — no exceptions, no "the section

header covers it." Section headers group related fields; inline comments

explain each individual field's purpose, units, format, or valid range.

What to check:

headers. Every pipeline, texture, sampler, buffer, setting, and state

variable gets its own comment explaining what it is, its format/units

where applicable, and how it's used

document each field


7. Spec and documentation accuracy (5+ PR comments)

When referencing specifications (glTF 2.0, Vulkan, etc.) or external standards,

the wording must match the spec's normative language.

What to check:

the meaning)


8. Skill documentation completeness (5+ PR comments)

The matching skill in .claude/skills/<topic>/SKILL.md must have all required

sections.

What to check:


9. README structure and content

What to check:

the top (not a placeholder)

the top) — math results are text output that would be intimidating before

the lesson content

section immediately before "Building" that lists each shader file with a

brief description of what it does

(per CLAUDE.md tone principles)


10. Concept introduction for new readers

**Lessons are written for readers who know nothing unless a previous lesson

taught it.** Every concept, API, tool, or term that appears for the first time

must be briefly defined in the README — or the README must link to the specific

earlier lesson or engine/math lesson that introduced it.

What to check:

briefly explained (what it does, why it is needed) — not just named

swapchain, render pass, command buffer, pipeline, vertex buffer, shader,

depth buffer) has a plain-language definition before or alongside its first

use

"back-face culling") are defined when first used, or explicitly deferred

with a note pointing to the future lesson that will cover them

background on foundational topics

concepts (vectors, matrices, coordinate spaces) for the first time

assumption that "everyone knows what this is"


11. main.c structure (from publish-lesson validation)

What to check:

SDL_AppIterate, SDL_AppQuit

what

(SDL_fabsf, SDL_sinf, SDL_memset, etc.), and approved project wrappers

for C99 functions SDL lacks (forge_isfinite, forge_fmaxf, forge_fminf)

Skip SDL_MAIN_USE_CALLBACKS check for: math, engine lessons that use

main() directly.


12. `forge_scene.h` usage (GPU, physics, audio lessons)

All GPU lessons, all physics lessons, and all audio lessons must use

forge_scene.h for the rendering baseline (shadow map, Blinn-Phong, grid,

sky, camera, UI). This eliminates hundreds of lines of boilerplate and ensures

a consistent rendering foundation.

What to check:

#include "scene/forge_scene.h"

pipelines, textures, and samplers for the baseline rendering

/ forge_scene_begin_main_pass / forge_scene_end_frame pattern

(scene, grid, shadow, sky, UI shaders are provided by forge_scene.h)

Skip this check for: math, engine, UI, asset lessons.


13. Markdown linting

Run the linter and resolve all issues.

npx markdownlint-cli2 "lessons/<track>/NN-name/**/*.md" ".claude/skills/<topic>/SKILL.md"

Common issues from PR feedback:


14. Python linting (if scripts were modified)

If any Python scripts in scripts/ were added or modified:

uv run ruff check scripts/
uv run ruff format --check scripts/

15. Pyright type checking (if Python files were modified)

If any Python files in scripts/ or pipeline/ were added or modified:

uv run pyright

16. SDL stdinc compliance

Never use bare C stdlib calls when an SDL_ equivalent exists. This is a

cross-platform portability requirement.

What to check:

etc.) when an SDL equivalent exists. Grep for bare names in .c and .h

files and verify all matches use the SDL_ prefix.


17. Build and shader compilation

Verify the lesson compiles and shaders are up to date.

For GPU, physics, and audio lessons (C with shaders):

python scripts/compile_shaders.py NN -v
cmake --build build --target NN-name

For math/engine lessons (C without shaders):

cmake --build build --target NN-name

For asset lessons (Python):

uv run pytest tests/pipeline/ -v

Skip for: UI lessons (no standalone executable).


18. Diagram correctness (recurring in PRs #152, #167, #168, #179, #185)

If the lesson has diagrams (check for assets/*.png files that are not

screenshots), verify each diagram function against the README:

For a thorough review, invoke /dev-review-diagrams with the lesson key.

If there are no diagrams for the lesson, skip this section.


19. Asset Pipeline Compliance (GPU Lessons 39+)

Skip for: GPU lessons 01–38, math, engine, UI, asset lessons.

Code review (all GPU lessons 39+):

forge_pipeline_load_mesh()

apply to texture atlases, which use BC7 for both albedo and normals)

standard shapes)

Manifest compliance (MANDATORY):

with manual copy commands

runtime asset dependencies (fonts, models, materials)

copying fonts, models, textures, or running pipeline tools. No

file(GLOB) for textures. No direct forge_mesh_tool or

forge_scene_tool invocations.

and diagrams for the README. All runtime assets come from

${FORGE_PROCESSED_DIR} via the manifest.

assets/materials/, or assets/fonts/ — not to lesson-local dirs

Runtime validation (run once per PR):


20. Asset Pipeline Compliance (physics and audio lessons)

Skip for: GPU, math, engine, UI, asset lessons.

Physics and audio lessons use forge_scene.h for the rendering baseline and

forge_shapes_*() for procedural geometry. They do not load pipeline meshes

directly, but they must follow the shapes, texture, and manifest mandates.

What to check:

forge_shapes_*() from common/shapes/forge_shapes.h

visualization geometry

upload raw ForgeShape position/normal arrays directly via

SDL_CreateGPUBuffer. ForgeShape stores struct-of-arrays (separate

positions[] and normals[]), but forge_scene.h shaders expect

interleaved ForgeSceneVertex (array-of-structs with position + normal

per vertex). Uploading raw SoA data produces broken/spiky geometry.

Manifest compliance (MANDATORY):

copying fonts, no make_directory + copy_if_different patterns

The correct pattern (used by all existing physics lessons):

1. Convert ForgeShape to ForgeSceneVertex[] array

2. Upload via forge_scene_upload_buffer(scene, SDL_GPU_BUFFERUSAGE_VERTEX, ...)

3. Upload indices via forge_scene_upload_buffer(scene, SDL_GPU_BUFFERUSAGE_INDEX, ...)

ForgeUiWindowState field, it must be initialized with

forge_ui_window_state_default(x, y, w, h) before use. Uninitialized

window state has zero dimensions and the panel will not render.


Reporting

After completing all checks, report a summary table:

Final Pass Results — Lesson NN: Name
=====================================

 0. Required files       ✅ PASS  (all files present)
 1. SDL bool returns     ✅ PASS  (N calls checked)
 2. Command buffer life  ✅ PASS  (N paths checked)
 3. Magic numbers        ✅ PASS
 4. Resource leaks       ⚠️  WARN  (1 potential leak in load_scene)
 5. Naming conventions   ✅ PASS
 6. Intent comments      ✅ PASS
 7. Spec accuracy        ✅ PASS
 8. Skill completeness   ✅ PASS
 9. README structure     ✅ PASS
10. Concept introduction ✅ PASS
11. main.c structure     ✅ PASS
12. forge_scene.h usage  ✅ PASS
13. Markdown lint        ✅ PASS
14. Python lint          ⏭️  SKIP  (no scripts modified)
15. Pyright types        ⏭️  SKIP  (no scripts modified)
16. SDL stdinc compliance ✅ PASS
17. Build & shaders      ✅ PASS
18. Diagram correctness  ⏭️  SKIP  (no diagrams)
19. Asset pipeline (39+) ⏭️  SKIP  (lesson < 39)
20. Asset pipeline (phys/audio) ⏭️  SKIP  (not physics/audio)

For each WARN or FAIL, list the specific file, line, and issue with a suggested

fix. Ask the user if they want you to apply the fixes before proceeding to

/dev-create-pr.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.