/bett3r-pv3-ai-skills:create-modulefrom bett3r-pv3-ai-skills
Orchestrate complete DDD module creation including schemas, aggregate, policies, read models, and tests. Use when scaffolding a new bounded context or feature module.
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.
Orchestrate the creation of a complete PV3 DDD module by composing all sub-skills.
Read ddd-patterns → MODULES.md before writing index.ts — the create() composition shape and why a boot hook (onStarted) must be correct under both boot orders. ddd-patterns → SKILL.md carries the cross-cutting rules this skill's checklist assumes (the MDU/lift artifact-factory contract, the composition-root boundary, invariant placement) plus the trigger table naming the per-artifact references the sub-skills use.
Resolve these placeholders from the repo's .blueprint.config.json:
| Placeholder | .blueprint.config.json field | Example value |
|---|---|---|
<domainEventsPath> | domainEventsPath | src/packages/shared/teselly-domain |
<domainEventsPackageName> | domainEventsPackageName | @bett3r-dev/teselly-domain |
<serverPath> | serverPath | src/services/server |
The framework packages @bett3r-dev/pv3-types, @bett3r-dev/jsonschema-definer, and the
ports module are PV3 framework — identical in every PV3 repo — and appear verbatim below.
Apply the patterns from these sibling skills (create-schema, create-aggregate, create-policy, create-readmodel, create-tests) — they are the source of truth for each component:
create-schemacreate-aggregatecreate-policycreate-readmodelcreate-testsStep 0 — if this module's artifacts are in .blueprint/design.json, run
scaffold-from-design first, scoped to the slice's
designs: ids. It collapses steps 3–5 below into filling in generated files, and it is the only
way the module's artifacts converge to satisfied on the board. The steps below then read as
what to fill, in the same order. For a module with no design nodes, start at step 1.
Generate components in this exact order (each step depends on the previous):
Location: <domainEventsPath>/src/<domain>/
Generate:
<domain>.types.ts — Event schemas, value objects<domain>-integration.types.ts — Aggregate state, command, readmodel schemas<entity>.events.ts — Event factory functions with friendlyNameindex.ts — Barrel exports (both .types and -integration.types)Apply the patterns from the create-schema skill.
Location: <serverPath>/src/modules/<module-name>/
Generate:
<module>-module.types.ts — Thin re-export of schemas from <domainEventsPackageName>export {
MyAggregateSchema,
CreateCommandSchema,
EditCommandSchema,
MyReadmodelSchema,
MyReadmodelType
} from '<domainEventsPackageName>';
Location: <serverPath>/src/modules/<module-name>/
Generate:
<entity>.aggregate.ts — AggregateBuilder with event reducers and command handlersApply the patterns from the create-aggregate skill.
Location: <serverPath>/src/modules/<module-name>/
Generate:
<purpose>.policy.ts — One file per policyApply the patterns from the create-policy skill.
Location: <serverPath>/src/modules/<module-name>/
Generate:
<entity>.readmodel.ts — ReadmodelBuilder with projectors and queriesApply the patterns from the create-readmodel skill.
Location: Co-located with source files
Generate:
<entity>.aggregate.test.ts<purpose>.policy.test.ts (for each policy)<entity>.readmodel.test.tsApply the patterns from the create-tests skill.
Location: <serverPath>/src/modules/<module-name>/index.ts
import { Ports } from 'ports';
import { MyAggregate } from './<entity>.aggregate';
import { MyReadmodel } from './<entity>.readmodel';
import { MyPolicy } from './<purpose>.policy';
export const create = async ( ports: Ports ) => {
ports.eventsourcing.routeCommandHandler( MyAggregate( ports ));
ports.eventsourcing.routeEventHandler( MyReadmodel( ports ));
ports.eventsourcing.routeEventHandler( MyPolicy( ports ));
};
After generating all module files:
Ensure the new domain is exported from <domainEventsPath>/src/index.ts (or the appropriate barrel file).
The module's create() function needs to be called from the server's module registration. Check the existing pattern in:
<serverPath>/src/modules/ — see how other modules are imported and their create() is called.npx jest <serverPath>/src/modules/<module-name>/ --verbose
<domainEventsPath>/src/<domain>/
<domain>.types.ts # Event schemas, value objects
<domain>-integration.types.ts # Aggregate, command, readmodel schemas
<entity>.events.ts # Event definitions
index.ts # Barrel exports
<serverPath>/src/modules/<module-name>/
<module>-module.types.ts # Re-exports from <domainEventsPackageName>
<entity>.aggregate.ts # Aggregate
<entity>.readmodel.ts # Read model
<purpose>.policy.ts # Policy (0 or more)
<entity>.aggregate.test.ts # Aggregate tests
<entity>.readmodel.test.ts # Readmodel tests
<purpose>.policy.test.ts # Policy tests
index.ts # Module composition
*.controller.ts — PV3 handles routing internally*.module.ts — Replaced by index.ts create() function*.service.ts for readmodels — PV3 ReadmodelBuilder handles projection inline( ports ) — aggregate, policy, readmodel, recorder. Never a second constructor argument. The MDU/lift loader instantiates artifacts as factory( ports ); an injected dep is undefined in any lifted deployment unit. Single-consumer infra → a lazy library singleton via getX( ports ), never the global Ports type. See the ddd-patterns skill → "Artifact Constructor Signature — the MDU/Lift Contract".*.test.ts next to source, not in separate directoryAfter completion, return:
## Module Created: <ModuleName>
**Domain schemas:** <domainEventsPath>/src/<domain>/
- <domain>.types.ts
- <entity>.events.ts
- index.ts
**Module:** <serverPath>/src/modules/<module-name>/
- <entity>.aggregate.ts
- <entity>.readmodel.ts
- <purpose>.policy.ts (if applicable)
- <entity>.aggregate.test.ts
- <entity>.readmodel.test.ts
- <purpose>.policy.test.ts (if applicable)
- index.ts
**Integration:**
- [ ] domain package barrel exports updated
- [ ] Server module registration updated
- [ ] Tests passing
( ports ) — no second constructor argument (MDU/lift contract)scopeInvariant() via .withCommandTemplate() (unless internal/system)ownerId: metadata?.userIdFilterByAccountIdTransformer() AND FilterByScopeTransformer()ownerId: event.metadata?.userIdWhat SKILL.md sets; muted values are Claude Code's defaults
11 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-Other plugins' skills for the same job
npx claudepluginhub bett3r-dev/bett3r-ai-workflow --plugin bett3r-pv3-ai-skills