npm run gen:context scaffolds a bounded context: folders + starter page, the @<ctx>/* tsconfig alias, a dependency-cruiser boundary entry, and a lazy authGuard route. Refactors .dependency-cruiser.js's per-context contextRule calls into a single CONTEXT_ALLOWED map that every rule derives from, so adding a context is really one config entry (verified behavior-preserving: same dep:check counts, same graph output). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2.1 KiB
2.1 KiB
name, description
| name | description |
|---|---|
| new-context | Scaffold a new DDD bounded context (folders, path alias, boundary rules, lazy route). Use when adding a new business capability that doesn't belong in an existing context. |
New bounded context
A context is a business capability, not a user group — a user group is an actor that may span contexts (ADR-0002). Check first whether the capability belongs in an existing context; new contexts are rare.
Naming: domain contexts are Dutch (registratie, herregistratie); only
shared/reusable code is English. The context name is the ubiquitous language term.
Steps
- Run
npm run gen:context(WP-44) and give it the lowercase context name. It mechanises the manual edits below in one shot:- Folders —
src/app/<ctx>/{domain,application,infrastructure,contracts}/.gitkeep+ a starterui/<ctx>.page.ts(replace with the real first feature). - Path alias —
"@<ctx>/*": ["src/app/<ctx>/*"]added totsconfig.jsonpaths. - Boundary entry — one new key in
.dependency-cruiser.js'sCONTEXT_ALLOWEDmap (WP-38's single declarative source; every context's forbidden list is derived from that map, so adding one key is enough — nothing else to hand-edit). List the OTHER contexts the new one may import (usually[]— a leaf, likebrief). - Route — a lazy child under the persistent shell in
app.routes.ts, gated byauthGuard.
- Folders —
- Verify:
npm run dep:check && npm run lint && npm run build(regenerate the graph withnpm run dep:graphif you want the committed diagram to reflect it too). - Build the first feature slice with the new-feature skill — replace the generated placeholder page.
Worked example
src/app/brief/ — an independent leaf context (depends only on shared): see its
folder layout and its contextRule entry in .dependency-cruiser.js.
Verify
npm run dep:check && npm run lint && npm run build
# prove the fence works: add a forbidden import (e.g. new ctx → @herregistratie/*),
# confirm `npm run dep:check` fails, remove it.