Files
atomic-design-poc/.claude/skills/new-context/SKILL.md
T
ehoandClaude Sonnet 5 7b6cabfc4a feat(dx): gen:context generator (WP-44)
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>
2026-07-27 14:18:43 +02:00

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

  1. 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 starter ui/<ctx>.page.ts (replace with the real first feature).
    • Path alias — "@<ctx>/*": ["src/app/<ctx>/*"] added to tsconfig.json paths.
    • Boundary entry — one new key in .dependency-cruiser.js's CONTEXT_ALLOWED map (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, like brief).
    • Route — a lazy child under the persistent shell in app.routes.ts, gated by authGuard.
  2. Verify: npm run dep:check && npm run lint && npm run build (regenerate the graph with npm run dep:graph if you want the committed diagram to reflect it too).
  3. 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.