Prompt file imported from 7Spade/xuanwu-platform (
.github/prompts/ddd-slice-scaffold.prompt.md). Fill in{{moduleName}},{{aggregate}},{{usecases}}before use. Copyright stays with the author.
DDD Slice Scaffold Workflow
This prompt drives the full DDD cycle for a new bounded context from scratch.
What is scaffolded
src/modules/{module-name}.module/
├── index.ts ← Public API (Presentation exports only)
│
├── domain.{context}/ ← Step 1: Domain Layer
│ ├── _entity.ts ← Aggregate Root + Entities
│ ├── _value-objects.ts ← Value Objects (immutable, self-validating)
│ ├── _service.ts ← Domain Service (if needed)
│ ├── _events.ts ← Domain Event definitions
│ └── _ports.ts ← Outbound Port interfaces (IRepository, IEventBus)
│
├── core/ ← Step 2: Application Layer
│ ├── _use-cases.ts ← Use Case orchestration
│ ├── _actions.ts ← Server Actions (thin adapter → use case)
│ ├── _queries.ts ← Read queries (CQRS read side)
│ └── _dto.ts ← Data Transfer Objects
│
├── infra.{adapter}/ ← Step 3: Infrastructure Layer (one folder per adapter)
│ ├── _repository.ts ← Repository implementation (Firestore, etc.)
│ └── _mapper.ts ← Domain ↔ Persistence mapper
│
└── _components/ ← Step 4: Presentation Layer
├── {SliceName}View.tsx ← Main container component
└── {SubComponent}.tsx
Workflow
- Read domain glossary from
docs/architecture/catalog/business-entities.mdanddocs/architecture/glossary/business-terms.md. - Domain Layer (ddd-domain-modeler): Entity + VOs + Events.
- Application Layer (ddd-application-layer): Use cases + Server Actions + Queries.
- Infrastructure Layer (ddd-infrastructure): Repository adapter + persistence mapper.
- Presentation Layer (xuanwu-ui): Components calling server actions.
- Public API: Wire
index.tsto expose only Presentation exports. - Register: Add slice to
src/modules/README.md.
Guardrails
- Domain objects MUST NOT have framework/SDK imports.
- Application layer MUST call only port interfaces.
- Infrastructure MUST implement port interfaces.
index.tsMUST export only Presentation-safe APIs.- Follow naming from
docs/architecture/README.mdand Serena project memories.
Output Contract
- Complete file tree matching the scaffold above.
- Each file with correct imports and layer boundary enforcement.
- Unit tests for all domain invariants.
- Integration tests for application use cases with mocked ports.
- Updated
src/modules/README.mdslice table.
Module name: {{moduleName}} Main aggregate: {{aggregate}} Primary use cases: {{usecases}}