Solution Generator
Translates a completed architecture document into a .NET solution scaffold — projects, folder structure, domain entities, and CQRS handler stubs — following Clean Architecture and the patterns in this template.
Inputs
| Input | Source | Role |
|-------|--------|------|
| Architecture document | docs/architecture/{SolutionName}-architecture.md | Primary input — all parameters derived from here |
| Ubiquitous Language | UBIQUITOUS_LANGUAGE.md | Domain naming, aggregate identification |
| Use Cases | docs/bounded-contexts/{Domain}/use-cases.md | Each use case → CQRS Command or Query stub |
| User Stories | docs/bounded-contexts/{Domain}/user-stories.md | Acceptance criteria → test stubs |
| Session Decisions | docs/session-decisions.md | Technology and pattern choices |
Generation Steps
- Parse the architecture document for:
- Solution name
- Bounded contexts and their aggregates
- Technology stack choices (ORM, auth, caching, etc.)
- Architectural patterns (event sourcing, CQRS, etc.)
- Integration points and external services
- Map aggregates to entities — one EF Core entity class per aggregate root per bounded context
- Map use cases to CQRS — each use case main flow becomes a Command or Query + Handler stub:
- Create/Update/Delete flows → Commands
- Read flows → Queries
- Generate the solution structure (see below)
- Generate entity configurations —
IEntityTypeConfiguration<T>per entity
- Generate service registration —
Extensions/ServiceCollectionExtensions.csper domain project
- Generate test stubs — one test class per handler, every stub traced to the acceptance
criterion it is evidence for:
- a
// Traces: US-{Domain}-{NNN} / AC-{Domain}-{NNN}.{n}, AC-{Domain}-{NNN}.{m}header line directly
below the // File: line
- exactly one
[TestCategory("AC-{Domain}-{NNN}.{n}")]per test method, with[TestMethod]
written first
- at least one test method per acceptance criterion the slice's
sourcereferences — from
source.acceptance_criteria, or from the criteria of its source.user_stories when that
key is omitted; a criterion may have several methods
- the generated shape follows
.ai/reference/templates/test-class.cs.txt; the identifier rules
are in .ai/reference/traceability.md
- a slice whose
sourceis absent or unlabelled is in legacy mode — generate the stub without
an identifier rather than inventing one
Solution Structure
Generate this layout for each bounded context, following the reference architecture in .ai/project/architecture.md:
src/
├── {Solution}.Contracts.{Domain}/
├── {Solution}.Entities.{Domain}/
├── {Solution}.Models.{Domain}/
├── {Solution}.Domain.{Domain}/
│ ├── Features/
│ │ └── {Entity}/
│ │ ├── Commands/
│ │ │ ├── Create{Entity}/
│ │ │ │ ├── Create{Entity}Command.cs
│ │ │ │ ├── Create{Entity}CommandHandler.cs
│ │ │ │ └── Create{Entity}Response.cs
│ │ │ ├── Update{Entity}/
│ │ │ └── Delete{Entity}/
│ │ ├── Queries/
│ │ │ ├── Get{Entity}ById/
│ │ │ └── Get{Entities}List/
│ │ └── Events/
│ ├── Models/
│ │ └── {Entity}.cs
│ └── Extensions/
│ └── ServiceCollectionExtensions.cs
└── {Solution}.Services.{Domain}/
tests/
└── {Solution}.{Domain}.Tests/
CQRS Stubs
Follow the patterns in:
.ai/reference/templates/command-handler.cs.txt.ai/reference/templates/query-handler.cs.txt
Key rules (from AGENTS.md Critical Coding Rules):
- Commands use individual parameters, not model objects
- Handlers use EF Core primitives only (no repositories, no extension methods)
- All mapping is manual — use
/* map entity to {Entity} model */placeholders - Always include
CancellationTokenon all async methods - Responses wrap model types — never return domain entities directly
- Interfaces live in
Abstractions/folders in the highest shared project — not the implementing project - One type per file — model, response and request types are never merged into one file
- Models are named after the concept — never a
Dtosuffix
Service Registration Stub
// Extensions/ServiceCollectionExtensions.cs
public static IServiceCollection With{Domain}DomainHandlers(
this IServiceCollection services)
{
var assembly = typeof(ServiceCollectionExtensions).Assembly;
services.AddCQRS().AddHandlers(assembly);
return services;
}
After Generation
Run gap-review to validate the generated solution against the original architecture document and session decisions.