agile-context-engineering 0.1.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/LICENSE +30 -0
  2. package/README.md +272 -78
  3. package/agents/ace-code-discovery-analyst.md +245 -0
  4. package/agents/ace-code-integration-analyst.md +248 -0
  5. package/agents/ace-code-reviewer.md +375 -0
  6. package/agents/ace-product-owner.md +361 -0
  7. package/agents/ace-project-researcher.md +606 -0
  8. package/agents/ace-research-synthesizer.md +228 -0
  9. package/agents/ace-technical-application-architect.md +287 -0
  10. package/agents/ace-wiki-mapper.md +334 -0
  11. package/agile-context-engineering/src/ace-tools.js +2881 -0
  12. package/agile-context-engineering/src/ace-tools.test.js +1089 -0
  13. package/agile-context-engineering/templates/_command.md +54 -0
  14. package/agile-context-engineering/templates/_workflow.xml +17 -0
  15. package/agile-context-engineering/templates/config.json +0 -0
  16. package/agile-context-engineering/templates/product/external-solution.xml +832 -0
  17. package/agile-context-engineering/templates/product/feature.xml +361 -0
  18. package/agile-context-engineering/templates/product/integration-solution.xml +0 -0
  19. package/agile-context-engineering/templates/product/product-backlog.xml +231 -0
  20. package/agile-context-engineering/templates/product/product-vision.xml +227 -0
  21. package/agile-context-engineering/templates/product/story-integration-solution.xml +1014 -0
  22. package/agile-context-engineering/templates/product/story-technical-solution.xml +1025 -0
  23. package/agile-context-engineering/templates/product/story-wiki.xml +190 -0
  24. package/agile-context-engineering/templates/product/story.xml +451 -0
  25. package/agile-context-engineering/templates/wiki/coding-standards.xml +493 -0
  26. package/agile-context-engineering/templates/wiki/decizions.xml +115 -0
  27. package/agile-context-engineering/templates/wiki/guide.xml +137 -0
  28. package/agile-context-engineering/templates/wiki/module-discovery.xml +174 -0
  29. package/agile-context-engineering/templates/wiki/pattern.xml +159 -0
  30. package/agile-context-engineering/templates/wiki/subsystem-architecture.xml +343 -0
  31. package/agile-context-engineering/templates/wiki/subsystem-structure.xml +235 -0
  32. package/agile-context-engineering/templates/wiki/system-architecture.xml +254 -0
  33. package/agile-context-engineering/templates/wiki/system-cross-cutting.xml +197 -0
  34. package/agile-context-engineering/templates/wiki/system-structure.xml +178 -0
  35. package/agile-context-engineering/templates/wiki/system.xml +381 -0
  36. package/agile-context-engineering/templates/wiki/tech-debt-index.xml +125 -0
  37. package/agile-context-engineering/templates/wiki/testing-framework.xml +283 -0
  38. package/agile-context-engineering/templates/wiki/wiki-readme.xml +276 -0
  39. package/agile-context-engineering/utils/questioning.xml +111 -0
  40. package/agile-context-engineering/utils/ui-formatting.md +300 -0
  41. package/agile-context-engineering/workflows/execute-story.xml +1145 -0
  42. package/agile-context-engineering/workflows/help.xml +540 -0
  43. package/agile-context-engineering/workflows/init-coding-standards.xml +386 -0
  44. package/agile-context-engineering/workflows/map-story.xml +797 -0
  45. package/agile-context-engineering/workflows/map-subsystem.xml +1177 -0
  46. package/agile-context-engineering/workflows/map-system.xml +672 -0
  47. package/agile-context-engineering/workflows/plan-backlog.xml +1356 -0
  48. package/agile-context-engineering/workflows/plan-feature.xml +1495 -0
  49. package/agile-context-engineering/workflows/plan-product-vision.xml +342 -0
  50. package/agile-context-engineering/workflows/plan-story.xml +909 -0
  51. package/agile-context-engineering/workflows/research-external-solution.xml +659 -0
  52. package/agile-context-engineering/workflows/research-integration-solution.xml +712 -0
  53. package/agile-context-engineering/workflows/research-story-wiki.xml +474 -0
  54. package/agile-context-engineering/workflows/research-technical-solution.xml +762 -0
  55. package/agile-context-engineering/workflows/review-story.xml +281 -0
  56. package/bin/install.js +102 -166
  57. package/commands/ace/execute-story.md +137 -0
  58. package/commands/ace/help.md +93 -0
  59. package/commands/ace/init-coding-standards.md +83 -0
  60. package/commands/ace/map-story.md +156 -0
  61. package/commands/ace/map-subsystem.md +138 -0
  62. package/commands/ace/map-system.md +92 -0
  63. package/commands/ace/plan-backlog.md +83 -0
  64. package/commands/ace/plan-feature.md +89 -0
  65. package/commands/ace/plan-product-vision.md +81 -0
  66. package/commands/ace/plan-story.md +145 -0
  67. package/commands/ace/research-external-solution.md +138 -0
  68. package/commands/ace/research-integration-solution.md +135 -0
  69. package/commands/ace/research-story-wiki.md +116 -0
  70. package/commands/ace/research-technical-solution.md +147 -0
  71. package/commands/ace/review-story.md +109 -0
  72. package/package.json +5 -8
  73. package/agents/executor.md +0 -88
  74. package/agents/planner.md +0 -78
  75. package/agents/researcher.md +0 -77
  76. package/agents/verifier.md +0 -116
  77. package/commands/ace-execute-story.md +0 -114
  78. package/commands/ace-init.md +0 -254
  79. package/commands/ace-plan-epic.md +0 -79
  80. package/commands/ace-plan-feature.md +0 -78
  81. package/commands/ace-plan-project.md +0 -205
  82. package/commands/ace-plan-story.md +0 -97
  83. package/commands/ace-refine-story.md +0 -90
  84. package/commands/ace-verify-story.md +0 -127
@@ -0,0 +1,343 @@
1
+ <subsystem-architecture>
2
+ <purpose>
3
+ Template for `.docs/wiki/subsystems/[subsystem-name]/architecture.md` — the internal
4
+ architecture view of a single subsystem. Captures component structure (C4 L3), internal
5
+ flows, dependency contracts, data ownership, and subsystem-specific decisions.
6
+
7
+ Complements system-architecture.md (which shows system-wide L1/L2 views).
8
+ Complements subsystem-structure.md (which shows physical file/folder layout).
9
+
10
+ One instance per subsystem — each gets its own architecture doc.
11
+
12
+ A "subsystem" is any cohesive code unit with a clear responsibility boundary —
13
+ whether deployed as a microservice, a monolith module, or a library package.
14
+ </purpose>
15
+
16
+ <template>
17
+ <subsystem-context>
18
+ ## [Subsystem Name]
19
+
20
+ **Responsibility:** [One-line — what this subsystem owns and does]
21
+ **Root:** `[path from project root]`
22
+
23
+ ### System Context
24
+
25
+ How this subsystem connects to the rest of the system:
26
+
27
+ | Relationship | Counterpart | Pattern | What Flows |
28
+ |-------------|-------------|---------|------------|
29
+ | Inbound | [Caller subsystem / external] | [Sync/Async, HTTP/gRPC/event] | [Data/command description] |
30
+ | Outbound | [Callee subsystem / external] | [Sync/Async, HTTP/gRPC/event] | [Data/command description] |
31
+ </subsystem-context>
32
+
33
+ <architectural-pattern>
34
+ ## Architectural Pattern
35
+
36
+ **Pattern:** [N-Tier / Clean Architecture / Onion / Hexagonal / Vertical Slice / CQRS / MVC / Simple Layered / Other]
37
+ **Detected from:** [e.g., "Domain/, Application/, Infrastructure/ folder hierarchy", "IRepository interfaces in core project", "Feature-first directory layout with per-slice handlers"]
38
+
39
+ [1-2 sentences: how the pattern manifests in this subsystem — what the layers are called,
40
+ how dependencies flow, and any notable deviations from the canonical pattern.]
41
+ </architectural-pattern>
42
+
43
+ <c4-l3-component>
44
+ ## L3: Internal Components
45
+
46
+ Shape this diagram to match the detected architectural pattern. Use the reference diagrams
47
+ in the guidelines section. Below is the Clean Architecture default — replace with the
48
+ appropriate structure for the actual pattern.
49
+
50
+ ```mermaid
51
+ flowchart TD
52
+ subgraph Entry["Entry Point(s)"]
53
+ api["[API Layer]<br/><small>[Router/Controller/Handler]</small>"]
54
+ end
55
+
56
+ subgraph App["Application Layer"]
57
+ svc["[Service / Use Case]<br/><small>[Orchestrates domain]</small>"]
58
+ end
59
+
60
+ subgraph Domain["Domain"]
61
+ entity["[Domain Entity / Aggregate]<br/><small>[Core business logic]</small>"]
62
+ end
63
+
64
+ subgraph Infra["Infrastructure"]
65
+ repo["[Repository]<br/><small>[Data access]</small>"]
66
+ client["[External Client]<br/><small>[3rd-party / other subsystem]</small>"]
67
+ end
68
+
69
+ subgraph Data["Data"]
70
+ db[("Data Store")]
71
+ end
72
+
73
+ api --> svc
74
+ svc --> entity
75
+ svc --> repo
76
+ svc --> client
77
+ repo --> db
78
+ ```
79
+
80
+ ### Component Responsibilities
81
+
82
+ | Component | Responsibility | Key Files |
83
+ |-----------|---------------|-----------|
84
+ | [API Layer] | [Receives and validates requests, maps to use cases] | `[path]` |
85
+ | [Service] | [Orchestrates domain logic and infrastructure] | `[path]` |
86
+ | [Domain] | [Business rules, entities, value objects] | `[path]` |
87
+ | [Repository] | [Persists and retrieves domain objects] | `[path]` |
88
+ | [External Client] | [Communicates with external system/subsystem] | `[path]` |
89
+ </c4-l3-component>
90
+
91
+ <internal-flows>
92
+ ## Key Internal Flows
93
+
94
+ The flows that define this subsystem's core operations.
95
+
96
+ ### Flow: [Flow Name]
97
+
98
+ [One sentence: what this achieves and when it triggers.]
99
+
100
+ ```mermaid
101
+ sequenceDiagram
102
+ participant Caller as [Caller / Entry]
103
+ participant Svc as [Service]
104
+ participant Domain as [Domain]
105
+ participant Repo as [Repository]
106
+ participant DB as [Data Store]
107
+
108
+ Caller->>Svc: [Request / command]
109
+ Svc->>Domain: [What is passed]
110
+ Domain-->>Svc: [Result / validated object]
111
+ Svc->>Repo: [Persist / query]
112
+ Repo->>DB: [SQL / query]
113
+ DB-->>Repo: [Result]
114
+ Repo-->>Svc: [Domain object]
115
+ Svc-->>Caller: [Response]
116
+ ```
117
+ </internal-flows>
118
+
119
+ <dependency-inventory>
120
+ ## Dependency Inventory
121
+
122
+ ### Inbound (Who calls this subsystem)
123
+
124
+ | Caller | Call Type | Contract | Notes |
125
+ |--------|-----------|----------|-------|
126
+ | [Subsystem / External] | [HTTP GET /path, Event: topic-name] | [OpenAPI / schema / event type] | [e.g., "authenticated calls only"] |
127
+
128
+ ### Outbound (What this subsystem calls)
129
+
130
+ | Dependency | Call Type | Contract | Failure Handling |
131
+ |------------|-----------|----------|-----------------|
132
+ | [Subsystem / External] | [HTTP / gRPC / SQL / event publish] | [OpenAPI / schema / event type] | [Retry, fallback, fail fast] |
133
+ </dependency-inventory>
134
+
135
+ <data-ownership>
136
+ ## Data Ownership
137
+
138
+ This subsystem owns the following data stores and schemas. Other subsystems MUST NOT
139
+ write directly — they interact through this subsystem's API or events.
140
+
141
+ | Store | Type | Schema / Namespace | Key Entities |
142
+ |-------|------|--------------------|--------------|
143
+ | [Table/collection/topic] | [Postgres/Mongo/Kafka] | [Schema name or prefix] | [Primary entities stored] |
144
+
145
+ **Data NOT owned here:** [Any data this subsystem reads but doesn't own, with note of true owner]
146
+ </data-ownership>
147
+
148
+ <subsystem-architectural-decisions>
149
+ ## Subsystem Architectural Decisions
150
+
151
+ Decisions specific to this subsystem. System-wide decisions live in system-architecture.md.
152
+
153
+ | Decision | Rationale |
154
+ |----------|-----------|
155
+ | [e.g., CQRS for this service] | [High read/write asymmetry — separate models] |
156
+ | [e.g., Repository pattern over direct ORM] | [Testability, ability to swap data store] |
157
+ </subsystem-architectural-decisions>
158
+ </template>
159
+
160
+ <guidelines>
161
+
162
+ **ALL visual representations of architecture, dependencies, flows, or relationships MUST be ```mermaid fenced code blocks. NO ASCII arrows (->), NO dependency trees, NO PlantUML. Only mermaid. The ONLY ASCII exception is file trees.**
163
+
164
+ **Architectural Pattern — How to Detect:**
165
+
166
+ Examine folder structure, namespaces, class names, and dependency directions. Match against
167
+ these signals — the first clear match wins. When signals overlap, note the hybrid.
168
+
169
+ - **N-Tier / Simple Layered** — Folders named `Controllers/`, `Services/` (or `BLL/`),
170
+ `Repositories/` (or `DAL/`). Direct downward dependencies: controller → service → repo.
171
+ No interface inversion — concrete classes reference each other directly.
172
+
173
+ - **MVC** — Framework-scaffolded `Models/`, `Views/`, `Controllers/` (or `Pages/` for
174
+ Razor Pages). Route handlers return views or JSON directly. Thin or no service layer.
175
+
176
+ - **Clean Architecture** — Explicit `Domain/`, `Application/`, `Infrastructure/`,
177
+ `Presentation/` (or `Web/`, `API/`) projects or folders. Domain has zero outgoing
178
+ dependencies. Application references Domain only. Infrastructure implements interfaces
179
+ defined in Application or Domain. Dependency rule strictly inward.
180
+
181
+ - **Onion Architecture** — Similar signals to Clean but layered as concentric rings:
182
+ `Core/` (domain model + domain services + application services), `Infrastructure/`,
183
+ optional `UI/`. Interfaces (ports) defined in Core; implementations in outer rings.
184
+
185
+ - **Hexagonal / Ports & Adapters** — Explicit `ports/` or `interfaces/` alongside
186
+ `adapters/` or `infrastructure/`. Primary adapters (HTTP, CLI) on one side; secondary
187
+ adapters (DB, messaging) on the other. Domain core has no framework imports.
188
+
189
+ - **Vertical Slice / Feature-First** — Feature-named top-level folders:
190
+ `Features/CreateOrder/`, `Features/ListOrders/`. Each slice contains its own handler,
191
+ validator, model, and tests. No shared service layer across features. Often uses a
192
+ mediator (MediatR, similar) — look for `IRequest`/`IRequestHandler` or equivalent.
193
+
194
+ - **CQRS** — Separate `Commands/` and `Queries/` (or `Read/` and `Write/`) directories.
195
+ Distinct models for reads vs. writes. May be combined with Event Sourcing
196
+ (`Events/`, `EventStore`, `Projections/`).
197
+
198
+ **Architectural Pattern — Diagram shapes per pattern:**
199
+
200
+ Use the reference below to choose the right diagram structure. Replace the default
201
+ Clean Architecture diagram in the template with the one matching the detected pattern.
202
+
203
+ *N-Tier:*
204
+ ```
205
+ flowchart TD
206
+ ctrl["Controller / Presenter"] --> svc["Service / Business Logic"]
207
+ svc --> repo["Repository / DAO"]
208
+ repo --> db[("Data Store")]
209
+ ```
210
+
211
+ *Clean Architecture / Onion:*
212
+ ```
213
+ flowchart TD
214
+ subgraph Presentation; api["Controller / Handler"]; end
215
+ subgraph Application; uc["Use Case / App Service"]; end
216
+ subgraph Domain; ent["Entity / Aggregate"]; port["Port Interface"]; end
217
+ subgraph Infrastructure; impl["Repository Impl"]; adapter["External Adapter"]; end
218
+ api --> uc
219
+ uc --> ent
220
+ uc --> port
221
+ impl -.->|implements| port
222
+ adapter -.->|implements| port
223
+ ```
224
+
225
+ *Hexagonal / Ports & Adapters:*
226
+ ```
227
+ flowchart LR
228
+ subgraph Primary["Primary Adapters (Driving)"]
229
+ http["HTTP Controller"]
230
+ cli["CLI Handler"]
231
+ end
232
+ subgraph Core["Domain Core"]
233
+ domain["Domain Logic"]
234
+ inport["Input Port"]
235
+ outport["Output Port"]
236
+ end
237
+ subgraph Secondary["Secondary Adapters (Driven)"]
238
+ dbrepo["DB Repository"]
239
+ msgclient["Messaging Client"]
240
+ end
241
+ http --> inport
242
+ cli --> inport
243
+ inport --> domain
244
+ domain --> outport
245
+ outport -.->|implements| dbrepo
246
+ outport -.->|implements| msgclient
247
+ ```
248
+
249
+ *Vertical Slice / Feature-First:*
250
+ ```
251
+ flowchart LR
252
+ subgraph SliceA["Feature: [Name A]"]
253
+ ha["Handler A"] --> va["Validator A"]
254
+ ha --> dba[("DB")]
255
+ end
256
+ subgraph SliceB["Feature: [Name B]"]
257
+ hb["Handler B"] --> vb["Validator B"]
258
+ hb --> dbb[("DB")]
259
+ end
260
+ entry["Entry / Mediator"] --> ha
261
+ entry --> hb
262
+ ```
263
+
264
+ *CQRS:*
265
+ ```
266
+ flowchart TD
267
+ entry["Entry / Mediator"]
268
+ subgraph Commands
269
+ ch["Command Handler"] --> domain["Domain / Aggregate"]
270
+ domain --> writedb[("Write Store")]
271
+ end
272
+ subgraph Queries
273
+ qh["Query Handler"] --> readdb[("Read Store / Projection")]
274
+ end
275
+ entry --> ch
276
+ entry --> qh
277
+ ```
278
+
279
+ **Subsystem Context:**
280
+ - One-line responsibility — NOT a paragraph. If you need more words, the boundary is wrong
281
+ - System context table: only show DIRECT inbound/outbound. No transitive dependencies
282
+ - Keep it brief — the full system view is in system-architecture.md
283
+
284
+ **L3 Component Diagram:**
285
+ - Layered top-to-bottom (entry → application → domain → infrastructure → data)
286
+ - Each box = a logical component, NOT a file or class
287
+ - Use `flowchart TD` for layered architectures (Clean Architecture, DDD) or `flowchart LR`
288
+ for pipeline/stream-processing subsystems
289
+ - Do NOT show method calls — this is component-level, not code-level
290
+ - Component table: key files must be actual paths within the subsystem
291
+
292
+ **Internal Flows:**
293
+ - 1-3 flows maximum. Choose flows a NEW DEVELOPER must understand to add a feature
294
+ - Component-level only — no method names, no line numbers, no class details
295
+ - Sequence diagram participants = components from the L3 diagram, not files
296
+ - If more than 3 flows are needed, this subsystem likely has multiple bounded operations —
297
+ consider separate docs per operation or split the subsystem
298
+
299
+ **Dependency Inventory:**
300
+ - Inbound: every caller of this subsystem, even if it's just one other subsystem
301
+ - Outbound: every dependency this subsystem calls — including data stores, caches, queues
302
+ - "Failure Handling" for outbound: what happens when that dependency is unavailable?
303
+
304
+ **Data Ownership:**
305
+ - Strict — document who OWNS the data, not just who reads it
306
+ - Include ALL data stores: relational tables, document collections, cache keys, message topics
307
+ - "Data NOT owned here" prevents confusion when a subsystem reads across ownership boundaries
308
+
309
+ **Subsystem Architectural Decisions:**
310
+ - Only decisions that deviate from system-wide defaults or are significant within the subsystem
311
+ - Skip obvious choices (e.g., don't document "we use async/await" in a Node.js service)
312
+ - Decision + Rationale only. No status tracking, no dates
313
+
314
+ **What does NOT belong here:**
315
+ - Physical file layout (that's subsystem-structure.md)
316
+ - System-wide tech stack (that's system-architecture.md)
317
+ - L1/L2 diagrams (that's system-architecture.md)
318
+ - Code-level detail like class signatures, method contracts (L4 — in code comments/docs)
319
+
320
+ </guidelines>
321
+
322
+ <evolution>
323
+
324
+ Update when this subsystem's internal architecture changes.
325
+
326
+ **Update triggers:**
327
+ - Architectural pattern changed (e.g., N-Tier refactored to Clean Architecture)
328
+ - New component layer added (e.g., adding CQRS, adding a cache layer)
329
+ - New inbound integration (new caller, new event type consumed)
330
+ - New outbound dependency (new API called, new data store added)
331
+ - Data ownership changes (new table, new schema, new topic)
332
+ - New subsystem-specific architectural decision made
333
+ - Core internal flow fundamentally changed (not just a new step in an existing flow)
334
+
335
+ **NOT an update trigger:**
336
+ - New feature following existing patterns
337
+ - Bug fixes or refactoring within existing components
338
+ - New API endpoint within existing handler
339
+ - New fields on existing entities
340
+
341
+ </evolution>
342
+
343
+ </subsystem-architecture>
@@ -0,0 +1,235 @@
1
+ <subsystem-structure>
2
+ <purpose>
3
+ Template for `.docs/wiki/subsystems/[subsystem-name]/structure.md` — the physical file
4
+ organization within a single subsystem. Answers "I'm working in this subsystem, where do I put things?"
5
+
6
+ Complements system-structure.md (which shows the system-wide layout and subsystem index).
7
+ One instance per subsystem — each gets its own structure doc.
8
+
9
+ A "subsystem" is any cohesive code unit with a clear responsibility boundary —
10
+ whether deployed as a microservice, a monolith module, or a library package.
11
+
12
+ **Monoliths have subsystems too.** A monolith with bounded contexts, feature modules,
13
+ or domain packages gets one subsystem-structure doc per module — same as microservices.
14
+ The only difference is deployment topology, not documentation structure.
15
+ </purpose>
16
+
17
+ <template>
18
+ <subsystem-overview>
19
+ ## [Subsystem Name]
20
+
21
+ **Root:** `[path from project root]`
22
+ **Responsibility:** [One-line purpose — what this subsystem owns]
23
+ </subsystem-overview>
24
+
25
+ <directory-layout>
26
+ ## Directory Layout
27
+
28
+ [ASCII box-drawing tree of ALL directories and files with purpose - use ├── └── │ characters for tree structure only]
29
+
30
+ Complete file tree of this subsystem. List every file and directory — this is the
31
+ full inventory. An agent reading this should know exactly what exists without running `ls`.
32
+
33
+ ```
34
+ [subsystem-root]/
35
+ ├── [dir]/ # [Purpose]
36
+ │ ├── [subdir]/ # [Purpose]
37
+ │ │ └── [subdir]/ # [Purpose]
38
+ │ └── [subdir]/ # [Purpose]
39
+ ├── [dir]/ # [Purpose]
40
+ │ ├── [subdir]/ # [Purpose]
41
+ │ └── [file] # [Purpose]
42
+ ├── [dir]/ # [Purpose]
43
+ └── [file] # [Purpose]
44
+ ```
45
+ </directory-layout>
46
+
47
+ <directory-purposes>
48
+ ## Directory Purposes
49
+
50
+ **[Directory Name]:**
51
+ - Purpose: [What lives here]
52
+ - Contains: [Types of files: e.g., "*.ts source files", "component directories"]
53
+ - Key files: `[important files in this directory]`
54
+ - Subdirectories: [If nested, describe structure]
55
+
56
+ **[Directory Name]:**
57
+ - Purpose: [What lives here]
58
+ - Contains: [Types of files]
59
+ - Key files: `[important files]`
60
+ - Subdirectories: [Structure]
61
+ </directory-purposes>
62
+
63
+ <key-file-locations>
64
+ ## Key File Locations
65
+
66
+ **Entry Points:**
67
+ - `[path]`: [Purpose — e.g., "HTTP server startup", "CLI entry point"]
68
+
69
+ **Configuration:**
70
+ - `[path]`: [Purpose — e.g., "Module config", "DI container setup"]
71
+
72
+ **Core Logic:**
73
+ - `[path]`: [Purpose — e.g., "Domain services", "Business rules"]
74
+ - `[path]`: [Purpose — e.g., "Data access", "Repository implementations"]
75
+
76
+ **API Surface:**
77
+ - `[path]`: [Purpose — e.g., "Route definitions", "Controller handlers"]
78
+ - `[path]`: [Purpose — e.g., "DTOs / request-response types"]
79
+
80
+ **Testing:**
81
+ - `[path]`: [Purpose — e.g., "Unit tests"]
82
+ - `[path]`: [Purpose — e.g., "Test fixtures / factories"]
83
+ </key-file-locations>
84
+
85
+ <naming-conventions>
86
+ ## Naming Conventions
87
+
88
+ Subsystem-specific patterns. If this subsystem follows system-wide conventions
89
+ without deviation, state: "Follows system-wide conventions — see system-structure.md"
90
+
91
+ **Files:**
92
+ - [Pattern]: [Example — e.g., "kebab-case.ts for modules"]
93
+ - [Pattern]: [Example — e.g., "PascalCase.tsx for React components"]
94
+ - [Pattern]: [Example — e.g., "PascalCase.cs for C# classes"]
95
+ - [Pattern]: [Example — e.g., "*.test.ts co-located with source"]
96
+
97
+ **Directories:**
98
+ - [Pattern]: [Example — e.g., "kebab-case for feature directories"]
99
+ - [Pattern]: [Example — e.g., "plural names for collections"]
100
+
101
+ **Special Patterns:**
102
+ - [Pattern]: [Example — e.g., "index.ts barrel exports per directory"]
103
+ - [Pattern]: [Example — e.g., "__tests__/ for test directories"]
104
+ </naming-conventions>
105
+
106
+ <where-to-add-new-code>
107
+ ## Where to Add New Code
108
+
109
+ **New Feature:**
110
+ - Primary code: `[directory path]`
111
+ - Tests: `[directory path]`
112
+ - Config if needed: `[directory path]`
113
+
114
+ **New Component / Module:**
115
+ - Implementation: `[directory path]`
116
+ - Types: `[directory path]`
117
+ - Tests: `[directory path]`
118
+
119
+ **New Route / Endpoint / Command:**
120
+ - Definition: `[directory path]`
121
+ - Handler: `[directory path]`
122
+ - Tests: `[directory path]`
123
+
124
+ **New Domain Entity / Model:**
125
+ - Entity: `[directory path]`
126
+ - Repository: `[directory path]`
127
+ - Tests: `[directory path]`
128
+
129
+ **New Service / Use Case:**
130
+ - Service: `[directory path]`
131
+ - Use case / application logic: `[directory path]`
132
+ - Interface / contract: `[directory path]`
133
+ - Tests: `[directory path]`
134
+
135
+ **New DTO / Request-Response Object:**
136
+ - DTOs: `[directory path]`
137
+ - Validators: `[directory path]`
138
+
139
+ **New Mapper / Transformer:**
140
+ - Mappers: `[directory path]`
141
+
142
+ **New Constants / Enums:**
143
+ - Constants: `[directory path]`
144
+ - Enums: `[directory path]`
145
+ - Magic values / lookup tables: `[directory path]`
146
+
147
+ **New Database Script / Migration:**
148
+ - Migrations: `[directory path]`
149
+ - Seeds / fixtures: `[directory path]`
150
+ - Stored procedures: `[directory path]`
151
+
152
+ **Shared Kernel / Cross-Cutting:**
153
+ - Shared kernel: `[directory path]`
154
+ - Base classes / interfaces: `[directory path]`
155
+ - Common exceptions: `[directory path]`
156
+ - Extension methods / helpers: `[directory path]`
157
+
158
+ **Utilities:**
159
+ - Shared helpers: `[directory path]`
160
+ - Type definitions: `[directory path]`
161
+ </where-to-add-new-code>
162
+
163
+ <special-directories>
164
+ ## Special Directories
165
+
166
+ Directories with special meaning within this subsystem.
167
+
168
+ **[Directory]:**
169
+ - Purpose: [e.g., "Generated code", "Build output", "Migrations"]
170
+ - Source: [e.g., "Auto-generated by X", "Manually maintained"]
171
+ - Committed: [Yes/No]
172
+ </special-directories>
173
+ </template>
174
+
175
+ <guidelines>
176
+
177
+ **Subsystem Overview:**
178
+ - Root path must be relative to project root — agents use this to navigate
179
+ - Responsibility is one line. If you need more, it goes in the subsystem architecture doc
180
+
181
+ **Directory Layout:**
182
+ - List EVERY file and directory. This is the complete inventory of the subsystem
183
+ - Every directory gets a `# Purpose` comment
184
+ - Every file gets a `# Purpose` comment
185
+ - Use ASCII box-drawing characters: `├── └── │`
186
+ - Skip node_modules, build output, and other generated dirs (mention in Special Directories)
187
+
188
+ **Directory Purposes:**
189
+ - One entry per directory that has meaningful content
190
+ - "Key files" should list the 2-3 most important files a developer would look at first
191
+ - Skip directories that are obvious from the tree (e.g., don't describe `tests/` if it just has tests)
192
+
193
+ **Key File Locations:**
194
+ - Paths must be relative to subsystem root
195
+ - Group by role, not by directory
196
+ - Every entry needs a purpose — `user.service.ts` tells you nothing; "Core user CRUD operations" does
197
+ - Focus on files a developer touches when working on this subsystem
198
+
199
+ **Where to Add New Code:**
200
+ - This is the most actionable section. An agent reads this when creating new files
201
+ - Be specific — `src/features/[feature-name]/` not "the features directory"
202
+ - Cover the common cases for this subsystem's domain
203
+
204
+ **Naming Conventions:**
205
+ - Only document if this subsystem has patterns different from system-wide conventions
206
+ - If it follows system-wide conventions exactly, say so and link to system-structure.md
207
+ - Show actual examples from the codebase, not theoretical patterns
208
+
209
+ **What does NOT belong here:**
210
+ - Conceptual architecture (that's the subsystem architecture doc)
211
+ - Technology stack (that's system-architecture.md)
212
+ - Code conventions like formatting rules (that's a conventions doc)
213
+ - Other subsystems' structure (each has its own doc)
214
+
215
+ </guidelines>
216
+
217
+ <evolution>
218
+
219
+ Update when the physical layout of this subsystem changes.
220
+
221
+ **Update triggers:**
222
+ - New top-level directory added within subsystem
223
+ - Directory renamed, moved, or removed
224
+ - New entry point or configuration file added
225
+ - Naming convention changed
226
+ - "Where to add new code" guidance no longer accurate
227
+
228
+ **NOT an update trigger:**
229
+ - New files added within existing directories
230
+ - New features that follow existing structure
231
+ - Bug fixes or internal refactoring
232
+
233
+ </evolution>
234
+
235
+ </subsystem-structure>