Runnable `npm run gen:value-object` / `gen:form-machine` (plop) that scaffold the two
pure-TS house patterns with a co-located spec: a branded value object + parseX (mirrors
postcode/bsn), and an Elm-style form/wizard machine (Draft/Valid/Errors + Editing/
Submitting/Submitted/Failed union + initial/pure reduce/assertNever). Prompts take
context + PascalCase name (positional-arg bypass); a post-action reminds to add the
English target for the generated $localize id. Templates in plop-templates/ (prettier-
ignored). Skills (value-object, form-machine) point at the generators. ui-component +
bff-endpoint stay skill-driven (Angular {{}} / backend + gen:api).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2.5 KiB
WP-43 — Runnable leaf generators
Status: done (value-object + form-machine; ui-component/bff-endpoint kept as skills) Phase: 8 — platform/DX/showcase Priority: P3
Outcome
Tool = plop. plopfile.mjs + plop-templates/ provide two runnable generators for the pure-TS
patterns: npm run gen:value-object (branded type + parseX + spec, mirrors postcode/bsn) and
npm run gen:form-machine (Draft/Valid/Errors + Editing/Submitting/Submitted/Failed union +
initial/pure reduce/assertNever + spec, mirrors change-request.machine). Prompts take
context + PascalCase name (positional-arg bypass for scripting); each emits a co-located spec so the
"pure logic must have a spec" rule holds by default; a post-action reminds to add the English
<target> for the generated $localize id. Smoke-tested (both generate → lint + dep:check clean),
then the demo output removed. Skills (value-object, form-machine) point at the generator.
plop-templates/ is prettier-ignored (Handlebars, not TS).
Scoped out (kept as skills): gen:ui-component (Angular template {{ }} collides with
Handlebars) and gen:bff-endpoint (spans the C# backend + gen:api regen) — a generator adds
little over the recipe there.
Why
The house patterns (value object, form machine, bff endpoint, ui component) are documented only as
agent-executed prose skills; there's no npm run gen:* a developer runs to emit the boilerplate.
For a template meant to bootstrap real registers, mechanise the highest-churn recipes.
Decisions
- Step 1 — tool fork: plop (recommended: tiny, readable templates,
npm run gen:*) vs Angular schematics (nativeng generate, heavier to author). Decide before building. - Generators emit house-pattern files with co-located spec/story, matching current idioms:
gen:value-object,gen:form-machine(page/wizard),gen:bff-endpoint,gen:ui-component. - Templates become the single source; each matching skill gets a one-line "run
npm run gen:x, then …".
Files
- New
plopfile.mjs(orschematics/) + template files;package.jsongen:*scripts. - Update the corresponding
.claude/skills/*/SKILL.mdto invoke the generator.
Acceptance criteria
gen:value-object+gen:form-machineemit files that passnpm run lint+dep:checkwith no hand-edits beyond the domain specifics (rule/fields) + the en.xlf target.- Generated units include their co-located spec.
- Smoke-tested both;
npm run cigreen.