jdi-cli 0.1.1 → 0.1.2

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 (35) hide show
  1. package/core/agents/jdi-architect.md +19 -0
  2. package/core/agents/jdi-researcher.md +2 -1
  3. package/core/skills/clean-architecture/SKILL.md +134 -0
  4. package/core/skills/ddd/SKILL.md +140 -0
  5. package/core/skills/hexagonal/SKILL.md +127 -0
  6. package/core/skills/onion/SKILL.md +133 -0
  7. package/core/skills/the-method/SKILL.md +139 -0
  8. package/core/skills/vertical-slice/SKILL.md +127 -0
  9. package/package.json +1 -1
  10. package/runtimes/antigravity/skills/clean-architecture/SKILL.md +125 -0
  11. package/runtimes/antigravity/skills/ddd/SKILL.md +131 -0
  12. package/runtimes/antigravity/skills/hexagonal/SKILL.md +118 -0
  13. package/runtimes/antigravity/skills/jdi-architect/SKILL.md +19 -0
  14. package/runtimes/antigravity/skills/jdi-researcher/SKILL.md +2 -1
  15. package/runtimes/antigravity/skills/onion/SKILL.md +124 -0
  16. package/runtimes/antigravity/skills/the-method/SKILL.md +130 -0
  17. package/runtimes/antigravity/skills/vertical-slice/SKILL.md +118 -0
  18. package/runtimes/claude/agents/jdi-architect.md +19 -0
  19. package/runtimes/claude/agents/jdi-researcher.md +2 -1
  20. package/runtimes/claude/skills/clean-architecture/SKILL.md +120 -0
  21. package/runtimes/claude/skills/ddd/SKILL.md +125 -0
  22. package/runtimes/claude/skills/hexagonal/SKILL.md +112 -0
  23. package/runtimes/claude/skills/onion/SKILL.md +119 -0
  24. package/runtimes/claude/skills/the-method/SKILL.md +124 -0
  25. package/runtimes/claude/skills/vertical-slice/SKILL.md +113 -0
  26. package/runtimes/copilot/agents/jdi-architect.agent.md +19 -0
  27. package/runtimes/copilot/agents/jdi-researcher.agent.md +2 -1
  28. package/runtimes/opencode/agents/jdi-architect.md +19 -0
  29. package/runtimes/opencode/agents/jdi-researcher.md +2 -1
  30. package/runtimes/opencode/skills/clean-architecture/SKILL.md +120 -0
  31. package/runtimes/opencode/skills/ddd/SKILL.md +125 -0
  32. package/runtimes/opencode/skills/hexagonal/SKILL.md +112 -0
  33. package/runtimes/opencode/skills/onion/SKILL.md +119 -0
  34. package/runtimes/opencode/skills/the-method/SKILL.md +124 -0
  35. package/runtimes/opencode/skills/vertical-slice/SKILL.md +113 -0
@@ -0,0 +1,113 @@
1
+ ---
2
+ name: vertical-slice
3
+ description: Vertical Slice Architecture (Jimmy Bogard). Organize by feature, not by technical layer. Each feature owns its full request-to-response path with minimal sharing. Language-agnostic rigid rules. Mutually exclusive with The Method, DDD, Clean Architecture, Hexagonal, Onion.
4
+ ---
5
+
6
+ # Skill: Vertical Slice Architecture
7
+
8
+ Rigid, inviolable rules from Jimmy Bogard's Vertical Slice Architecture. The system is organized by **feature**, not by technical layer. Each slice owns the full path from external request to external response.
9
+
10
+ Vertical Slice is the ONLY allowed design when PROJECT.md `Code Design: LOCKED: Vertical Slice`. Do not impose Clean Architecture's 4-layer structure, Onion shells, Hexagonal core/ports/adapters, DDD aggregates as primary structure, or The Method's universal hierarchy on top.
11
+
12
+ ## Mandatory structure
13
+
14
+ 1. **Each feature is one slice.** A feature is a single user-facing capability (e.g., `RegisterCustomer`, `CancelOrder`, `RenewSubscription`).
15
+ 2. **A slice owns its full pipeline:** input contract, validator, handler, business logic, persistence access, output contract, and slice-specific tests.
16
+ 3. **Slices live in feature folders / packages.** The primary code organization is `features/{feature-name}/` (or equivalent in the language). Technical-layer folders (`controllers/`, `services/`, `repositories/`, `models/`) as the primary structure are forbidden.
17
+ 4. **Each feature folder is self-contained.** Inside a folder live only the artifacts that serve that feature.
18
+ 5. **No shared "Service" layer, no shared "Repository" layer, no shared "Manager" layer across slices.** Each slice has its own.
19
+
20
+ ## Slice isolation rules (inviolable)
21
+
22
+ 1. **Slices do not call each other directly.** If slice A needs work done by slice B, slice A either duplicates the minimum needed code OR they both publish/subscribe to a shared event bus. Direct invocation of slice B's handler from slice A is forbidden.
23
+ 2. **No shared mutable state across slices.** A slice never mutates state owned by another slice except through the shared persistence boundary, and never through another slice's handler.
24
+ 3. **DRY applies inside a slice, not across slices.** Two slices that look similar today are still allowed to diverge tomorrow. Forced sharing is the enemy.
25
+ 4. **Cross-slice abstractions are introduced only when 3+ slices need the exact same behavior with the exact same shape, and that behavior is stable.** Premature shared abstractions are violations.
26
+
27
+ ## Slice composition (mandatory contents)
28
+
29
+ Each slice MUST contain:
30
+
31
+ 1. **Request / Command / Query contract** — a structure describing the input.
32
+ 2. **Handler** — receives the request, executes the logic, returns the response.
33
+ 3. **Validator** (if input requires validation) — slice-local validation rules.
34
+ 4. **Response contract** — the output shape returned to the caller.
35
+ 5. **Slice-local types** — any DTOs, view models, or projections the slice needs.
36
+ 6. **Slice-local tests** — integration tests that exercise the slice end-to-end.
37
+
38
+ A slice MAY contain:
39
+
40
+ - A slice-specific persistence access path (raw query, ORM query, projection, command-side persistence).
41
+ - A slice-specific external system call.
42
+ - Slice-local pre/post processing.
43
+
44
+ A slice MUST NOT contain:
45
+
46
+ - References to another slice's handler, request, or response types.
47
+ - References to a shared "Service" abstracting multiple slices.
48
+ - A "Manager" coordinating multiple slices.
49
+
50
+ ## Cross-cutting concerns (inviolable)
51
+
52
+ 1. Cross-cutting concerns (logging, authentication, authorization, transactions, validation pipeline, error handling) are applied as **pipeline behaviors / middleware** that wrap the handler, never as shared services injected into the handler.
53
+ 2. Authentication and authorization decisions may use shared types (claims, principals) but are enforced at the pipeline level, not inside the handler.
54
+ 3. Validation runs as a pipeline step before the handler executes. The handler assumes valid input.
55
+ 4. Logging, tracing, metrics: pipeline behaviors. The handler does not invoke logging libraries for cross-cutting purposes.
56
+
57
+ ## Persistence rules
58
+
59
+ 1. **No generic repository spanning slices.** A slice that needs persistence either uses the ORM/database client directly within the slice OR has its own slice-local repository.
60
+ 2. **Reads and writes may diverge structurally.** A slice that reads may use a different model than a slice that writes; this is encouraged.
61
+ 3. **No "Domain Model" required to be shared across slices.** Each slice models the data it needs in the shape it needs.
62
+ 4. **A shared schema (database) is acceptable; a shared in-code model abstraction is not.**
63
+
64
+ ## Forbidden patterns (inviolable)
65
+
66
+ - **Technical-layer primary folders** (`controllers/`, `services/`, `repositories/`, `models/`) used as the system's primary organization.
67
+ - **A handler calling another handler.**
68
+ - **A "Service" class injected into multiple handlers** to provide their business logic.
69
+ - **A "Manager" class coordinating multiple slices.**
70
+ - **A shared "Repository" abstraction** consumed by 5+ slices.
71
+ - **Cross-slice imports of internal slice types.** Slice A importing `B.HandleQuery` or `B.RequestDto` is forbidden.
72
+ - **Slice A invoking slice B via an internal interface** instead of via the public boundary (HTTP, queue, event).
73
+ - **DRY refactoring that merges 2 slices into 1 because they share 80% of the code.** Slices stay separate until 3+ identical use cases exist with stable shape.
74
+ - **Forcing all slices through a shared base handler class** that contains business logic.
75
+ - **A shared "Domain Model" referenced by all slices** as the primary modeling element.
76
+
77
+ ## Naming conventions
78
+
79
+ - Feature folders: feature name in domain language (`RegisterCustomer/`, `CancelOrder/`, `ViewCustomerDashboard/`).
80
+ - Request types: domain operation name (`RegisterCustomerCommand`, `CancelOrderCommand`, `ViewCustomerDashboardQuery`).
81
+ - Handler types: paired with request (`RegisterCustomerHandler`).
82
+ - Validator types: paired with request (`RegisterCustomerValidator`).
83
+ - Response types: domain output name (`RegisterCustomerResponse`).
84
+ - Internal slice types: prefixed by feature name when shared inside the slice (`RegisterCustomerEmailTemplate`).
85
+
86
+ ## Reviewer enforcement (gate 5)
87
+
88
+ Reviewer rejects (BLOCKED) when:
89
+ - The codebase is primarily organized by technical layer instead of by feature.
90
+ - A handler invokes another slice's handler, request, or response type.
91
+ - A new "Service" / "Manager" / "Coordinator" class is introduced that spans multiple slices and carries business logic.
92
+ - A shared generic repository is introduced and consumed by multiple slices.
93
+ - Cross-cutting concerns are injected into handlers as shared services instead of applied as pipeline behaviors.
94
+ - Slice A imports types from slice B's internal folder.
95
+
96
+ Reviewer warns (APPROVED_WITH_WARNINGS) when:
97
+ - Two slices share an identical small helper that has been duplicated 3+ times (candidate for extraction, not required).
98
+ - A slice contains logic that appears to belong to a different slice.
99
+ - A slice handler is long enough to suggest splitting into pipeline behaviors.
100
+ - A slice references a "Domain Service" or "Aggregate" terminology that may indicate a different design creeping in.
101
+
102
+ ## Anti-patterns
103
+
104
+ - "Vertical slices" implemented inside an MVC controllers/services/repositories folder structure (the folders betray the layer-primary structure)
105
+ - A "Domain" project that all slices reference, containing entities + services + repositories — that is layered or Onion in disguise
106
+ - Cross-slice "Coordinator" classes that orchestrate two handlers
107
+ - A shared "BaseHandler" that contains transaction management AND business logic
108
+ - A slice handler that delegates 90% of its work to a shared service (the slice is hollow)
109
+ - Premature "DRY" extraction that merges slices into a generic handler with strategy patterns
110
+
111
+ ## Outputs
112
+
113
+ Does NOT produce own files. Modifies parent agent's structural decisions during code authoring and review.
@@ -381,13 +381,29 @@ Write to `.jdi/agents/jdi-reviewer-{slug}.md`.
381
381
 
382
382
  After writing doer/reviewer, inject `<skills_to_load>` block after `</role>` via Edit.
383
383
 
384
+ **Code-design skill (mandatory) — resolve from `PROJECT.md.Code Design` (LOCKED value) using this mapping:**
385
+
386
+ | Code Design (PROJECT.md) | Skill to load |
387
+ |---|---|
388
+ | The Method | `the-method` |
389
+ | DDD | `ddd` |
390
+ | Clean Architecture | `clean-architecture` |
391
+ | Hexagonal | `hexagonal` |
392
+ | Onion | `onion` |
393
+ | Vertical Slice | `vertical-slice` |
394
+
395
+ The resolved code-design skill is loaded by **both doer and reviewer**. Exactly one code-design skill is loaded. Never load two code-design skills simultaneously — the project uses exactly one design. If the mapping cannot resolve, abort with an error and ask the user to fix `PROJECT.md.Code Design`.
396
+
384
397
  **Doer — always:**
385
398
  ```markdown
386
399
  <skills_to_load>
387
400
  - solid — before creating classes/modules/interfaces. Detects god class, large switches, deep inheritance, dep on concretes.
401
+ - {CODE_DESIGN_SKILL} — INVIOLABLE structural rules for the project's locked code design. Apply on every file created.
388
402
  </skills_to_load>
389
403
  ```
390
404
 
405
+ Replace `{CODE_DESIGN_SKILL}` with the resolved entry from the mapping above (e.g. `the-method`, `ddd`, `clean-architecture`, `hexagonal`, `onion`, `vertical-slice`).
406
+
391
407
  If `has_frontend=true`, append:
392
408
  ```markdown
393
409
  - frontend-rules — when task touches .tsx/.vue/.svelte/.razor/.cshtml/.html/.twig/.erb/.blade.php. WCAG 2.2 AA + UX.
@@ -400,9 +416,12 @@ If `has_frontend=true`, append:
400
416
  - kiss — gate 5: over-engineering — interface with 1 impl, factory for new(), pass-through, deep inheritance.
401
417
  - yagni — gate 5: speculative code — optional params never passed, TODO without ticket, generic with 1 type.
402
418
  - clean-code — bad names, long functions, magic numbers, silent catch, boolean params, redundant comments.
419
+ - {CODE_DESIGN_SKILL} — gate 5: enforce INVIOLABLE structural rules for the project's locked code design. BLOCKED on violations defined by the skill.
403
420
  </skills_to_load>
404
421
  ```
405
422
 
423
+ Replace `{CODE_DESIGN_SKILL}` with the same resolved entry — both doer and reviewer load the SAME code-design skill.
424
+
406
425
  If `has_frontend=true`, append:
407
426
  ```markdown
408
427
  - frontend-rules — gate 5 frontend: <input> without label, button without aria-label, localStorage with token, outline removed.
@@ -56,10 +56,11 @@ Options:
56
56
  - Vertical Slice
57
57
  - Clean Architecture
58
58
  - Hexagonal (Ports & Adapters)
59
+ - Onion Architecture
59
60
  - The Method (Juval Löwy)
60
61
  - "Don't know, suggest" (-> recommend based on type + stack)
61
62
 
62
- Locked for the life of the project (global rule).
63
+ Locked for the life of the project (global rule). Mutually exclusive — the project uses exactly ONE code design. The choice is enforced by a JDI skill loaded into doer + reviewer (one of: `ddd`, `vertical-slice`, `clean-architecture`, `hexagonal`, `onion`, `the-method`).
63
64
 
64
65
  **Q4 — MVP scope**
65
66
  "Which minimum features for the MVP? (comma-separated)"
@@ -378,13 +378,29 @@ Write to `.jdi/agents/jdi-reviewer-{slug}.md`.
378
378
 
379
379
  After writing doer/reviewer, inject `<skills_to_load>` block after `</role>` via Edit.
380
380
 
381
+ **Code-design skill (mandatory) — resolve from `PROJECT.md.Code Design` (LOCKED value) using this mapping:**
382
+
383
+ | Code Design (PROJECT.md) | Skill to load |
384
+ |---|---|
385
+ | The Method | `the-method` |
386
+ | DDD | `ddd` |
387
+ | Clean Architecture | `clean-architecture` |
388
+ | Hexagonal | `hexagonal` |
389
+ | Onion | `onion` |
390
+ | Vertical Slice | `vertical-slice` |
391
+
392
+ The resolved code-design skill is loaded by **both doer and reviewer**. Exactly one code-design skill is loaded. Never load two code-design skills simultaneously — the project uses exactly one design. If the mapping cannot resolve, abort with an error and ask the user to fix `PROJECT.md.Code Design`.
393
+
381
394
  **Doer — always:**
382
395
  ```markdown
383
396
  <skills_to_load>
384
397
  - solid — before creating classes/modules/interfaces. Detects god class, large switches, deep inheritance, dep on concretes.
398
+ - {CODE_DESIGN_SKILL} — INVIOLABLE structural rules for the project's locked code design. Apply on every file created.
385
399
  </skills_to_load>
386
400
  ```
387
401
 
402
+ Replace `{CODE_DESIGN_SKILL}` with the resolved entry from the mapping above (e.g. `the-method`, `ddd`, `clean-architecture`, `hexagonal`, `onion`, `vertical-slice`).
403
+
388
404
  If `has_frontend=true`, append:
389
405
  ```markdown
390
406
  - frontend-rules — when task touches .tsx/.vue/.svelte/.razor/.cshtml/.html/.twig/.erb/.blade.php. WCAG 2.2 AA + UX.
@@ -397,9 +413,12 @@ If `has_frontend=true`, append:
397
413
  - kiss — gate 5: over-engineering — interface with 1 impl, factory for new(), pass-through, deep inheritance.
398
414
  - yagni — gate 5: speculative code — optional params never passed, TODO without ticket, generic with 1 type.
399
415
  - clean-code — bad names, long functions, magic numbers, silent catch, boolean params, redundant comments.
416
+ - {CODE_DESIGN_SKILL} — gate 5: enforce INVIOLABLE structural rules for the project's locked code design. BLOCKED on violations defined by the skill.
400
417
  </skills_to_load>
401
418
  ```
402
419
 
420
+ Replace `{CODE_DESIGN_SKILL}` with the same resolved entry — both doer and reviewer load the SAME code-design skill.
421
+
403
422
  If `has_frontend=true`, append:
404
423
  ```markdown
405
424
  - frontend-rules — gate 5 frontend: <input> without label, button without aria-label, localStorage with token, outline removed.
@@ -60,10 +60,11 @@ Options:
60
60
  - Vertical Slice
61
61
  - Clean Architecture
62
62
  - Hexagonal (Ports & Adapters)
63
+ - Onion Architecture
63
64
  - The Method (Juval Löwy)
64
65
  - "Don't know, suggest" (-> recommend based on type + stack)
65
66
 
66
- Locked for the life of the project (global rule).
67
+ Locked for the life of the project (global rule). Mutually exclusive — the project uses exactly ONE code design. The choice is enforced by a JDI skill loaded into doer + reviewer (one of: `ddd`, `vertical-slice`, `clean-architecture`, `hexagonal`, `onion`, `the-method`).
67
68
 
68
69
  **Q4 — MVP scope**
69
70
  "Which minimum features for the MVP? (comma-separated)"
@@ -0,0 +1,120 @@
1
+ ---
2
+ name: clean-architecture
3
+ description: Clean Architecture (Robert C. Martin). 4 concentric layers - Entities, Use Cases, Interface Adapters, Frameworks & Drivers. The Dependency Rule points strictly inward. Language-agnostic rigid rules. Mutually exclusive with The Method, DDD, Hexagonal, Onion, Vertical Slice.
4
+ ---
5
+
6
+ # Skill: Clean Architecture
7
+
8
+ Rigid, inviolable rules from Robert C. Martin's *Clean Architecture*. The system is organized as **concentric layers**, and source-code dependencies point only **inward**.
9
+
10
+ Clean Architecture is the ONLY allowed design when PROJECT.md `Code Design: LOCKED: Clean Architecture`. Do not mix with The Method, DDD aggregates as a primary structure, Hexagonal terminology as the primary structure, Onion shells, or Vertical Slice feature folders as the primary structure.
11
+
12
+ ## The 4 layers (mandatory)
13
+
14
+ From innermost to outermost:
15
+
16
+ 1. **Entities (Enterprise Business Rules)** — the most general and high-level rules. Reusable across applications in the enterprise. Pure data + behavior. No knowledge of any other layer.
17
+ 2. **Use Cases (Application Business Rules)** — application-specific business rules. Orchestrate the dance of Entities to satisfy a use case. No knowledge of UI, DB, frameworks, devices, or external systems.
18
+ 3. **Interface Adapters** — convert data between the form most convenient for use cases/entities and the form most convenient for external agents. Controllers, Presenters, Gateways, ViewModels live here. No knowledge of frameworks beyond what is necessary to expose adapter contracts.
19
+ 4. **Frameworks & Drivers** — the outermost layer. Web framework, database, UI framework, file system, devices, external APIs. Glue code only — minimal logic.
20
+
21
+ Every code unit belongs to exactly one of these 4 layers. A unit that does not fit must be redesigned.
22
+
23
+ ## The Dependency Rule (inviolable)
24
+
25
+ **Source-code dependencies point only inward. Nothing in an inner circle may know anything at all about something in an outer circle.**
26
+
27
+ 1. Entities depend on nothing outside the Entities layer.
28
+ 2. Use Cases depend on Entities only. Use Cases do not import, reference, or know the names of anything in Interface Adapters or Frameworks & Drivers.
29
+ 3. Interface Adapters depend on Use Cases and Entities only. They do not depend on Frameworks & Drivers code directly — they depend on framework abstractions only where unavoidable, and never let framework types cross into the inner circles.
30
+ 4. Frameworks & Drivers depend on whatever is convenient (Adapters, libraries, vendor SDKs).
31
+ 5. Names defined in outer circles (e.g., entity names from a DB schema, DTOs from a controller, framework annotations) must not appear in inner-circle code.
32
+
33
+ ## Boundary Crossing rules (inviolable)
34
+
35
+ 1. **Cross boundaries via interfaces owned by the inner side.** Inputs into Use Cases are defined by interfaces in the Use Cases layer; implementations live in Interface Adapters.
36
+ 2. **Cross boundaries via Data Transfer Objects (DTOs) that are simple structures.** No framework objects, no ORM entities, no HTTP request objects cross a boundary.
37
+ 3. **Use Cases never receive framework-specific types** (HTTP request, ORM entity, file handle, socket). The Adapter translates these into the Use Case's input DTOs.
38
+ 4. **Use Cases return DTOs / output ports.** They never return entities directly to outer layers.
39
+ 5. **The Use Case interactor invokes an output port (interface) to deliver results.** The Presenter implements the output port. Use Cases never call presenters or controllers directly.
40
+
41
+ ## Layer purity rules (inviolable)
42
+
43
+ ### Entities
44
+
45
+ 1. Entities are pure. No imports from any other layer.
46
+ 2. Entities encapsulate enterprise-wide business rules; if a rule is application-specific, it does not belong here.
47
+ 3. Entities are not Database records, ORM models, JSON shapes, or API DTOs. If a class plays one of those roles, it is not an Entity.
48
+ 4. Entities have no annotations from persistence, serialization, or web frameworks.
49
+ 5. Entities are not anemic. Behavior lives with data.
50
+
51
+ ### Use Cases
52
+
53
+ 6. Each Use Case has a single, application-specific purpose stated by its name (verb-noun: e.g., `RegisterCustomer`, `RenewSubscription`).
54
+ 7. A Use Case owns its input port (input boundary) and output port (output boundary) as interfaces in the Use Cases layer.
55
+ 8. A Use Case does not import any framework, ORM, HTTP, file-system, or external-API type.
56
+ 9. A Use Case is testable without any infrastructure. If it cannot be tested without spinning up DB / HTTP / queue, the design is wrong.
57
+ 10. A Use Case orchestrates Entities. It does not duplicate enterprise rules that already live in Entities.
58
+
59
+ ### Interface Adapters
60
+
61
+ 11. Controllers translate external input (HTTP request, CLI args, message payload) into Use Case input DTOs and invoke the Use Case.
62
+ 12. Presenters convert Use Case output DTOs into a form suitable for delivery (ViewModel, response body).
63
+ 13. Gateways implement the persistence interfaces declared by the Use Cases.
64
+ 14. Adapters never contain business rules.
65
+ 15. Adapters depend inward on Use Cases / Entities, never outward on Frameworks.
66
+
67
+ ### Frameworks & Drivers
68
+
69
+ 16. Framework code is glue only. It wires Adapters to the framework runtime.
70
+ 17. Web framework controllers in the Frameworks layer call Adapters, not Use Cases directly.
71
+ 18. ORM-mapped models, framework annotations, configuration code, dependency injection wiring live here.
72
+
73
+ ## Composition rules
74
+
75
+ 1. **Composition Root is in the outermost layer.** The main / startup / DI container assembles all components.
76
+ 2. **Inner layers never construct outer layer types.** Dependencies are injected through interfaces defined by the inner layer.
77
+ 3. **Plug-in architecture.** A change in framework, DB, or UI must require changes only in the outer layers. Inner layers stay untouched.
78
+
79
+ ## Forbidden patterns (inviolable)
80
+
81
+ - **Use Cases referencing framework types** (HTTP request, ORM entity, file handle, vendor SDK type).
82
+ - **Entities referencing persistence frameworks** (ORM annotations, database column attributes that encode behavior).
83
+ - **Anemic Entities.** Behavior must accompany data.
84
+ - **Skipping a layer for convenience** (Controller calling a repository directly, Presenter calling the database).
85
+ - **Returning framework / ORM types from a Use Case.**
86
+ - **Use Case knowing the concrete Adapter** (e.g., calling a specific HTTP client class). Use Cases declare interfaces; Adapters implement.
87
+ - **Shared "Util" / "Helper" classes spanning layers** with hidden business rules.
88
+ - **Database-driven design** where the schema dictates Entity shape.
89
+ - **Cross-layer reach-around** (Framework code calling Use Cases bypassing Adapters, Adapters calling Frameworks bypassing the Composition Root).
90
+ - **Concentric layers reorganized as feature folders** that hide which layer a unit belongs to.
91
+
92
+ ## Reviewer enforcement (gate 5)
93
+
94
+ Reviewer rejects (BLOCKED) when:
95
+ - An Entity or Use Case imports a framework, ORM, HTTP, or vendor SDK type.
96
+ - A Use Case returns a framework / ORM / DTO defined in an outer layer.
97
+ - A Controller invokes persistence directly instead of going through a Use Case.
98
+ - An Adapter contains a business rule.
99
+ - An inner-layer file imports an outer-layer file (direct dependency violation).
100
+ - Boundary crossings carry framework-specific types instead of plain DTOs.
101
+ - Use Cases or Entities are not testable without infrastructure.
102
+
103
+ Reviewer warns (APPROVED_WITH_WARNINGS) when:
104
+ - A Use Case is named after a CRUD verb without application semantics.
105
+ - An Entity has only getters/setters (anemic).
106
+ - An Adapter file leaks framework annotations into its public interface.
107
+ - The Composition Root is split across layers instead of living in the outermost layer.
108
+
109
+ ## Anti-patterns
110
+
111
+ - "Service" layer mixing Use Cases with Adapter responsibilities
112
+ - DTOs leaking into Entities
113
+ - ORM entities serving as both Entity and persistence model
114
+ - Controller-with-business-logic
115
+ - Use Case classes that depend on framework annotations
116
+ - Hexagonal-style port terminology used to disguise a violation (the rule is the Dependency Rule, not the port naming)
117
+
118
+ ## Outputs
119
+
120
+ Does NOT produce own files. Modifies parent agent's structural decisions during code authoring and review.
@@ -0,0 +1,125 @@
1
+ ---
2
+ name: ddd
3
+ description: Domain-Driven Design (Eric Evans). Strategic patterns (Bounded Context, Ubiquitous Language, Context Map) plus tactical patterns (Aggregates, Entities, Value Objects, Domain Services, Repositories, Domain Events). Language-agnostic rigid rules. Mutually exclusive with The Method, Clean Architecture, Hexagonal, Onion, Vertical Slice.
4
+ ---
5
+
6
+ # Skill: Domain-Driven Design (DDD)
7
+
8
+ Rigid, inviolable rules from Eric Evans's *Domain-Driven Design* and Vaughn Vernon's *Implementing DDD*. The domain is the center of the system. Persistence, UI, frameworks, and external integrations are peripheral details.
9
+
10
+ DDD is the ONLY allowed design when PROJECT.md `Code Design: LOCKED: DDD`. Do not introduce The Method's Managers/Engines/ResourceAccess, Clean Architecture's concentric layers as a structural primary, Hexagonal port terminology as the primary structure, Onion shells, or Vertical Slice handlers as the primary structure.
11
+
12
+ ## Strategic rules (inviolable)
13
+
14
+ 1. **Bounded Context (BC) is the unit of model isolation.** Every BC owns its own model, its own ubiquitous language, its own database schema, and its own deployment unit (where feasible). A model is meaningful only inside its BC.
15
+ 2. **Each BC must be named.** Anonymous BCs do not exist. The name appears in the codebase (folder, namespace, module, package).
16
+ 3. **Ubiquitous Language (UL) is contractual within a BC.** The same word means exactly one thing inside the BC. Synonyms are forbidden. Code, tests, docs, conversations, and database column names share the UL terminology.
17
+ 4. **No shared model across BCs.** When two BCs reference the same real-world concept, each has its own model class for it. Cross-BC reuse of classes is forbidden.
18
+ 5. **Cross-BC interaction follows a Context Map relationship.** Every integration between BCs is explicitly typed as exactly one of: Shared Kernel, Customer/Supplier, Conformist, Anticorruption Layer (ACL), Open Host Service (OHS), Published Language (PL), Partnership, Separate Ways. Undeclared integration is forbidden.
19
+ 6. **Anticorruption Layer (ACL) is required when integrating with a legacy or external model.** Foreign models do not leak into a BC.
20
+ 7. **Core Domain is identified explicitly.** Other BCs are classified as Supporting Subdomain or Generic Subdomain. The Core Domain receives the highest engineering investment and is never outsourced or replaced by a generic library.
21
+ 8. **Domain knowledge does not leak into Generic Subdomains.** Generic Subdomain code (Identity, Logging, Notification) must be reusable across projects without domain assumptions.
22
+
23
+ ## Tactical rules (inviolable)
24
+
25
+ ### Aggregate
26
+
27
+ 1. **An Aggregate has exactly one Root.** All external access goes through the Root. References to inner entities from outside the Aggregate are forbidden.
28
+ 2. **The Aggregate Root enforces all invariants of the Aggregate.** No partial state may be observed by other Aggregates or by Application Services.
29
+ 3. **One transaction modifies at most one Aggregate instance.** Multi-aggregate consistency is achieved by Domain Events, not by enclosing transactions.
30
+ 4. **Aggregates reference other Aggregates only by identifier (ID), never by direct object reference.** Cross-aggregate navigation through references is forbidden.
31
+ 5. **Aggregate boundaries are designed around invariants and transactional consistency, never around UI screens or convenience.**
32
+ 6. **Aggregates must be small.** If an Aggregate contains a collection that grows unbounded, the design is wrong and must be split.
33
+
34
+ ### Entity vs Value Object
35
+
36
+ 7. **An Entity has identity that persists across state changes.** Equality is by identity, never by attributes.
37
+ 8. **A Value Object is immutable and identity-less.** Equality is by attributes. Mutating a Value Object is forbidden — replace, do not modify.
38
+ 9. **Prefer Value Objects.** When a concept has no identity, model it as a Value Object. Default to Value Object; promote to Entity only when identity is required.
39
+ 10. **Value Objects must be self-validating.** Construction of a Value Object with invalid state must fail at construction time.
40
+
41
+ ### Domain Service
42
+
43
+ 11. **A Domain Service exists only when an operation does not belong to any Entity or Value Object.** If the operation can fit on an Entity/VO, it must live there.
44
+ 12. **Domain Services are stateless and named with a Ubiquitous Language verb-noun expressing a domain operation, not a technical action.**
45
+ 13. **Domain Services contain domain logic only.** Persistence, transactions, messaging, and orchestration of use cases live in Application Services.
46
+
47
+ ### Repository
48
+
49
+ 14. **One Repository per Aggregate Root.** No repository per Entity that is not a Root. No "generic" repository shared across Aggregates.
50
+ 15. **Repository interface lives with the domain model, not with persistence.** Persistence implementation lives outside the domain layer.
51
+ 16. **Repositories return whole Aggregates, never partial state.** A method returning a piece of an Aggregate (single inner entity, partial fields) is forbidden.
52
+ 17. **Queries that span multiple Aggregates or return projections do not use Repositories.** Use a dedicated Query/ReadModel pattern (CQRS-style). Reads and writes may diverge structurally.
53
+
54
+ ### Domain Event
55
+
56
+ 18. **Domain Events are immutable, past-tense facts.** Names are past tense (e.g., "OrderPlaced", "PaymentRefused"). Mutating a Domain Event is forbidden.
57
+ 19. **Domain Events are emitted by Aggregates.** Application Services do not invent domain events.
58
+ 20. **Domain Events carry only the data needed to react to the fact.** Do not embed entire Aggregate state.
59
+ 21. **Cross-Aggregate consistency uses Domain Events, not synchronous calls between Aggregates.**
60
+
61
+ ### Application Service
62
+
63
+ 22. **Application Services orchestrate use cases.** They load Aggregates via Repositories, invoke domain methods, persist changes, and emit Domain Events. They contain no business rules.
64
+ 23. **Application Services are thin.** A method longer than orchestration of 5-8 domain calls is a smell; extract domain logic back to the domain.
65
+ 24. **Application Services do not return domain entities directly to UI.** Return DTOs or projections.
66
+
67
+ ### Domain layer purity
68
+
69
+ 25. **The Domain Layer depends on nothing external.** No framework, ORM, HTTP, file system, or messaging library is referenced from domain code.
70
+ 26. **Persistence-ignorant domain.** Entities/Aggregates do not inherit from ORM base classes, do not have persistence annotations leaking semantic meaning, and do not know about transactions.
71
+ 27. **No anemic models.** Entities and Value Objects own their behavior. A class with only getters/setters and no business methods is forbidden in the domain layer.
72
+ 28. **No "Manager", "Helper", "Util", "Processor" classes in the domain layer.** These names betray missing domain concepts.
73
+
74
+ ## Modeling rules (inviolable)
75
+
76
+ 1. The model in code must match the model in conversation with domain experts. If they diverge, the code is wrong.
77
+ 2. Names come from the Ubiquitous Language. Technical names ("Data", "Info", "Object", "Item", "Entry") are forbidden in the domain layer.
78
+ 3. New domain concepts are added to the Ubiquitous Language before they are added to the code.
79
+ 4. Domain experts must recognize the names, intents, and invariants encoded in the domain layer.
80
+
81
+ ## Forbidden patterns (inviolable)
82
+
83
+ - **Generic Repository** spanning multiple Aggregates (`Repository<T>`) is forbidden.
84
+ - **Lazy-loaded navigation across Aggregates** is forbidden.
85
+ - **Transactions spanning multiple Aggregates** are forbidden.
86
+ - **Returning Entities from a query that crosses Aggregates** is forbidden — use a read model.
87
+ - **CRUD-only Application Services** ("CreateUser", "UpdateUser") with no domain semantics are a smell; reframe as domain operations ("RegisterCustomer", "DeactivateAccount") when meaning exists.
88
+ - **Anti-corruption layer absence** when consuming an external/legacy model is a violation.
89
+ - **Sharing entities across Bounded Contexts** is forbidden.
90
+ - **DTO leaking into the domain layer** is forbidden.
91
+
92
+ ## Reviewer enforcement (gate 5)
93
+
94
+ Reviewer rejects (BLOCKED) when:
95
+ - Domain code references a framework / ORM / HTTP / messaging library.
96
+ - An Aggregate is mutated from outside its Root.
97
+ - A single transaction modifies more than one Aggregate instance.
98
+ - A Repository serves multiple Aggregate Roots, or returns partial state.
99
+ - Cross-Aggregate references are by object instead of by ID.
100
+ - A Domain Service performs persistence, transactions, or messaging.
101
+ - An Application Service contains business rules.
102
+ - An Entity / VO has only getters/setters (anemic).
103
+ - Two Bounded Contexts share the same model class.
104
+ - An integration with an external system has no Anticorruption Layer.
105
+
106
+ Reviewer warns (APPROVED_WITH_WARNINGS) when:
107
+ - A class is named "Manager" / "Helper" / "Util" / "Processor" in the domain layer.
108
+ - A Value Object is mutable.
109
+ - An Aggregate exposes its internal collections directly.
110
+ - A Domain Event is named in present/future tense.
111
+ - The Ubiquitous Language used in code disagrees with the language in PROJECT.md or CONTEXT.md.
112
+
113
+ ## Anti-patterns
114
+
115
+ - Anemic Domain Model
116
+ - Generic Repository pattern
117
+ - God Aggregate (entire schema under one Root)
118
+ - Smart UI bypassing domain
119
+ - Domain services that orchestrate use cases (those are Application Services)
120
+ - "Service layer" without distinguishing Domain Service vs Application Service
121
+ - Database-first design driving Aggregate shape
122
+
123
+ ## Outputs
124
+
125
+ Does NOT produce own files. Modifies parent agent's structural decisions during code authoring and review.
@@ -0,0 +1,112 @@
1
+ ---
2
+ name: hexagonal
3
+ description: Hexagonal Architecture / Ports and Adapters (Alistair Cockburn). Application core in the center, surrounded by Ports (interfaces owned by the core) and Adapters (implementations). Driving (primary) vs Driven (secondary) sides. Language-agnostic rigid rules. Mutually exclusive with The Method, DDD, Clean Architecture, Onion, Vertical Slice.
4
+ ---
5
+
6
+ # Skill: Hexagonal Architecture (Ports and Adapters)
7
+
8
+ Rigid, inviolable rules from Alistair Cockburn's Ports and Adapters. The application is a **core** isolated from the outside world by **ports** (interfaces) and **adapters** (implementations).
9
+
10
+ Hexagonal is the ONLY allowed design when PROJECT.md `Code Design: LOCKED: Hexagonal`. Do not use The Method, DDD as primary structure, Clean Architecture's 4-layer terminology as primary structure, Onion shells, or Vertical Slice feature folders as primary structure.
11
+
12
+ ## Mandatory structure
13
+
14
+ The system consists of exactly three structural elements:
15
+
16
+ 1. **Application Core (the hexagon)** — domain model + application logic. Knows nothing about technology, protocols, or external systems. The core is the only place where business rules exist.
17
+ 2. **Ports** — interfaces **owned by the core** that declare what the core needs from the outside (driven ports) or what the outside can ask the core to do (driving ports). A port is an abstract contract; it has no implementation in the core.
18
+ 3. **Adapters** — implementations of ports living outside the core. Adapters translate between the technology-specific outside world (HTTP, DB, queue, file, UI) and the technology-free core.
19
+
20
+ Every code unit belongs to exactly one of: Core, Port (still inside the core's package), or Adapter. A unit that does not fit must be redesigned.
21
+
22
+ ## Driving vs Driven (mandatory)
23
+
24
+ 1. **Driving (primary) side** — the side that initiates interaction with the core. UI, HTTP controllers, CLI handlers, scheduled job triggers, integration tests. Driving adapters invoke driving ports.
25
+ 2. **Driven (secondary) side** — the side the core delegates to. Persistence, message bus, external APIs, file system, email, cache. The core invokes driven ports, which are implemented by driven adapters.
26
+ 3. **Driving port** is an interface that exposes the core's capabilities to the outside. **Driven port** is an interface declared by the core that the outside must satisfy.
27
+ 4. **Direction of dependency: adapters depend on ports; ports live in the core; the core depends on nothing infrastructural.**
28
+
29
+ ## Inviolable rules
30
+
31
+ ### Core purity
32
+
33
+ 1. The core has zero imports from any framework, ORM, HTTP library, vendor SDK, file system API, or transport library.
34
+ 2. The core defines its own types for inputs and outputs to ports. Adapter types (HTTP request, ORM model, queue message) do not appear in core code.
35
+ 3. The core does not know the identity of any adapter. It interacts only with ports.
36
+ 4. The core does not perform I/O. All I/O happens through driven ports.
37
+ 5. The core is fully testable without any adapter. If a unit test of the core requires spinning up DB / HTTP / queue, the design is wrong.
38
+
39
+ ### Ports
40
+
41
+ 6. A port is an interface. It has no logic.
42
+ 7. Ports live in the core's package / module. They are not in an "infrastructure" or "adapters" package.
43
+ 8. The core defines a port; the adapter implements it. A port defined outside the core, or implemented in the core, is forbidden.
44
+ 9. Driving ports name capabilities of the core in domain language (e.g., `PlaceOrder`, `RenewSubscription`). Driven ports name dependencies in domain language (e.g., `OrderRepository`, `NotificationSender`).
45
+ 10. Port methods receive and return only types defined inside the core. They do not receive HTTP requests, ORM entities, or framework-specific types.
46
+
47
+ ### Adapters
48
+
49
+ 11. An adapter implements exactly one port (driving or driven). An adapter that mixes driving and driven roles is forbidden.
50
+ 12. A driving adapter translates an external trigger (HTTP request, CLI command, message, schedule) into a core-defined input and invokes a driving port.
51
+ 13. A driven adapter translates a core-defined call into a technology-specific action (SQL query, HTTP call, file write, queue publish) and translates the result back into core-defined output.
52
+ 14. Adapters contain only translation and I/O. Business rules in an adapter are forbidden — they must move into the core.
53
+ 15. Adapters never call other adapters directly. Coordination between adapters happens through the core via a driving adapter → core → driven adapter sequence.
54
+ 16. Adapters never call the core's internal classes directly. They go through ports.
55
+
56
+ ### Composition
57
+
58
+ 17. The Composition Root assembles adapters and injects them into the core at startup. The core does not construct its own adapters.
59
+ 18. Replacing an adapter (e.g., swapping PostgreSQL for MongoDB, REST for gRPC) must not require changes inside the core. If it does, the port is leaking.
60
+ 19. Multiple adapters may implement the same port. The core does not know how many.
61
+ 20. Test adapters (fakes, in-memory implementations) are first-class adapters and must use the same ports as production adapters. The core cannot have a "test-only" code path.
62
+
63
+ ## Forbidden patterns (inviolable)
64
+
65
+ - **Framework types crossing into the core.** No HTTP request type, no ORM entity, no vendor SDK type referenced in core code.
66
+ - **Business rules in adapters.** A driven adapter computing a price, a driving adapter validating a domain rule — both forbidden.
67
+ - **Adapters calling adapters.** Adapter coordination outside the core is forbidden.
68
+ - **Core code instantiating an adapter.** Construction happens in the Composition Root.
69
+ - **Ports defined outside the core.** A port placed in an "infrastructure" module is a violation.
70
+ - **Anemic core.** A core without behavior is a violation — adapters become a leak path for rules.
71
+ - **A driving port returning a framework-specific type** (a port returning `HttpResponse` is wrong).
72
+ - **Driven ports leaking persistence concepts** (a port named `SqlUserRepository` is wrong; it must be domain-named).
73
+ - **Mixed-role adapter** (one adapter both responding to HTTP and writing to DB).
74
+ - **Bypassing ports** by injecting an adapter directly where a port should appear.
75
+ - **Concentric layer terminology** ("Entities layer", "Use Cases layer", "Application Services layer") imposed as the primary structure — Hexagonal organizes by core/ports/adapters, not by concentric layers.
76
+
77
+ ## Naming conventions
78
+
79
+ - Driving ports: domain capability verbs (`PlaceOrder`, `RegisterCustomer`).
80
+ - Driven ports: dependency names in domain language (`OrderRepository`, `EmailSender`, `PaymentGateway`).
81
+ - Adapters: technology-qualified (`HttpPlaceOrderAdapter`, `PostgresOrderRepositoryAdapter`, `SmtpEmailSenderAdapter`).
82
+ - The core never references a name containing a technology word.
83
+
84
+ ## Reviewer enforcement (gate 5)
85
+
86
+ Reviewer rejects (BLOCKED) when:
87
+ - Core code imports a framework / ORM / HTTP / vendor SDK / file-system type.
88
+ - A port is defined outside the core or implemented inside the core.
89
+ - A port method's signature mentions a framework-specific type.
90
+ - An adapter contains business logic.
91
+ - An adapter calls another adapter directly.
92
+ - The core instantiates an adapter.
93
+ - A driven port name leaks a persistence technology.
94
+ - A driving adapter returns the result of a port call without translating from a core type to an external type.
95
+
96
+ Reviewer warns (APPROVED_WITH_WARNINGS) when:
97
+ - An adapter file is doing more translation than necessary (smell: complex mapping suggesting hidden rules).
98
+ - A port is implemented by a single adapter and is unlikely ever to vary (still allowed — keep the port).
99
+ - A core class has no behavior (anemic).
100
+ - Composition wiring is scattered instead of centralized in a Composition Root.
101
+
102
+ ## Anti-patterns
103
+
104
+ - "Service" layer between core and adapters (no such thing in Hexagonal)
105
+ - Repository implemented inside the core (must be a port)
106
+ - Use Case classes shaped after Clean Architecture's Use Case layer (the structure is core/ports/adapters)
107
+ - Ports tied to a transport (e.g., `RestOrderPort`) — ports are domain-shaped, adapters are transport-shaped
108
+ - "Domain Services" terminology imported wholesale from DDD as the primary structure (acceptable internal to the core when meaningful, but does not replace the hexagonal primary structure)
109
+
110
+ ## Outputs
111
+
112
+ Does NOT produce own files. Modifies parent agent's structural decisions during code authoring and review.