Dev ui review

From Nebulavenus/forge-gpu · View interactive version

Dev ui review is an AI agent skill from the GitHub repository Nebulavenus/forge-gpu. Code quality, correctness, and documentation review for UI lessons — run before dev-final-pass

How to use this skill

Skill file

Run a UI-specific quality review on a UI lesson before running /dev-final-pass.

This skill catches the recurring code quality, correctness, and documentation

issues specific to the forge_ui / forge_ui_ctx libraries and their callers.

It is not a replacement for /dev-final-pass — it covers the UI-domain concerns

that the general final pass does not.

The user provides:

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

How to run this skill

Work through the three phases below in order. Each phase launches parallel

agents. After each phase, validate findings, apply fixes, then have the agents

revalidate. Repeat until no more issues are found.

Use a Task agent (model: haiku) for builds, test runs, and linting — never run

those directly from the main agent.

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." If the check says every function, check

every function.


Phase 1 — Code correctness sweep

Spawn one agent per concern to review every function added or modified in

common/ui/forge_ui.h, common/ui/forge_ui_ctx.h, the lesson's main.c, and

the relevant test files. Each agent works independently and reports findings.

Agent 1: Memory safety

Agent 2: Parameter validation

Agent 3: Bug detection

Agent 4: Undefined behavior

Agent 5: Resource cleanup

every exit path — bare malloc/free must not be used; the codebase uses

SDL's allocation functions exclusively

when the struct is destroyed

After collecting findings from all five agents:

  1. Validate — review each finding to confirm it is a real issue
  2. Fix — apply corrections to the source files
  3. Revalidate — have the agents re-check the fixed code
  4. Repeat until zero findings remain
  5. Add tests — write tests covering every function reviewed and every issue

found. Ensure callers of these functions check return values.


Phase 2 — Verification checks

Spawn one agent per check to verify the following across all changed files.

The scope for each check is specified in its description.

Check 1: Test return value assertions

Scope: all test files in tests/ui/

For setup and success-path code, wrap forge_ui_* / forge_ui_ctx_* calls that

return false on failure with ASSERT_TRUE(...) so tests fail immediately on

unexpected errors.

For negative-path tests that intentionally trigger failures, assert the expected

failure explicitly with ASSERT_FALSE(...) (or equivalent).

What to look for:

Check 2: Magic numbers in tests

Scope: all test files in tests/ui/

Numeric literals representing reusable or semantically meaningful tuning

parameters (buffer sizes, dimensions, thresholds, domain constants) should be

defined as #define or enum at the top of the relevant test section. Other

test sections in the same file already follow this convention — new code must

match. One-off literals in a single tightly scoped assertion are acceptable

when they remain clear and do not obscure intent.

Acceptable bare numbers:

Unacceptable bare numbers:

Check 3: Inf/NaN handling

Scope: common/ui/forge_ui_ctx.h (all forge_ui_ctx_* functions)

Ensure that any arithmetic that could produce inf or NaN is handled:

values at entry

Check 4: State cleanup on early return

Scope: common/ui/forge_ui.h, common/ui/forge_ui_ctx.h

Ensure that context state is correctly cleared and no stale references persist:

forge_ui_ctx_end_window) must restore the context to a consistent state

position) must restore it on failure paths

Check 5: Unused variables

Scope: common/ui/forge_ui.h, common/ui/forge_ui_ctx.h, the lesson's

main.c, all changed test files

Remove any unused variables. Check for:

Check 6: API comment accuracy

Scope: common/ui/forge_ui.h, common/ui/forge_ui_ctx.h, the lesson's

main.c, the lesson's README.md

Update or remove misleading or incorrect API comments:

Check 7: Shared state isolation

Scope: common/ui/forge_ui_ctx.h

Ensure separate windows, panels, or other UI objects are not sharing state

unexpectedly:

state

Check 8: Test setup return values

Scope: all test files in tests/ui/

Ensure any test setup/helper code that can fail returns a boolean value. If the

helper allocates resources, initializes contexts, or calls forge_ui_*

functions, it should return bool and the caller should ASSERT_TRUE on it.

Writing tests for checks 3, 4, and 7

After completing checks 3, 4, and 7, write dedicated tests for every

finding and for the general cases covered:

to functions and verify they return false or produce clamped/safe output

immediately end it, begin with invalid params) and verify context state is

clean afterward

independently, and verify none affect the others

All new tests must follow the guidelines from checks 1 and 2:

After collecting findings from all eight checks:

  1. Validate — review each finding to confirm it is a real issue
  2. Fix — apply corrections to the source and test files
  3. Revalidate — have the agents re-check the fixed code
  4. Repeat until zero findings remain

Phase 3 — Documentation and content verification

Spawn one agent per check to verify documentation quality.

Doc check 1: Struct property documentation

Scope: common/ui/forge_ui.h, common/ui/forge_ui_ctx.h

Verify that every new or modified struct field has an inline comment

explaining:

Bad: int count; /* count */

Good: int count; /* number of active windows, 0 when no windows are open */

Doc check 2: KaTeX consistency

Scope: the lesson's README.md

Verify that any KaTeX math notation follows the same conventions as previous UI

and GPU lessons:

```text

$$

formula here

$$

```

Doc check 3: Matplotlib diagram compliance

Scope: any diagram scripts modified or added for this lesson

Verify diagrams adhere to the /dev-create-diagram skill guidelines:

Doc check 4: README-to-code accuracy

Scope: the lesson's README.md and main.c

Verify that every code snippet, function signature, struct definition, and API

example shown in the README exactly matches the actual code in main.c and

the library headers. Check for:

Doc check 5: README currency

Scope: README.md (root), lessons/ui/README.md, common/ui/README.md,

CLAUDE.md, previous lesson's README.md

Verify all index files are up to date with the changes from this lesson:

are documented in the API reference; the lesson appears in "Where It's Used"

adds new modules, CLAUDE.md reflects those changes

After collecting findings from all five doc checks:

  1. Validate — review each finding to confirm it is a real issue
  2. Fix — apply corrections to documentation, diagrams, and README files
  3. Revalidate — have the agents re-check the fixed content
  4. Repeat until zero findings remain

Reporting

After completing all phases, report a summary table:

UI Review Results — Lesson NN: Name
=====================================

Phase 1 — Code Correctness
  Memory safety        ✅ PASS  (N functions checked)
  Parameter validation ✅ PASS  (N functions checked)
  Bug detection        ✅ PASS
  Undefined behavior   ✅ PASS
  Resource cleanup     ✅ PASS

Phase 2 — Verification Checks
  1. Test assertions   ✅ PASS  (N calls wrapped)
  2. Magic numbers     ⚠️  FIXED (N constants extracted)
  3. Inf/NaN handling  ✅ PASS  (N guards added, N tests written)
  4. State cleanup     ✅ PASS  (N paths checked, N tests written)
  5. Unused variables  ✅ PASS
  6. Comment accuracy  ✅ PASS
  7. Shared state      ✅ PASS  (N tests written)
  8. Setup returns     ✅ PASS

Phase 3 — Documentation
  1. Struct docs       ✅ PASS  (N fields documented)
  2. KaTeX consistency ✅ PASS
  3. Diagram compliance ⏭️  SKIP (no diagrams modified)
  4. README accuracy   ✅ PASS
  5. README currency   ✅ PASS

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

the fix applied (or suggested if not yet applied). Ask the user if they want

to proceed to /dev-final-pass.

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.