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
@@ -411,13 +411,29 @@ Write to `.jdi/agents/jdi-reviewer-{slug}.md`.
411
411
 
412
412
  After writing doer/reviewer, inject `<skills_to_load>` block after `</role>` via Edit.
413
413
 
414
+ **Code-design skill (mandatory) — resolve from `PROJECT.md.Code Design` (LOCKED value) using this mapping:**
415
+
416
+ | Code Design (PROJECT.md) | Skill to load |
417
+ |---|---|
418
+ | The Method | `the-method` |
419
+ | DDD | `ddd` |
420
+ | Clean Architecture | `clean-architecture` |
421
+ | Hexagonal | `hexagonal` |
422
+ | Onion | `onion` |
423
+ | Vertical Slice | `vertical-slice` |
424
+
425
+ 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`.
426
+
414
427
  **Doer — always:**
415
428
  ```markdown
416
429
  <skills_to_load>
417
430
  - solid — before creating classes/modules/interfaces. Detects god class, large switches, deep inheritance, dep on concretes.
431
+ - {CODE_DESIGN_SKILL} — INVIOLABLE structural rules for the project's locked code design. Apply on every file created.
418
432
  </skills_to_load>
419
433
  ```
420
434
 
435
+ Replace `{CODE_DESIGN_SKILL}` with the resolved entry from the mapping above (e.g. `the-method`, `ddd`, `clean-architecture`, `hexagonal`, `onion`, `vertical-slice`).
436
+
421
437
  If `has_frontend=true`, append:
422
438
  ```markdown
423
439
  - frontend-rules — when task touches .tsx/.vue/.svelte/.razor/.cshtml/.html/.twig/.erb/.blade.php. WCAG 2.2 AA + UX.
@@ -430,9 +446,12 @@ If `has_frontend=true`, append:
430
446
  - kiss — gate 5: over-engineering — interface with 1 impl, factory for new(), pass-through, deep inheritance.
431
447
  - yagni — gate 5: speculative code — optional params never passed, TODO without ticket, generic with 1 type.
432
448
  - clean-code — bad names, long functions, magic numbers, silent catch, boolean params, redundant comments.
449
+ - {CODE_DESIGN_SKILL} — gate 5: enforce INVIOLABLE structural rules for the project's locked code design. BLOCKED on violations defined by the skill.
433
450
  </skills_to_load>
434
451
  ```
435
452
 
453
+ Replace `{CODE_DESIGN_SKILL}` with the same resolved entry — both doer and reviewer load the SAME code-design skill.
454
+
436
455
  If `has_frontend=true`, append:
437
456
  ```markdown
438
457
  - frontend-rules — gate 5 frontend: <input> without label, button without aria-label, localStorage with token, outline removed.
@@ -90,10 +90,11 @@ Options:
90
90
  - Vertical Slice
91
91
  - Clean Architecture
92
92
  - Hexagonal (Ports & Adapters)
93
+ - Onion Architecture
93
94
  - The Method (Juval Löwy)
94
95
  - "Don't know, suggest" (-> recommend based on type + stack)
95
96
 
96
- Locked for the life of the project (global rule).
97
+ 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`).
97
98
 
98
99
  **Q4 — MVP scope**
99
100
  "Which minimum features for the MVP? (comma-separated)"
@@ -0,0 +1,134 @@
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
+ type: skill
5
+ applies_to: |
6
+ Loaded by doer and reviewer when PROJECT.md `Code Design` is `Clean Architecture`.
7
+ Inviolable design rules. Doer applies during creation. Reviewer enforces at gate 5.
8
+ loaded_by:
9
+ - jdi-doer-{slug}
10
+ - jdi-reviewer-{slug}
11
+ runtime_overrides:
12
+ antigravity:
13
+ triggers:
14
+ - "Clean Architecture"
15
+ - "Robert Martin clean"
16
+ - "Dependency Rule"
17
+ - "Use Cases layer"
18
+ ---
19
+
20
+ # Skill: Clean Architecture
21
+
22
+ Rigid, inviolable rules from Robert C. Martin's *Clean Architecture*. The system is organized as **concentric layers**, and source-code dependencies point only **inward**.
23
+
24
+ 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.
25
+
26
+ ## The 4 layers (mandatory)
27
+
28
+ From innermost to outermost:
29
+
30
+ 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.
31
+ 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.
32
+ 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.
33
+ 4. **Frameworks & Drivers** — the outermost layer. Web framework, database, UI framework, file system, devices, external APIs. Glue code only — minimal logic.
34
+
35
+ Every code unit belongs to exactly one of these 4 layers. A unit that does not fit must be redesigned.
36
+
37
+ ## The Dependency Rule (inviolable)
38
+
39
+ **Source-code dependencies point only inward. Nothing in an inner circle may know anything at all about something in an outer circle.**
40
+
41
+ 1. Entities depend on nothing outside the Entities layer.
42
+ 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.
43
+ 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.
44
+ 4. Frameworks & Drivers depend on whatever is convenient (Adapters, libraries, vendor SDKs).
45
+ 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.
46
+
47
+ ## Boundary Crossing rules (inviolable)
48
+
49
+ 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.
50
+ 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.
51
+ 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.
52
+ 4. **Use Cases return DTOs / output ports.** They never return entities directly to outer layers.
53
+ 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.
54
+
55
+ ## Layer purity rules (inviolable)
56
+
57
+ ### Entities
58
+
59
+ 1. Entities are pure. No imports from any other layer.
60
+ 2. Entities encapsulate enterprise-wide business rules; if a rule is application-specific, it does not belong here.
61
+ 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.
62
+ 4. Entities have no annotations from persistence, serialization, or web frameworks.
63
+ 5. Entities are not anemic. Behavior lives with data.
64
+
65
+ ### Use Cases
66
+
67
+ 6. Each Use Case has a single, application-specific purpose stated by its name (verb-noun: e.g., `RegisterCustomer`, `RenewSubscription`).
68
+ 7. A Use Case owns its input port (input boundary) and output port (output boundary) as interfaces in the Use Cases layer.
69
+ 8. A Use Case does not import any framework, ORM, HTTP, file-system, or external-API type.
70
+ 9. A Use Case is testable without any infrastructure. If it cannot be tested without spinning up DB / HTTP / queue, the design is wrong.
71
+ 10. A Use Case orchestrates Entities. It does not duplicate enterprise rules that already live in Entities.
72
+
73
+ ### Interface Adapters
74
+
75
+ 11. Controllers translate external input (HTTP request, CLI args, message payload) into Use Case input DTOs and invoke the Use Case.
76
+ 12. Presenters convert Use Case output DTOs into a form suitable for delivery (ViewModel, response body).
77
+ 13. Gateways implement the persistence interfaces declared by the Use Cases.
78
+ 14. Adapters never contain business rules.
79
+ 15. Adapters depend inward on Use Cases / Entities, never outward on Frameworks.
80
+
81
+ ### Frameworks & Drivers
82
+
83
+ 16. Framework code is glue only. It wires Adapters to the framework runtime.
84
+ 17. Web framework controllers in the Frameworks layer call Adapters, not Use Cases directly.
85
+ 18. ORM-mapped models, framework annotations, configuration code, dependency injection wiring live here.
86
+
87
+ ## Composition rules
88
+
89
+ 1. **Composition Root is in the outermost layer.** The main / startup / DI container assembles all components.
90
+ 2. **Inner layers never construct outer layer types.** Dependencies are injected through interfaces defined by the inner layer.
91
+ 3. **Plug-in architecture.** A change in framework, DB, or UI must require changes only in the outer layers. Inner layers stay untouched.
92
+
93
+ ## Forbidden patterns (inviolable)
94
+
95
+ - **Use Cases referencing framework types** (HTTP request, ORM entity, file handle, vendor SDK type).
96
+ - **Entities referencing persistence frameworks** (ORM annotations, database column attributes that encode behavior).
97
+ - **Anemic Entities.** Behavior must accompany data.
98
+ - **Skipping a layer for convenience** (Controller calling a repository directly, Presenter calling the database).
99
+ - **Returning framework / ORM types from a Use Case.**
100
+ - **Use Case knowing the concrete Adapter** (e.g., calling a specific HTTP client class). Use Cases declare interfaces; Adapters implement.
101
+ - **Shared "Util" / "Helper" classes spanning layers** with hidden business rules.
102
+ - **Database-driven design** where the schema dictates Entity shape.
103
+ - **Cross-layer reach-around** (Framework code calling Use Cases bypassing Adapters, Adapters calling Frameworks bypassing the Composition Root).
104
+ - **Concentric layers reorganized as feature folders** that hide which layer a unit belongs to.
105
+
106
+ ## Reviewer enforcement (gate 5)
107
+
108
+ Reviewer rejects (BLOCKED) when:
109
+ - An Entity or Use Case imports a framework, ORM, HTTP, or vendor SDK type.
110
+ - A Use Case returns a framework / ORM / DTO defined in an outer layer.
111
+ - A Controller invokes persistence directly instead of going through a Use Case.
112
+ - An Adapter contains a business rule.
113
+ - An inner-layer file imports an outer-layer file (direct dependency violation).
114
+ - Boundary crossings carry framework-specific types instead of plain DTOs.
115
+ - Use Cases or Entities are not testable without infrastructure.
116
+
117
+ Reviewer warns (APPROVED_WITH_WARNINGS) when:
118
+ - A Use Case is named after a CRUD verb without application semantics.
119
+ - An Entity has only getters/setters (anemic).
120
+ - An Adapter file leaks framework annotations into its public interface.
121
+ - The Composition Root is split across layers instead of living in the outermost layer.
122
+
123
+ ## Anti-patterns
124
+
125
+ - "Service" layer mixing Use Cases with Adapter responsibilities
126
+ - DTOs leaking into Entities
127
+ - ORM entities serving as both Entity and persistence model
128
+ - Controller-with-business-logic
129
+ - Use Case classes that depend on framework annotations
130
+ - Hexagonal-style port terminology used to disguise a violation (the rule is the Dependency Rule, not the port naming)
131
+
132
+ ## Outputs
133
+
134
+ Does NOT produce own files. Modifies parent agent's structural decisions during code authoring and review.
@@ -0,0 +1,140 @@
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
+ type: skill
5
+ applies_to: |
6
+ Loaded by doer and reviewer when PROJECT.md `Code Design` is `DDD`.
7
+ Inviolable design rules. Doer applies during creation. Reviewer enforces at gate 5.
8
+ loaded_by:
9
+ - jdi-doer-{slug}
10
+ - jdi-reviewer-{slug}
11
+ runtime_overrides:
12
+ antigravity:
13
+ triggers:
14
+ - "DDD"
15
+ - "Domain-Driven Design"
16
+ - "bounded context"
17
+ - "aggregate root"
18
+ - "ubiquitous language"
19
+ ---
20
+
21
+ # Skill: Domain-Driven Design (DDD)
22
+
23
+ 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.
24
+
25
+ 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.
26
+
27
+ ## Strategic rules (inviolable)
28
+
29
+ 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.
30
+ 2. **Each BC must be named.** Anonymous BCs do not exist. The name appears in the codebase (folder, namespace, module, package).
31
+ 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.
32
+ 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.
33
+ 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.
34
+ 6. **Anticorruption Layer (ACL) is required when integrating with a legacy or external model.** Foreign models do not leak into a BC.
35
+ 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.
36
+ 8. **Domain knowledge does not leak into Generic Subdomains.** Generic Subdomain code (Identity, Logging, Notification) must be reusable across projects without domain assumptions.
37
+
38
+ ## Tactical rules (inviolable)
39
+
40
+ ### Aggregate
41
+
42
+ 1. **An Aggregate has exactly one Root.** All external access goes through the Root. References to inner entities from outside the Aggregate are forbidden.
43
+ 2. **The Aggregate Root enforces all invariants of the Aggregate.** No partial state may be observed by other Aggregates or by Application Services.
44
+ 3. **One transaction modifies at most one Aggregate instance.** Multi-aggregate consistency is achieved by Domain Events, not by enclosing transactions.
45
+ 4. **Aggregates reference other Aggregates only by identifier (ID), never by direct object reference.** Cross-aggregate navigation through references is forbidden.
46
+ 5. **Aggregate boundaries are designed around invariants and transactional consistency, never around UI screens or convenience.**
47
+ 6. **Aggregates must be small.** If an Aggregate contains a collection that grows unbounded, the design is wrong and must be split.
48
+
49
+ ### Entity vs Value Object
50
+
51
+ 7. **An Entity has identity that persists across state changes.** Equality is by identity, never by attributes.
52
+ 8. **A Value Object is immutable and identity-less.** Equality is by attributes. Mutating a Value Object is forbidden — replace, do not modify.
53
+ 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.
54
+ 10. **Value Objects must be self-validating.** Construction of a Value Object with invalid state must fail at construction time.
55
+
56
+ ### Domain Service
57
+
58
+ 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.
59
+ 12. **Domain Services are stateless and named with a Ubiquitous Language verb-noun expressing a domain operation, not a technical action.**
60
+ 13. **Domain Services contain domain logic only.** Persistence, transactions, messaging, and orchestration of use cases live in Application Services.
61
+
62
+ ### Repository
63
+
64
+ 14. **One Repository per Aggregate Root.** No repository per Entity that is not a Root. No "generic" repository shared across Aggregates.
65
+ 15. **Repository interface lives with the domain model, not with persistence.** Persistence implementation lives outside the domain layer.
66
+ 16. **Repositories return whole Aggregates, never partial state.** A method returning a piece of an Aggregate (single inner entity, partial fields) is forbidden.
67
+ 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.
68
+
69
+ ### Domain Event
70
+
71
+ 18. **Domain Events are immutable, past-tense facts.** Names are past tense (e.g., "OrderPlaced", "PaymentRefused"). Mutating a Domain Event is forbidden.
72
+ 19. **Domain Events are emitted by Aggregates.** Application Services do not invent domain events.
73
+ 20. **Domain Events carry only the data needed to react to the fact.** Do not embed entire Aggregate state.
74
+ 21. **Cross-Aggregate consistency uses Domain Events, not synchronous calls between Aggregates.**
75
+
76
+ ### Application Service
77
+
78
+ 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.
79
+ 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.
80
+ 24. **Application Services do not return domain entities directly to UI.** Return DTOs or projections.
81
+
82
+ ### Domain layer purity
83
+
84
+ 25. **The Domain Layer depends on nothing external.** No framework, ORM, HTTP, file system, or messaging library is referenced from domain code.
85
+ 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.
86
+ 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.
87
+ 28. **No "Manager", "Helper", "Util", "Processor" classes in the domain layer.** These names betray missing domain concepts.
88
+
89
+ ## Modeling rules (inviolable)
90
+
91
+ 1. The model in code must match the model in conversation with domain experts. If they diverge, the code is wrong.
92
+ 2. Names come from the Ubiquitous Language. Technical names ("Data", "Info", "Object", "Item", "Entry") are forbidden in the domain layer.
93
+ 3. New domain concepts are added to the Ubiquitous Language before they are added to the code.
94
+ 4. Domain experts must recognize the names, intents, and invariants encoded in the domain layer.
95
+
96
+ ## Forbidden patterns (inviolable)
97
+
98
+ - **Generic Repository** spanning multiple Aggregates (`Repository<T>`) is forbidden.
99
+ - **Lazy-loaded navigation across Aggregates** is forbidden.
100
+ - **Transactions spanning multiple Aggregates** are forbidden.
101
+ - **Returning Entities from a query that crosses Aggregates** is forbidden — use a read model.
102
+ - **CRUD-only Application Services** ("CreateUser", "UpdateUser") with no domain semantics are a smell; reframe as domain operations ("RegisterCustomer", "DeactivateAccount") when meaning exists.
103
+ - **Anti-corruption layer absence** when consuming an external/legacy model is a violation.
104
+ - **Sharing entities across Bounded Contexts** is forbidden.
105
+ - **DTO leaking into the domain layer** is forbidden.
106
+
107
+ ## Reviewer enforcement (gate 5)
108
+
109
+ Reviewer rejects (BLOCKED) when:
110
+ - Domain code references a framework / ORM / HTTP / messaging library.
111
+ - An Aggregate is mutated from outside its Root.
112
+ - A single transaction modifies more than one Aggregate instance.
113
+ - A Repository serves multiple Aggregate Roots, or returns partial state.
114
+ - Cross-Aggregate references are by object instead of by ID.
115
+ - A Domain Service performs persistence, transactions, or messaging.
116
+ - An Application Service contains business rules.
117
+ - An Entity / VO has only getters/setters (anemic).
118
+ - Two Bounded Contexts share the same model class.
119
+ - An integration with an external system has no Anticorruption Layer.
120
+
121
+ Reviewer warns (APPROVED_WITH_WARNINGS) when:
122
+ - A class is named "Manager" / "Helper" / "Util" / "Processor" in the domain layer.
123
+ - A Value Object is mutable.
124
+ - An Aggregate exposes its internal collections directly.
125
+ - A Domain Event is named in present/future tense.
126
+ - The Ubiquitous Language used in code disagrees with the language in PROJECT.md or CONTEXT.md.
127
+
128
+ ## Anti-patterns
129
+
130
+ - Anemic Domain Model
131
+ - Generic Repository pattern
132
+ - God Aggregate (entire schema under one Root)
133
+ - Smart UI bypassing domain
134
+ - Domain services that orchestrate use cases (those are Application Services)
135
+ - "Service layer" without distinguishing Domain Service vs Application Service
136
+ - Database-first design driving Aggregate shape
137
+
138
+ ## Outputs
139
+
140
+ Does NOT produce own files. Modifies parent agent's structural decisions during code authoring and review.
@@ -0,0 +1,127 @@
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
+ type: skill
5
+ applies_to: |
6
+ Loaded by doer and reviewer when PROJECT.md `Code Design` is `Hexagonal`.
7
+ Inviolable design rules. Doer applies during creation. Reviewer enforces at gate 5.
8
+ loaded_by:
9
+ - jdi-doer-{slug}
10
+ - jdi-reviewer-{slug}
11
+ runtime_overrides:
12
+ antigravity:
13
+ triggers:
14
+ - "Hexagonal"
15
+ - "Ports and Adapters"
16
+ - "Alistair Cockburn"
17
+ - "driving adapter"
18
+ - "driven adapter"
19
+ ---
20
+
21
+ # Skill: Hexagonal Architecture (Ports and Adapters)
22
+
23
+ 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).
24
+
25
+ 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.
26
+
27
+ ## Mandatory structure
28
+
29
+ The system consists of exactly three structural elements:
30
+
31
+ 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.
32
+ 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.
33
+ 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.
34
+
35
+ 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.
36
+
37
+ ## Driving vs Driven (mandatory)
38
+
39
+ 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.
40
+ 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.
41
+ 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.
42
+ 4. **Direction of dependency: adapters depend on ports; ports live in the core; the core depends on nothing infrastructural.**
43
+
44
+ ## Inviolable rules
45
+
46
+ ### Core purity
47
+
48
+ 1. The core has zero imports from any framework, ORM, HTTP library, vendor SDK, file system API, or transport library.
49
+ 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.
50
+ 3. The core does not know the identity of any adapter. It interacts only with ports.
51
+ 4. The core does not perform I/O. All I/O happens through driven ports.
52
+ 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.
53
+
54
+ ### Ports
55
+
56
+ 6. A port is an interface. It has no logic.
57
+ 7. Ports live in the core's package / module. They are not in an "infrastructure" or "adapters" package.
58
+ 8. The core defines a port; the adapter implements it. A port defined outside the core, or implemented in the core, is forbidden.
59
+ 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`).
60
+ 10. Port methods receive and return only types defined inside the core. They do not receive HTTP requests, ORM entities, or framework-specific types.
61
+
62
+ ### Adapters
63
+
64
+ 11. An adapter implements exactly one port (driving or driven). An adapter that mixes driving and driven roles is forbidden.
65
+ 12. A driving adapter translates an external trigger (HTTP request, CLI command, message, schedule) into a core-defined input and invokes a driving port.
66
+ 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.
67
+ 14. Adapters contain only translation and I/O. Business rules in an adapter are forbidden — they must move into the core.
68
+ 15. Adapters never call other adapters directly. Coordination between adapters happens through the core via a driving adapter → core → driven adapter sequence.
69
+ 16. Adapters never call the core's internal classes directly. They go through ports.
70
+
71
+ ### Composition
72
+
73
+ 17. The Composition Root assembles adapters and injects them into the core at startup. The core does not construct its own adapters.
74
+ 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.
75
+ 19. Multiple adapters may implement the same port. The core does not know how many.
76
+ 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.
77
+
78
+ ## Forbidden patterns (inviolable)
79
+
80
+ - **Framework types crossing into the core.** No HTTP request type, no ORM entity, no vendor SDK type referenced in core code.
81
+ - **Business rules in adapters.** A driven adapter computing a price, a driving adapter validating a domain rule — both forbidden.
82
+ - **Adapters calling adapters.** Adapter coordination outside the core is forbidden.
83
+ - **Core code instantiating an adapter.** Construction happens in the Composition Root.
84
+ - **Ports defined outside the core.** A port placed in an "infrastructure" module is a violation.
85
+ - **Anemic core.** A core without behavior is a violation — adapters become a leak path for rules.
86
+ - **A driving port returning a framework-specific type** (a port returning `HttpResponse` is wrong).
87
+ - **Driven ports leaking persistence concepts** (a port named `SqlUserRepository` is wrong; it must be domain-named).
88
+ - **Mixed-role adapter** (one adapter both responding to HTTP and writing to DB).
89
+ - **Bypassing ports** by injecting an adapter directly where a port should appear.
90
+ - **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.
91
+
92
+ ## Naming conventions
93
+
94
+ - Driving ports: domain capability verbs (`PlaceOrder`, `RegisterCustomer`).
95
+ - Driven ports: dependency names in domain language (`OrderRepository`, `EmailSender`, `PaymentGateway`).
96
+ - Adapters: technology-qualified (`HttpPlaceOrderAdapter`, `PostgresOrderRepositoryAdapter`, `SmtpEmailSenderAdapter`).
97
+ - The core never references a name containing a technology word.
98
+
99
+ ## Reviewer enforcement (gate 5)
100
+
101
+ Reviewer rejects (BLOCKED) when:
102
+ - Core code imports a framework / ORM / HTTP / vendor SDK / file-system type.
103
+ - A port is defined outside the core or implemented inside the core.
104
+ - A port method's signature mentions a framework-specific type.
105
+ - An adapter contains business logic.
106
+ - An adapter calls another adapter directly.
107
+ - The core instantiates an adapter.
108
+ - A driven port name leaks a persistence technology.
109
+ - A driving adapter returns the result of a port call without translating from a core type to an external type.
110
+
111
+ Reviewer warns (APPROVED_WITH_WARNINGS) when:
112
+ - An adapter file is doing more translation than necessary (smell: complex mapping suggesting hidden rules).
113
+ - A port is implemented by a single adapter and is unlikely ever to vary (still allowed — keep the port).
114
+ - A core class has no behavior (anemic).
115
+ - Composition wiring is scattered instead of centralized in a Composition Root.
116
+
117
+ ## Anti-patterns
118
+
119
+ - "Service" layer between core and adapters (no such thing in Hexagonal)
120
+ - Repository implemented inside the core (must be a port)
121
+ - Use Case classes shaped after Clean Architecture's Use Case layer (the structure is core/ports/adapters)
122
+ - Ports tied to a transport (e.g., `RestOrderPort`) — ports are domain-shaped, adapters are transport-shaped
123
+ - "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)
124
+
125
+ ## Outputs
126
+
127
+ Does NOT produce own files. Modifies parent agent's structural decisions during code authoring and review.
@@ -0,0 +1,133 @@
1
+ ---
2
+ name: onion
3
+ description: Onion Architecture (Jeffrey Palermo). Concentric shells with the Domain Model at the absolute center. Dependencies invert across shells - outer depends on inner, inner knows nothing of outer. Language-agnostic rigid rules. Mutually exclusive with The Method, DDD, Clean Architecture, Hexagonal, Vertical Slice.
4
+ type: skill
5
+ applies_to: |
6
+ Loaded by doer and reviewer when PROJECT.md `Code Design` is `Onion`.
7
+ Inviolable design rules. Doer applies during creation. Reviewer enforces at gate 5.
8
+ loaded_by:
9
+ - jdi-doer-{slug}
10
+ - jdi-reviewer-{slug}
11
+ runtime_overrides:
12
+ antigravity:
13
+ triggers:
14
+ - "Onion Architecture"
15
+ - "Jeffrey Palermo"
16
+ - "domain at the center"
17
+ - "concentric shells"
18
+ ---
19
+
20
+ # Skill: Onion Architecture
21
+
22
+ Rigid, inviolable rules from Jeffrey Palermo's Onion Architecture. The system is a series of **concentric shells** with the **Domain Model at the absolute center**. Outer shells depend on inner shells; the inverse is forbidden.
23
+
24
+ Onion is the ONLY allowed design when PROJECT.md `Code Design: LOCKED: Onion`. Do not use The Method, DDD as primary structure, Clean Architecture's 4-named layers, Hexagonal port/adapter terminology as primary structure, or Vertical Slice feature folders as primary structure.
25
+
26
+ ## The shells (mandatory order from center outward)
27
+
28
+ 1. **Domain Model** — entities and value objects expressing the business state. No behavior dependent on infrastructure. The absolute center.
29
+ 2. **Domain Services** — domain operations that do not belong to a single entity/value object. Pure domain logic. Stateless.
30
+ 3. **Application Services** — orchestrate use cases. Coordinate Domain Services and Domain Model. Define interfaces for infrastructure dependencies (repository contracts, external system contracts).
31
+ 4. **Infrastructure** — persistence implementations, external system clients, UI, tests, framework bindings. The outermost shell.
32
+
33
+ Every code unit belongs to exactly one of these 4 shells. A unit that does not fit must be redesigned.
34
+
35
+ ## The Dependency Direction (inviolable)
36
+
37
+ **Dependencies point inward.** Every shell may depend on shells closer to the center; no shell may depend on shells farther from the center.
38
+
39
+ 1. Domain Model depends on nothing else in the system.
40
+ 2. Domain Services depend on Domain Model only.
41
+ 3. Application Services depend on Domain Model and Domain Services.
42
+ 4. Infrastructure depends on Application Services, Domain Services, and Domain Model.
43
+ 5. Names defined in Infrastructure (ORM types, framework types, vendor SDK types) never appear in any inner shell.
44
+
45
+ ## Inversion across infrastructure (inviolable)
46
+
47
+ 1. **Application Services define the interfaces** (repository contracts, external system contracts) they require. These interfaces live in Application Services or Domain Services — never in Infrastructure.
48
+ 2. **Infrastructure implements those interfaces.** The implementation class lives in Infrastructure. The interface lives inward.
49
+ 3. **The Composition Root wires interfaces to implementations.** The Composition Root is part of Infrastructure (or a separate startup module that depends on Infrastructure). Inner shells never construct Infrastructure types.
50
+
51
+ ## Domain Model rules
52
+
53
+ 1. The Domain Model contains only entities and value objects in domain language.
54
+ 2. The Domain Model has no annotations, no inheritance from framework base classes, no persistence concerns, no serialization concerns.
55
+ 3. The Domain Model is not anemic. Behavior that belongs to an entity lives on that entity. Behavior that belongs to no single entity lives in Domain Services.
56
+ 4. Value objects are immutable. Replacing is the only mutation pattern.
57
+ 5. The Domain Model does not know how it is persisted, displayed, or transmitted.
58
+
59
+ ## Domain Services rules
60
+
61
+ 6. Domain Services are stateless. They contain pure domain logic that does not naturally belong to a single Entity or Value Object.
62
+ 7. Domain Services depend on the Domain Model only. They never call repositories, infrastructure, or Application Services.
63
+ 8. Domain Services do not perform I/O.
64
+ 9. Names of Domain Services are domain operations, not technical operations.
65
+
66
+ ## Application Services rules
67
+
68
+ 10. Application Services orchestrate use cases. One Application Service method = one application-level operation.
69
+ 11. Application Services declare the interfaces (repository, gateway, sender, publisher) they require. These interfaces live with Application Services (or in Domain Services when their abstraction is purely domain-driven).
70
+ 12. Application Services do not contain business rules — they coordinate. Business rules live in Domain Model and Domain Services.
71
+ 13. Application Services do not import any Infrastructure class. They depend on the interfaces they themselves declare.
72
+ 14. Application Services receive input DTOs and return output DTOs (or void). They do not return Domain Model entities to outer shells when those would leak persistence concerns.
73
+
74
+ ## Infrastructure rules
75
+
76
+ 15. Infrastructure implements interfaces declared by inner shells. It does not introduce interfaces of its own that inner shells consume.
77
+ 16. Infrastructure contains: persistence (ORM mappings, repositories), HTTP/UI controllers, message bus clients, file system access, vendor SDK calls, scheduled job handlers, and the Composition Root.
78
+ 17. Infrastructure does not contain business rules.
79
+ 18. Infrastructure classes are named with their technology when the technology is the encapsulated concern (e.g., `SqlOrderRepository`, `HttpPaymentGateway`).
80
+ 19. Two infrastructure classes do not call each other to fulfill a use case. Coordination happens via Application Services.
81
+
82
+ ## Forbidden patterns (inviolable)
83
+
84
+ - **Inner shell referencing outer shell.** Domain Model referencing Application Services or Infrastructure is forbidden. Domain Services referencing Application Services or Infrastructure is forbidden. Application Services referencing Infrastructure (concrete classes) is forbidden.
85
+ - **Persistence annotations or framework types in the Domain Model.**
86
+ - **Repository interface placed in Infrastructure.** The interface must live inward (Application Services or Domain Services).
87
+ - **Domain Services performing I/O.**
88
+ - **Application Services containing business rules.**
89
+ - **Infrastructure-defined interfaces consumed by inner shells.**
90
+ - **Skipping a shell** (Infrastructure code calling Domain Model methods directly when an Application Service exists for that use case; or controller calling repository directly bypassing Application Services).
91
+ - **Anemic Domain Model.**
92
+ - **CRUD-only Application Services** with no application semantics.
93
+ - **Cross-shell reach-around** (Infrastructure A calling Infrastructure B to fulfill a use case without going through an Application Service).
94
+
95
+ ## Naming conventions
96
+
97
+ - Domain Model classes: domain nouns (`Customer`, `Order`, `Subscription`).
98
+ - Domain Services: domain verb-noun (`OrderPricingPolicy`, `SubscriptionRenewalRules`).
99
+ - Application Services: application-level operations (`RegisterCustomerService`, `RenewSubscriptionService`).
100
+ - Interfaces consumed by Application Services: domain-meaningful (`IOrderRepository`, `IPaymentGateway`, `INotificationSender`).
101
+ - Infrastructure classes: technology-qualified (`SqlOrderRepository`, `StripePaymentGateway`, `SmtpNotificationSender`).
102
+
103
+ ## Reviewer enforcement (gate 5)
104
+
105
+ Reviewer rejects (BLOCKED) when:
106
+ - Domain Model, Domain Services, or Application Services import a framework / ORM / HTTP / vendor SDK type.
107
+ - A repository or external-system interface is declared in Infrastructure and consumed inward.
108
+ - An inner shell file imports an outer shell file.
109
+ - Application Services contain business rules that belong on Domain Model or Domain Services.
110
+ - Domain Services perform I/O or call a repository.
111
+ - Infrastructure classes coordinate use cases instead of being driven by Application Services.
112
+ - Infrastructure introduces an interface that inner shells depend on.
113
+
114
+ Reviewer warns (APPROVED_WITH_WARNINGS) when:
115
+ - Domain Model is anemic.
116
+ - Application Services are named after CRUD verbs without semantic meaning.
117
+ - Composition Root is fragmented across multiple infrastructure modules.
118
+ - An entity is mutable in places where a value object would be correct.
119
+
120
+ ## Anti-patterns
121
+
122
+ - "Service" layer mixing Domain Services with Application Services indistinguishably
123
+ - Generic repository (`IRepository<T>`) declared at the Infrastructure level
124
+ - Domain Model classes inheriting from an ORM base
125
+ - Domain Services calling repositories
126
+ - Application Services holding state across calls
127
+ - Direct controller-to-repository wiring
128
+ - Infrastructure types appearing as parameters to inner-shell methods
129
+ - "Onion" framing used to disguise Clean Architecture, Hexagonal, or DDD — the rule is the inward dependency direction and the Domain Model at the absolute center
130
+
131
+ ## Outputs
132
+
133
+ Does NOT produce own files. Modifies parent agent's structural decisions during code authoring and review.