# Step 1.5: Module Layout (default mode only) **Role**: Professional software architect **Goal**: Produce `_docs/02_document/module-layout.md` — the authoritative file-ownership map used by the implement skill. Separates **behavioral** task specs (no file paths) from **structural** file mapping (no behavior). **Constraints**: Follow the target language's standard project-layout conventions. Do not invent non-standard directory structures. ## Steps 1. Detect the target language from `DOCUMENT_DIR/architecture.md` and the bootstrap structure plan produced in Step 1. 2. Apply the language's conventional layout (see table in `templates/module-layout.md`): - Python → `src///` - C# → `src//` - Rust → `crates//` - TypeScript / React → `src//` with `index.ts` barrel - Go → `internal//` or `pkg//` 3. Each component owns ONE top-level directory. Shared code goes under `/shared/` (or language equivalent). 4. Public API surface = files in the layout's `public:` list for each component; everything else is internal and MUST NOT be imported from other components. 5. Cross-cutting concerns (logging, error handling, config, telemetry, auth middleware, feature flags, i18n) each get ONE entry under Shared / Cross-Cutting; per-component tasks consume them (see Step 2 cross-cutting rule). 6. **ADR cross-check**: if `_docs/02_document/adr/` exists, read every `Status: Accepted` ADR. For each, confirm the proposed module layout does not contradict the ADR's `Decision` (e.g., an ADR mandating an event-bus boundary between two components must show up as a `Imports from` exclusion in the layout; an ADR locking a layering style must show up in the Layering table). If an ADR conflicts with the language-conventional layout from step 2, the ADR wins — record the conflict in a `## ADR-driven exceptions to the conventional layout` section of `module-layout.md` with `See ADR NNN_` references. If the ADR conflict is irreconcilable (the ADR demands something the language genuinely cannot express), STOP and ask the user A/B/C: (A) update the ADR via plan Step 4.5 supersede flow, (B) accept a layered exception with documented rationale, (C) re-open architecture. 7. Write `_docs/02_document/module-layout.md` using `templates/module-layout.md` format. Each Per-Component Mapping entry that is governed by an ADR includes a trailing `> See ADR NNN_` line. ## Self-verification - [ ] Every component in `DOCUMENT_DIR/components/` has a Per-Component Mapping entry - [ ] Every shared / cross-cutting concern has a Shared section entry - [ ] Layering table covers every component (shared at the bottom) - [ ] No component's `Imports from` list points at a higher layer - [ ] Paths follow the detected language's convention - [ ] No two components own overlapping paths - [ ] If `_docs/02_document/adr/` exists with Accepted ADRs, every layout decision that an ADR governs has a trailing `> See ADR NNN_` reference - [ ] No Accepted ADR is contradicted by the layout without a documented exception ## Save action Write `_docs/02_document/module-layout.md`. ## Blocking **BLOCKING**: Present layout summary to user. Do NOT proceed to Step 2 until user confirms. The implement skill depends on this file; inconsistencies here cause file-ownership conflicts at batch time.