/bett3r-pv3-ai-skills:scaffold-from-designfrom bett3r-pv3-ai-skills
Generate the mechanical half of PV3 artifacts from the BLUEPRINT design graph, then hand the rest to the create-* skills. Use when a slice delivers designed artifacts (a policy, read model, command or event that exists in .blueprint/design.json) that no committed scaffold report covers — /design's scaffold commit normally generates them, and /build then runs no scaffolder — before writing any of them by hand.
Ships in bett3r-pv3-ai-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
The mechanical pass. Everything the design graph already determines — file paths, builder
wiring, event names, registration lines, and above all the node ids the extractor will read
back — is generated by a tested program instead of retyped. What is left is what the graph
cannot know, and that is what the create-* skills are for.
Run this before create-policy / create-readmodel / create-schema, not instead of them.
Not to save typing. To make the design converge.
/design proposes sales_pol_buyer-invoice-preference-send-policy. The BLUEPRINT extractor later
re-derives an id from whatever was actually written. Drift by one word in a label or a subdomain
and the proposal never flips to satisfied — the board reports a phantom artifact forever, and
nobody notices, because the code is fine. The scaffolder imports the id function the extractor
uses, so what it emits reads back as exactly what was proposed.
The second reason is placement. A policy in the wrong module compiles, passes its tests, ships, and fails a guard later. The rule is mechanical (below), so it is computed, not remembered.
| Need | Check |
|---|---|
a readable design.json | .blueprint/design.json in a normal checkout; .work/design-snapshot/design.json in a fleet lane |
a graph.json matching this tree | same two locations. In a lane, check manifest.yaml's sourceSha against your base commit first |
| the slice names its design nodes | designs: in .work/slices.yaml — written by /plan |
If the slice has no designs: field, this slice delivers nothing from the design layer, or
the plan predates the field. Do not guess a node set from the slice title: scaffolding the wrong
artifacts is worse than scaffolding none. Say so and write by hand.
The command is whatever the repo declares as designTooling.scaffold in .blueprint.config.json
(yarn blueprint:scaffold in teselly). There is no framework default: with no declaration there
is nothing to run, so say so and write by hand. Run it from the repo root: that is where files are
written and where existence is checked.
Most designed artifacts never reach this skill: /design ends in a scaffold commit
(scaffold-commit, ADR-015) over the whole agreed design, and a slice whose nodes that commit's
scaffold.json report covers runs no scaffolder in /build. This skill is the fallback for a
slice with no report: a repo that declares no designTooling.typecheck, or a design made before
the scaffold commit existed.
# normal checkout — reads this repo's own .blueprint/
<scaffold> --nodes <the slice's designs: ids, comma-separated>
# end of /design — the whole agreed design delta, no --nodes
<scaffold>
# fleet lane — reads the read-only snapshot the provisioner left
<scaffold> \
--design .work/design-snapshot/design.json \
--graph .work/design-snapshot/graph.json \
--nodes <ids>
--nodes also takes an edge key edge:<from>|<to>|<kind>, the one designs: lists for an edge
between two artifacts in code. An edge with a new end rides with that end: its id selects the
edge stub, and its key selects nothing and exits 0 silently, with no unknown-id line. An existing
end's id never selects an edge.
If the command is unknown to the repo's pv3 (error: unknown command 'scaffold'), its
@bett3r-dev/pv3-cli predates the scaffolder. Say so and write by hand; do not reach for the old
blueprint-pv3-scaffold package, which no longer exists.
Writes nothing. Prints what it would create, the fragments it will not write, and anything blocked.
Read the BLOCKED section before anything else. Each entry is a question the graph could not
answer, and each one is a real gap — a new subdomain with no home yet, a policy whose target
handler does not exist, a command with no handled-by edge. Surface these to the user rather
than deciding them yourself: they are design questions wearing a code hat, and the board is
where they get answered. The scaffolder deliberately refuses to guess, and overriding that by
hand-placing the file discards the only signal that a decision is missing.
Exit codes: 0 nothing blocked · 1 the design or graph could not be read, or the slice names
an id the design no longer contains (a stale plan — re-check slices.yaml against the board) ·
3 something was blocked. DEFERRED and ALREADY EXISTS entries are not blocked and leave the
exit code at 0.
A worktree has no .blueprint/ — the design layer belongs to one unit of work while a run spans N, and
a lane must never write it. The provisioner therefore leaves a read-only copy in
.work/design-snapshot/, and reading it is not writing the layer.
Compare manifest.yaml's sourceSha to your base commit before using it. A snapshot cut from
a different tree is wrong about what exists: it will report artifacts as already real that this
tree does not have, and anchor fragments in files that are not here. Neither is visible in the
output. On a mismatch, hand-write the artifacts and say why.
Never create a .blueprint/ in a worktree to make this work. Nothing written in a lane reaches the
board; if the design itself is wrong, escalate to the orchestrator.
Re-run the same command as step 1 with --write added — including
--design / --graph if you needed them there. Dropping them writes nothing in a lane, because
there is no .blueprint/ to fall back to.
<scaffold> [--design … --graph …] --nodes <ids> --write
Only files are written, plus guarded barrel lines. Fragments never are. A file is emitted only
when its host file does not exist, so this cannot overwrite anything — enforced by the wx open
flag, not by a check. The one write to an existing file is a barrel line for a new aggregate: one
export line appended at the end of an existing barrel, only when no line there is exactly that
line (the report lists it under APPENDED).
A fragment is code for a file that already exists: a new command inside an existing
aggregate's .withCommands({…}), a new event beside its siblings, the registration line in the
module index.ts. The tool prints the code, the imports, and a structural anchor; you place it.
This split is deliberate and is not a limitation to route around. The previous generation of this tooling tried to merge generated code into edited files; its merge step degraded to "use the generated one" and silently overwrote hand-written work. Nothing here rewrites a file it did not create: the only write to one is a presence-guarded export line appended at the end of a barrel.
Place the test fragments too. When the repo declares designTooling.tests, the scaffold report
has a TESTS section. A test file it wrote is create-only like any other file; a test for a file
that already exists comes back under FRAGMENTS, it.todo cases behind a TODO(scaffold) marker. Place
each one inside the top-level describe of the file its where: names. If the section reads TESTS - not configured, the repo declares no convention and there is nothing to place.
Place every registration fragment. An artifact nothing registers compiles, typechecks, and is never wired to the event bus — it simply never runs, which looks exactly like a wrong projection. It is the most likely way a scaffolded slice ends up looking finished while doing nothing.
BlueprintNode carries no fields, so none of this is derivable and none of it was guessed. Every
generated file states its own list in a STILL OWED block; the TODO(scaffold) markers are the
line-level version of the same thing.
| Owed | Skill to open |
|---|---|
schemas, event/command payload types, friendlyName | create-schema |
| command handler bodies, invariants, idempotency, stream strategy | create-aggregate + AGGREGATES.md |
| policy handler bodies, fan-out, redelivery, dependency declaration | create-policy + POLICIES.md |
| projection bodies, queries, indexes, scope enforcement | create-readmodel + READMODELS.md |
| the slice's oracle test | create-tests |
Delete the TODO(scaffold) marker when you satisfy it, and delete the STILL OWED block when
the file is complete. A scaffold banner left in finished code trains the next reader to ignore
banners.
Emitting nothing is not the same as having nothing to say — the table is the honest boundary, and the right-hand column is where the work actually is.
A designed dataShape that lists fields is rendered into the schema the table names (the matching rows below), as the real S.shape({…}), so the "placeholder, TODO(scaffold)" in those rows applies only where the scaffold cannot render the shape.
A node with no shape, or a sameAs shape, keeps the placeholder, with one exception: a command's or event's companion schema fragment with a sameAs shape is emitted as an alias of its target (export const X = Y;) only when its target is a proposed command or event whose own companion lands earlier in the same types module (the target's handling aggregate or emitter is extracted, it waits on no unbuilt ref, its events file is this one's, and its id sorts first).
Inside a rendered shape, a field with no type, a ref the scaffold does not resolve, or a schema field renders S.any() under its own TODO(scaffold) marker and is owed: listed in the file's STILL OWED block, or in the fragment's TODO: lines; a ref resolves only to an extracted node whose graph carries a shape that lists fields.
| Design element | Emitted | You still write |
|---|---|---|
policy | whole file + registration | handler bodies, dependency declaration, redelivery safety |
read-model | whole file + registration; schema as a placeholder, TODO(scaffold) | the real schema, projections, queries, indexes, scope |
command on an existing handler | fragment + companion schema fragment (placeholder, TODO(scaffold)) | the real command schema, the handler body, stream/idempotency |
command on a proposed aggregate in the same run | rendered into the aggregate's new file (HOSTED) + its placeholder schema in <stem>-integration.types.ts | the real command schema, the handler body, stream/idempotency |
command on a proposed handler the run does not write (a refused aggregate, or one left out of --nodes) | blocked, naming the handler | unblock the handler, or add its id to --nodes |
event of an existing aggregate | fragment + companion schema fragment (placeholder, TODO(scaffold)) | the real event schema, the namespace registration, translations |
event of a proposed aggregate in the same run | rendered into that aggregate's own new events file, never a sibling's (HOSTED), + placeholder schema + a stub reducer | the real event schema, the reducer, translations |
policy, read-model or view naming a proposed node that is not written this run (an event it reacts to or projects, a command it issues, an aggregate a view reads from) | deferred (not written, exit 0, listed under DEFERRED) | place the fragments, re-extract the graph, re-run the scaffold |
aggregate | its file (AggregateBuilder( <Stem>AggregateSchema, <Stem>Events )) + <stem>.events.ts, <stem>.types.ts, <stem>-integration.types.ts (placeholders, TODO(scaffold)) + guarded barrel lines; a new subdomain also gets its domain barrel and module index.ts; registration into an existing module is a fragment | reducers, handler bodies, invariants, scope (scopeInvariant() only when domainUtilsPackageName is declared) — use create-aggregate |
invariant (a proposed rule, with guarded-by edges from the commands it guards) | a named stub beside the handler of a guarded command (PV3: a named factory; kixie: a check<Name> helper) + one wiring fragment per guarded command (PV3: .withInvariant( <factory>()); kixie: the helper call). A generic invariant (a rule a framework library supplies) gets the wiring only. Deferred (not written, exit 0, listed under DEFERRED) when no command it guards is named, when no guarded command has a handler in code or planned this run, or when the adapter has no invariant template. The wiring for one guarded command is deferred on its own, the stub still placed, when that command has no handler in code or planned this run; a generic invariant's wiring is deferred per command the same way. A stub or wiring hosted in a handler this run plans is blocked when that handler is blocked, as any hosted unit is. An invariant never refuses the design | the rule itself, and the error code the stub rejects with |
a proposed edge onto an artifact in code (an edge stub) of kind projected-to, triggers, produces or emits | a compile-safe no-op fragment in that artifact's file, carrying edge and placed as topology, behind a marker naming its owner: the new end, TODO(scaffold) [<nodeId>], or with both ends in code the edge key, TODO(scaffold) [edge:<from>|<to>|<kind>]. projected-to: events-map entry + projector stub; triggers: builder-argument entry + a handler that issues nothing; produces: the event to append to .produces([...]), owed no-anchor (no anchor kind places it); emits: a ( state ) => state reducer, only when the event is in code and the emitter is an aggregate (a produces implies it) | the real projection, reaction or reducer, in the slice that owns the stub: the new end's, or the one listing the key |
| an edge stub whose builder argument is neither an inline literal nor a same-file const only this builder reads (a shared, exported or imported const, a computed value) | the stub, and an argument entry with no anchor, owed with a todo naming the argument and why | add the event to that argument by hand, knowing every builder reading it changes |
| an edge stub whose builder argument is the event's own namespace | the stub, no argument entry (the namespace already holds the event) | the stub's body |
an edge of any other kind onto an artifact in code (handled-by moves, reads-from, writes-to, calls, invokes, subscribes-to, …), a kind with no template, or one whose other end is held or not written this run | deferred (not written, exit 0, listed under DEFERRED, carrying edge), waiting on hand-authoring, a <framework> '<kind>' edge template, or that end | write it by hand, or place the other end and re-run |
aggregate labelled without Aggregate where every aggregate in code carries it | blocked, with the exact rename | rename it on the board |
system | <stem>.recorder.ts, keyed iff tagged keyed, events, types and integration-types files, no state schema, no reducers; blocked when guarded or suffix-less | handler bodies, the real command schema |
| schemas, tests | nothing | create-schema, create-tests |
A policy belongs in the module of the aggregate its
createCommandtargets — not the module that emits its trigger event.
Resolved from the graph as policy --issues--> command --handled-by--> handler. Measured against
98 shipped policies in the reference repo this predicts the correct module for 92; one of the
six misses is grandfathered as a known violation in that repo's own placement guard, so where it
disagrees with the tree it disagrees the way the guard does.
The exact subdirectory is weaker — 70/95 — but always inside the correct module. So a
generated file states its confidence in the banner: guard-enforced means the module is settled
and a move within it is cheap; inferred (read-models, which no guard governs) means check it.
A wrong module is a build failure; a wrong subdirectory is a git mv. Do not treat the two as
the same finding.
The run is a delta: proposed graph minus extracted graph. Anything that already exists in code
is reported as ALREADY REAL and emitted again by nothing. So a mid-slice re-run after
re-extracting the graph is a legitimate way to ask "what is still outstanding?" — there is no
state file to get out of sync, because the two graphs are the state.
--nodes omitted) with --write only at the end of /design, over an agreed
design, with the same safety as a slice run: dry run first, BLOCKED surfaced, every fragment
placed, and the commit made only once the repo typechecks. Units that wait on a fragment are
DEFERRED, not written broken: place the fragments, re-extract the graph and re-run. Inside a
slice, always pass --nodes; an un-scoped write there scaffolds other slices' artifacts..blueprint.config.json for paths and package names, like every skill here.What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub bett3r-dev/bett3r-ai-workflow --plugin bett3r-pv3-ai-skills11 skills in this plugin
/create-aggregateSkill: Create AggregateScaffold a new event-sourced aggregate with PV3 AggregateBuilder pattern. Use when adding a new aggregate to handle commands and emit events./create-integration-testSkill: Create Integration TestScaffold a full-pipeline in-process integration test suite for a server module using createIntegrationHarness. Use when you want to exercise the real command → aggregate → eventstore → outbox → readmodel pipeline for a subdomain (choreography, policies, gateway callbacks), not mocked unit tests./create-moduleSkill: Create ModuleOrchestrate complete DDD module creation including schemas, aggregate, policies, read models, and tests. Use when scaffolding a new bounded context or feature module./create-policySkill: Create PolicyScaffold an event-driven policy that reacts to events and triggers commands. Use when adding event reactions or sagas./create-readmodelSkill: Create ReadmodelScaffold an event-driven read model (projection) for querying. Use when adding query-side projections from events./create-schemaSkill: Create SchemaScaffold schemas, types, and events for a new DDD domain using @bett3r-dev/jsonschema-definer. Use when defining the schema layer for a new module.