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,139 @@
1
+ ---
2
+ name: the-method
3
+ description: The Method (Juval Löwy, "Righting Software"). Volatility-based decomposition with universal hierarchy (Clients, Managers, Engines, ResourceAccess, Resources, Utilities). Strict communication rules. Language-agnostic. Mutually exclusive with DDD, Clean Architecture, Hexagonal, Onion, Vertical Slice.
4
+ type: skill
5
+ applies_to: |
6
+ Loaded by doer and reviewer when PROJECT.md `Code Design` is `The Method`.
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
+ - "The Method"
15
+ - "Juval Lowy"
16
+ - "Righting Software"
17
+ - "volatility decomposition"
18
+ - "Universal Hierarchy"
19
+ ---
20
+
21
+ # Skill: The Method (Juval Löwy)
22
+
23
+ Rigid, inviolable design rules from Juval Löwy's *Righting Software*. Decompose by **volatility**, not functionality. Single architecture in the system — do not mix with any other code design.
24
+
25
+ The Method is the ONLY allowed design when PROJECT.md `Code Design: LOCKED: The Method`. Do not introduce DDD aggregates, Clean Architecture use cases, Hexagonal ports, Onion shells, or Vertical Slice handlers. Do not invent a hybrid.
26
+
27
+ ## Core principle (inviolable)
28
+
29
+ **Decompose the system by axes of volatility, never by functionality.**
30
+
31
+ A component is justified only when it encapsulates an independent reason to change. Two pieces of code that change for the same reason belong together. Two pieces that change for different reasons must be separated even if they currently look identical.
32
+
33
+ If a component has no clear volatility it encapsulates, it must not exist.
34
+
35
+ ## The Universal Hierarchy (mandatory)
36
+
37
+ Every system has exactly these 5 architectural categories plus 1 cross-cutting category. No other category may be invented.
38
+
39
+ 1. **Clients** — entry points. UI, CLI, public API endpoints, scheduled triggers, test harnesses. Volatility: presentation, protocol, channel.
40
+ 2. **Managers** — own a use case end-to-end. Sequence the work. Hold the workflow. Volatility: business workflow, use case orchestration.
41
+ 3. **Engines** — stateless business algorithms. Pure rules, calculations, validation logic. Volatility: business algorithm, formula, policy.
42
+ 4. **ResourceAccess** — only path to a Resource. Hides the technology of the data store. Volatility: data access technology.
43
+ 5. **Resources** — the actual data store / external system / queue / cache. Volatility: storage technology, vendor, schema.
44
+
45
+ Cross-cutting (callable from any layer):
46
+
47
+ 6. **Utilities** — Security, Logging, Diagnostics, Hosting, Configuration, Localization, Pub/Sub bus, Identity. Stateless cross-cutting concerns. Volatility: infrastructure technology.
48
+
49
+ Every code unit produced MUST belong to exactly one of these categories. If you cannot decide its category, the unit is wrong and must be redesigned.
50
+
51
+ ## Communication rules (inviolable)
52
+
53
+ The hierarchy is strictly directed. Communication that violates these rules is a defect, regardless of how convenient it appears.
54
+
55
+ 1. **Clients call Managers only.** Clients do not call Engines, ResourceAccess, Resources, or other Clients.
56
+ 2. **Managers call Engines and ResourceAccess.** Managers may also call Utilities.
57
+ 3. **Managers do not call Managers directly.** Manager-to-Manager communication, when required, goes through a **Queue** (publish/subscribe via the Utility bus). Never synchronous Manager-to-Manager.
58
+ 4. **Engines do not call Engines.** Composition of engines happens in the Manager.
59
+ 5. **Engines do not call ResourceAccess.** The Manager pulls data via ResourceAccess and passes it into the Engine.
60
+ 6. **Engines and ResourceAccess do not call Clients.** No upward calls.
61
+ 7. **ResourceAccess is the only component allowed to touch a Resource.** Nothing else (no Manager, no Engine, no Client, no Utility) touches a Resource directly.
62
+ 8. **Resources do not call anything.** They are passive.
63
+ 9. **Utilities are callable by any layer, but do not contain business logic.** Utilities never call Managers, Engines, or ResourceAccess.
64
+ 10. **No skip-level calls upward.** Lower layers never call higher layers synchronously.
65
+ 11. **Calls fan out, never fan in across the same layer synchronously.** No sideways synchronous calls within Managers or within Engines.
66
+
67
+ ## Volatility rules (inviolable)
68
+
69
+ 1. A component exists only to **encapsulate one axis of volatility**. State it explicitly.
70
+ 2. The component's public surface must change only when its encapsulated volatility changes. If a change to an unrelated axis requires editing the component, the decomposition is wrong.
71
+ 3. The more volatile the area, the deeper inside the architecture it lives. The more stable, the closer to the edges.
72
+ 4. **Functional decomposition is forbidden.** Naming components after features ("OrderManager", "CustomerEngine") is allowed only when the feature itself is a volatility boundary. Naming components after operations ("CreateOrder", "ValidateCustomer") is forbidden.
73
+ 5. **Naming after volatility, not noun.** Prefer `PricingEngine` (algorithm volatility) over `OrderService` (feature). Prefer `OrderRepository` only if data-access technology is the encapsulated volatility.
74
+
75
+ ## Composability rules
76
+
77
+ 1. Every Manager must be composable. Adding a new Client (new UI, new API) must not require touching the Manager.
78
+ 2. Engines and ResourceAccess components must be reusable across Managers. If they cannot be reused, the volatility encapsulation is wrong.
79
+ 3. The system must support adding a new use case by adding 1 Manager (and possibly 1 Client method) without modifying any Engine, ResourceAccess, Resource, or Utility.
80
+
81
+ ## Forbidden patterns (inviolable)
82
+
83
+ - **No domain-driven aggregates, anti-corruption layers, or bounded contexts** — that is DDD.
84
+ - **No use cases as a separate layer** — Managers ARE the use cases. Do not create a "UseCase" layer on top of Managers.
85
+ - **No ports & adapters / hexagonal terminology** — ResourceAccess plays the role of adapter for Resources. Do not introduce additional port/adapter layers.
86
+ - **No vertical slices** — code is organized by category, never by feature folder.
87
+ - **No Onion shells.** No "domain core" layer above Engines.
88
+ - **No Repository pattern named after entities** ("UserRepository", "OrderRepository"). ResourceAccess is named after the **resource technology and its volatility**, not after a domain entity. Acceptable: `BillingDataAccess`, `CatalogStore`. Forbidden: `OrderRepository` if "Order" is not a volatility boundary.
89
+ - **No anemic Engine** — an Engine without business logic is forbidden. An Engine with only getters/setters is a defect.
90
+ - **No business logic in Clients.** Clients only translate input to a Manager call and present a Manager response.
91
+ - **No business logic in ResourceAccess.** ResourceAccess maps technology to in-memory representations and nothing more.
92
+ - **No business logic in Resources.** Stored procedures, triggers, or business-logic-bearing schemas are violations.
93
+ - **No business logic in Utilities.** Utilities are infrastructure.
94
+ - **No bypassing ResourceAccess** to touch a Resource (no ORM call in a Manager, no raw SQL in an Engine).
95
+ - **No shared mutable state across components.** Engines are stateless. Managers hold transient workflow state only.
96
+
97
+ ## Mandatory acceptance per code unit
98
+
99
+ Before any Manager / Engine / ResourceAccess / Client / Utility is committed, the author must be able to answer:
100
+
101
+ 1. Which one of the 6 categories does this belong to? (must be exactly one)
102
+ 2. What single axis of volatility does it encapsulate? (must be statable in 1 sentence)
103
+ 3. Which categories does it call? (must comply with the communication rules above)
104
+ 4. What change in the system would cause it to be edited? (must be the volatility it encapsulates, nothing else)
105
+ 5. Is it composable: can another Manager / Client be added without modifying this unit? (must be yes for non-Client units)
106
+
107
+ A unit failing any answer must be redesigned before it ships.
108
+
109
+ ## Reviewer enforcement (gate 5)
110
+
111
+ Reviewer rejects (BLOCKED) when:
112
+ - A Client calls Engine / ResourceAccess / Resource directly.
113
+ - A Manager calls another Manager synchronously.
114
+ - An Engine calls another Engine.
115
+ - An Engine calls ResourceAccess.
116
+ - Any code outside ResourceAccess touches a Resource.
117
+ - A Utility contains business logic.
118
+ - A Repository / Service / Manager is named after a noun-entity instead of a volatility axis (warn first, block on second occurrence in the same PR).
119
+ - The PR adds a new top-level category not in the universal hierarchy.
120
+ - The PR splits code by feature folders instead of by category.
121
+
122
+ Reviewer warns (APPROVED_WITH_WARNINGS) when:
123
+ - A component's encapsulated volatility is not declared (missing 1-line statement at top of file or class).
124
+ - An Engine has no behavior (anemic).
125
+ - A new Manager was added without a Client-level entry point.
126
+
127
+ ## Anti-patterns
128
+
129
+ - "Service layer" with mixed Manager + Engine responsibilities
130
+ - "Helper" / "Util" classes containing business logic
131
+ - Domain entity classes with both data and behavior bound to persistence
132
+ - "Facade" components that hide multiple Managers behind a single class
133
+ - ResourceAccess methods that return business-decided values instead of raw data
134
+ - Cross-Manager transactions implemented via direct calls
135
+ - Synchronous chains crossing 3+ layers
136
+
137
+ ## Outputs
138
+
139
+ Does NOT produce own files. Modifies parent agent's structural decisions during code authoring and review.
@@ -0,0 +1,127 @@
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
+ type: skill
5
+ applies_to: |
6
+ Loaded by doer and reviewer when PROJECT.md `Code Design` is `Vertical Slice`.
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
+ - "Vertical Slice"
15
+ - "Jimmy Bogard"
16
+ - "feature folder"
17
+ - "slice architecture"
18
+ ---
19
+
20
+ # Skill: Vertical Slice Architecture
21
+
22
+ 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.
23
+
24
+ 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.
25
+
26
+ ## Mandatory structure
27
+
28
+ 1. **Each feature is one slice.** A feature is a single user-facing capability (e.g., `RegisterCustomer`, `CancelOrder`, `RenewSubscription`).
29
+ 2. **A slice owns its full pipeline:** input contract, validator, handler, business logic, persistence access, output contract, and slice-specific tests.
30
+ 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.
31
+ 4. **Each feature folder is self-contained.** Inside a folder live only the artifacts that serve that feature.
32
+ 5. **No shared "Service" layer, no shared "Repository" layer, no shared "Manager" layer across slices.** Each slice has its own.
33
+
34
+ ## Slice isolation rules (inviolable)
35
+
36
+ 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.
37
+ 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.
38
+ 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.
39
+ 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.
40
+
41
+ ## Slice composition (mandatory contents)
42
+
43
+ Each slice MUST contain:
44
+
45
+ 1. **Request / Command / Query contract** — a structure describing the input.
46
+ 2. **Handler** — receives the request, executes the logic, returns the response.
47
+ 3. **Validator** (if input requires validation) — slice-local validation rules.
48
+ 4. **Response contract** — the output shape returned to the caller.
49
+ 5. **Slice-local types** — any DTOs, view models, or projections the slice needs.
50
+ 6. **Slice-local tests** — integration tests that exercise the slice end-to-end.
51
+
52
+ A slice MAY contain:
53
+
54
+ - A slice-specific persistence access path (raw query, ORM query, projection, command-side persistence).
55
+ - A slice-specific external system call.
56
+ - Slice-local pre/post processing.
57
+
58
+ A slice MUST NOT contain:
59
+
60
+ - References to another slice's handler, request, or response types.
61
+ - References to a shared "Service" abstracting multiple slices.
62
+ - A "Manager" coordinating multiple slices.
63
+
64
+ ## Cross-cutting concerns (inviolable)
65
+
66
+ 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.
67
+ 2. Authentication and authorization decisions may use shared types (claims, principals) but are enforced at the pipeline level, not inside the handler.
68
+ 3. Validation runs as a pipeline step before the handler executes. The handler assumes valid input.
69
+ 4. Logging, tracing, metrics: pipeline behaviors. The handler does not invoke logging libraries for cross-cutting purposes.
70
+
71
+ ## Persistence rules
72
+
73
+ 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.
74
+ 2. **Reads and writes may diverge structurally.** A slice that reads may use a different model than a slice that writes; this is encouraged.
75
+ 3. **No "Domain Model" required to be shared across slices.** Each slice models the data it needs in the shape it needs.
76
+ 4. **A shared schema (database) is acceptable; a shared in-code model abstraction is not.**
77
+
78
+ ## Forbidden patterns (inviolable)
79
+
80
+ - **Technical-layer primary folders** (`controllers/`, `services/`, `repositories/`, `models/`) used as the system's primary organization.
81
+ - **A handler calling another handler.**
82
+ - **A "Service" class injected into multiple handlers** to provide their business logic.
83
+ - **A "Manager" class coordinating multiple slices.**
84
+ - **A shared "Repository" abstraction** consumed by 5+ slices.
85
+ - **Cross-slice imports of internal slice types.** Slice A importing `B.HandleQuery` or `B.RequestDto` is forbidden.
86
+ - **Slice A invoking slice B via an internal interface** instead of via the public boundary (HTTP, queue, event).
87
+ - **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.
88
+ - **Forcing all slices through a shared base handler class** that contains business logic.
89
+ - **A shared "Domain Model" referenced by all slices** as the primary modeling element.
90
+
91
+ ## Naming conventions
92
+
93
+ - Feature folders: feature name in domain language (`RegisterCustomer/`, `CancelOrder/`, `ViewCustomerDashboard/`).
94
+ - Request types: domain operation name (`RegisterCustomerCommand`, `CancelOrderCommand`, `ViewCustomerDashboardQuery`).
95
+ - Handler types: paired with request (`RegisterCustomerHandler`).
96
+ - Validator types: paired with request (`RegisterCustomerValidator`).
97
+ - Response types: domain output name (`RegisterCustomerResponse`).
98
+ - Internal slice types: prefixed by feature name when shared inside the slice (`RegisterCustomerEmailTemplate`).
99
+
100
+ ## Reviewer enforcement (gate 5)
101
+
102
+ Reviewer rejects (BLOCKED) when:
103
+ - The codebase is primarily organized by technical layer instead of by feature.
104
+ - A handler invokes another slice's handler, request, or response type.
105
+ - A new "Service" / "Manager" / "Coordinator" class is introduced that spans multiple slices and carries business logic.
106
+ - A shared generic repository is introduced and consumed by multiple slices.
107
+ - Cross-cutting concerns are injected into handlers as shared services instead of applied as pipeline behaviors.
108
+ - Slice A imports types from slice B's internal folder.
109
+
110
+ Reviewer warns (APPROVED_WITH_WARNINGS) when:
111
+ - Two slices share an identical small helper that has been duplicated 3+ times (candidate for extraction, not required).
112
+ - A slice contains logic that appears to belong to a different slice.
113
+ - A slice handler is long enough to suggest splitting into pipeline behaviors.
114
+ - A slice references a "Domain Service" or "Aggregate" terminology that may indicate a different design creeping in.
115
+
116
+ ## Anti-patterns
117
+
118
+ - "Vertical slices" implemented inside an MVC controllers/services/repositories folder structure (the folders betray the layer-primary structure)
119
+ - A "Domain" project that all slices reference, containing entities + services + repositories — that is layered or Onion in disguise
120
+ - Cross-slice "Coordinator" classes that orchestrate two handlers
121
+ - A shared "BaseHandler" that contains transaction management AND business logic
122
+ - A slice handler that delegates 90% of its work to a shared service (the slice is hollow)
123
+ - Premature "DRY" extraction that merges slices into a generic handler with strategy patterns
124
+
125
+ ## Outputs
126
+
127
+ Does NOT produce own files. Modifies parent agent's structural decisions during code authoring and review.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jdi-cli",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "JDI (Just Do It) — lean workflow toolkit for Claude Code, GitHub Copilot, Antigravity, and OpenCode. 10 commands (7 loop + ralph + adopt + meta), 6 core agents + N per-project specialists with file-glob routing. Optional Playwright MCP + Caveman plugin install.",
5
5
  "bin": {
6
6
  "jdi": "bin/jdi.js"
@@ -0,0 +1,125 @@
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
+ triggers:
5
+ - "Clean Architecture"
6
+ - "Robert Martin clean"
7
+ - "Dependency Rule"
8
+ - "Use Cases layer"
9
+ ---
10
+
11
+ # Skill: Clean Architecture
12
+
13
+ Rigid, inviolable rules from Robert C. Martin's *Clean Architecture*. The system is organized as **concentric layers**, and source-code dependencies point only **inward**.
14
+
15
+ 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.
16
+
17
+ ## The 4 layers (mandatory)
18
+
19
+ From innermost to outermost:
20
+
21
+ 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.
22
+ 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.
23
+ 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.
24
+ 4. **Frameworks & Drivers** — the outermost layer. Web framework, database, UI framework, file system, devices, external APIs. Glue code only — minimal logic.
25
+
26
+ Every code unit belongs to exactly one of these 4 layers. A unit that does not fit must be redesigned.
27
+
28
+ ## The Dependency Rule (inviolable)
29
+
30
+ **Source-code dependencies point only inward. Nothing in an inner circle may know anything at all about something in an outer circle.**
31
+
32
+ 1. Entities depend on nothing outside the Entities layer.
33
+ 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.
34
+ 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.
35
+ 4. Frameworks & Drivers depend on whatever is convenient (Adapters, libraries, vendor SDKs).
36
+ 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.
37
+
38
+ ## Boundary Crossing rules (inviolable)
39
+
40
+ 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.
41
+ 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.
42
+ 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.
43
+ 4. **Use Cases return DTOs / output ports.** They never return entities directly to outer layers.
44
+ 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.
45
+
46
+ ## Layer purity rules (inviolable)
47
+
48
+ ### Entities
49
+
50
+ 1. Entities are pure. No imports from any other layer.
51
+ 2. Entities encapsulate enterprise-wide business rules; if a rule is application-specific, it does not belong here.
52
+ 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.
53
+ 4. Entities have no annotations from persistence, serialization, or web frameworks.
54
+ 5. Entities are not anemic. Behavior lives with data.
55
+
56
+ ### Use Cases
57
+
58
+ 6. Each Use Case has a single, application-specific purpose stated by its name (verb-noun: e.g., `RegisterCustomer`, `RenewSubscription`).
59
+ 7. A Use Case owns its input port (input boundary) and output port (output boundary) as interfaces in the Use Cases layer.
60
+ 8. A Use Case does not import any framework, ORM, HTTP, file-system, or external-API type.
61
+ 9. A Use Case is testable without any infrastructure. If it cannot be tested without spinning up DB / HTTP / queue, the design is wrong.
62
+ 10. A Use Case orchestrates Entities. It does not duplicate enterprise rules that already live in Entities.
63
+
64
+ ### Interface Adapters
65
+
66
+ 11. Controllers translate external input (HTTP request, CLI args, message payload) into Use Case input DTOs and invoke the Use Case.
67
+ 12. Presenters convert Use Case output DTOs into a form suitable for delivery (ViewModel, response body).
68
+ 13. Gateways implement the persistence interfaces declared by the Use Cases.
69
+ 14. Adapters never contain business rules.
70
+ 15. Adapters depend inward on Use Cases / Entities, never outward on Frameworks.
71
+
72
+ ### Frameworks & Drivers
73
+
74
+ 16. Framework code is glue only. It wires Adapters to the framework runtime.
75
+ 17. Web framework controllers in the Frameworks layer call Adapters, not Use Cases directly.
76
+ 18. ORM-mapped models, framework annotations, configuration code, dependency injection wiring live here.
77
+
78
+ ## Composition rules
79
+
80
+ 1. **Composition Root is in the outermost layer.** The main / startup / DI container assembles all components.
81
+ 2. **Inner layers never construct outer layer types.** Dependencies are injected through interfaces defined by the inner layer.
82
+ 3. **Plug-in architecture.** A change in framework, DB, or UI must require changes only in the outer layers. Inner layers stay untouched.
83
+
84
+ ## Forbidden patterns (inviolable)
85
+
86
+ - **Use Cases referencing framework types** (HTTP request, ORM entity, file handle, vendor SDK type).
87
+ - **Entities referencing persistence frameworks** (ORM annotations, database column attributes that encode behavior).
88
+ - **Anemic Entities.** Behavior must accompany data.
89
+ - **Skipping a layer for convenience** (Controller calling a repository directly, Presenter calling the database).
90
+ - **Returning framework / ORM types from a Use Case.**
91
+ - **Use Case knowing the concrete Adapter** (e.g., calling a specific HTTP client class). Use Cases declare interfaces; Adapters implement.
92
+ - **Shared "Util" / "Helper" classes spanning layers** with hidden business rules.
93
+ - **Database-driven design** where the schema dictates Entity shape.
94
+ - **Cross-layer reach-around** (Framework code calling Use Cases bypassing Adapters, Adapters calling Frameworks bypassing the Composition Root).
95
+ - **Concentric layers reorganized as feature folders** that hide which layer a unit belongs to.
96
+
97
+ ## Reviewer enforcement (gate 5)
98
+
99
+ Reviewer rejects (BLOCKED) when:
100
+ - An Entity or Use Case imports a framework, ORM, HTTP, or vendor SDK type.
101
+ - A Use Case returns a framework / ORM / DTO defined in an outer layer.
102
+ - A Controller invokes persistence directly instead of going through a Use Case.
103
+ - An Adapter contains a business rule.
104
+ - An inner-layer file imports an outer-layer file (direct dependency violation).
105
+ - Boundary crossings carry framework-specific types instead of plain DTOs.
106
+ - Use Cases or Entities are not testable without infrastructure.
107
+
108
+ Reviewer warns (APPROVED_WITH_WARNINGS) when:
109
+ - A Use Case is named after a CRUD verb without application semantics.
110
+ - An Entity has only getters/setters (anemic).
111
+ - An Adapter file leaks framework annotations into its public interface.
112
+ - The Composition Root is split across layers instead of living in the outermost layer.
113
+
114
+ ## Anti-patterns
115
+
116
+ - "Service" layer mixing Use Cases with Adapter responsibilities
117
+ - DTOs leaking into Entities
118
+ - ORM entities serving as both Entity and persistence model
119
+ - Controller-with-business-logic
120
+ - Use Case classes that depend on framework annotations
121
+ - Hexagonal-style port terminology used to disguise a violation (the rule is the Dependency Rule, not the port naming)
122
+
123
+ ## Outputs
124
+
125
+ Does NOT produce own files. Modifies parent agent's structural decisions during code authoring and review.
@@ -0,0 +1,131 @@
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
+ triggers:
5
+ - "DDD"
6
+ - "Domain-Driven Design"
7
+ - "bounded context"
8
+ - "aggregate root"
9
+ - "ubiquitous language"
10
+ ---
11
+
12
+ # Skill: Domain-Driven Design (DDD)
13
+
14
+ 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.
15
+
16
+ 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.
17
+
18
+ ## Strategic rules (inviolable)
19
+
20
+ 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.
21
+ 2. **Each BC must be named.** Anonymous BCs do not exist. The name appears in the codebase (folder, namespace, module, package).
22
+ 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.
23
+ 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.
24
+ 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.
25
+ 6. **Anticorruption Layer (ACL) is required when integrating with a legacy or external model.** Foreign models do not leak into a BC.
26
+ 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.
27
+ 8. **Domain knowledge does not leak into Generic Subdomains.** Generic Subdomain code (Identity, Logging, Notification) must be reusable across projects without domain assumptions.
28
+
29
+ ## Tactical rules (inviolable)
30
+
31
+ ### Aggregate
32
+
33
+ 1. **An Aggregate has exactly one Root.** All external access goes through the Root. References to inner entities from outside the Aggregate are forbidden.
34
+ 2. **The Aggregate Root enforces all invariants of the Aggregate.** No partial state may be observed by other Aggregates or by Application Services.
35
+ 3. **One transaction modifies at most one Aggregate instance.** Multi-aggregate consistency is achieved by Domain Events, not by enclosing transactions.
36
+ 4. **Aggregates reference other Aggregates only by identifier (ID), never by direct object reference.** Cross-aggregate navigation through references is forbidden.
37
+ 5. **Aggregate boundaries are designed around invariants and transactional consistency, never around UI screens or convenience.**
38
+ 6. **Aggregates must be small.** If an Aggregate contains a collection that grows unbounded, the design is wrong and must be split.
39
+
40
+ ### Entity vs Value Object
41
+
42
+ 7. **An Entity has identity that persists across state changes.** Equality is by identity, never by attributes.
43
+ 8. **A Value Object is immutable and identity-less.** Equality is by attributes. Mutating a Value Object is forbidden — replace, do not modify.
44
+ 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.
45
+ 10. **Value Objects must be self-validating.** Construction of a Value Object with invalid state must fail at construction time.
46
+
47
+ ### Domain Service
48
+
49
+ 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.
50
+ 12. **Domain Services are stateless and named with a Ubiquitous Language verb-noun expressing a domain operation, not a technical action.**
51
+ 13. **Domain Services contain domain logic only.** Persistence, transactions, messaging, and orchestration of use cases live in Application Services.
52
+
53
+ ### Repository
54
+
55
+ 14. **One Repository per Aggregate Root.** No repository per Entity that is not a Root. No "generic" repository shared across Aggregates.
56
+ 15. **Repository interface lives with the domain model, not with persistence.** Persistence implementation lives outside the domain layer.
57
+ 16. **Repositories return whole Aggregates, never partial state.** A method returning a piece of an Aggregate (single inner entity, partial fields) is forbidden.
58
+ 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.
59
+
60
+ ### Domain Event
61
+
62
+ 18. **Domain Events are immutable, past-tense facts.** Names are past tense (e.g., "OrderPlaced", "PaymentRefused"). Mutating a Domain Event is forbidden.
63
+ 19. **Domain Events are emitted by Aggregates.** Application Services do not invent domain events.
64
+ 20. **Domain Events carry only the data needed to react to the fact.** Do not embed entire Aggregate state.
65
+ 21. **Cross-Aggregate consistency uses Domain Events, not synchronous calls between Aggregates.**
66
+
67
+ ### Application Service
68
+
69
+ 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.
70
+ 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.
71
+ 24. **Application Services do not return domain entities directly to UI.** Return DTOs or projections.
72
+
73
+ ### Domain layer purity
74
+
75
+ 25. **The Domain Layer depends on nothing external.** No framework, ORM, HTTP, file system, or messaging library is referenced from domain code.
76
+ 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.
77
+ 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.
78
+ 28. **No "Manager", "Helper", "Util", "Processor" classes in the domain layer.** These names betray missing domain concepts.
79
+
80
+ ## Modeling rules (inviolable)
81
+
82
+ 1. The model in code must match the model in conversation with domain experts. If they diverge, the code is wrong.
83
+ 2. Names come from the Ubiquitous Language. Technical names ("Data", "Info", "Object", "Item", "Entry") are forbidden in the domain layer.
84
+ 3. New domain concepts are added to the Ubiquitous Language before they are added to the code.
85
+ 4. Domain experts must recognize the names, intents, and invariants encoded in the domain layer.
86
+
87
+ ## Forbidden patterns (inviolable)
88
+
89
+ - **Generic Repository** spanning multiple Aggregates (`Repository<T>`) is forbidden.
90
+ - **Lazy-loaded navigation across Aggregates** is forbidden.
91
+ - **Transactions spanning multiple Aggregates** are forbidden.
92
+ - **Returning Entities from a query that crosses Aggregates** is forbidden — use a read model.
93
+ - **CRUD-only Application Services** ("CreateUser", "UpdateUser") with no domain semantics are a smell; reframe as domain operations ("RegisterCustomer", "DeactivateAccount") when meaning exists.
94
+ - **Anti-corruption layer absence** when consuming an external/legacy model is a violation.
95
+ - **Sharing entities across Bounded Contexts** is forbidden.
96
+ - **DTO leaking into the domain layer** is forbidden.
97
+
98
+ ## Reviewer enforcement (gate 5)
99
+
100
+ Reviewer rejects (BLOCKED) when:
101
+ - Domain code references a framework / ORM / HTTP / messaging library.
102
+ - An Aggregate is mutated from outside its Root.
103
+ - A single transaction modifies more than one Aggregate instance.
104
+ - A Repository serves multiple Aggregate Roots, or returns partial state.
105
+ - Cross-Aggregate references are by object instead of by ID.
106
+ - A Domain Service performs persistence, transactions, or messaging.
107
+ - An Application Service contains business rules.
108
+ - An Entity / VO has only getters/setters (anemic).
109
+ - Two Bounded Contexts share the same model class.
110
+ - An integration with an external system has no Anticorruption Layer.
111
+
112
+ Reviewer warns (APPROVED_WITH_WARNINGS) when:
113
+ - A class is named "Manager" / "Helper" / "Util" / "Processor" in the domain layer.
114
+ - A Value Object is mutable.
115
+ - An Aggregate exposes its internal collections directly.
116
+ - A Domain Event is named in present/future tense.
117
+ - The Ubiquitous Language used in code disagrees with the language in PROJECT.md or CONTEXT.md.
118
+
119
+ ## Anti-patterns
120
+
121
+ - Anemic Domain Model
122
+ - Generic Repository pattern
123
+ - God Aggregate (entire schema under one Root)
124
+ - Smart UI bypassing domain
125
+ - Domain services that orchestrate use cases (those are Application Services)
126
+ - "Service layer" without distinguishing Domain Service vs Application Service
127
+ - Database-first design driving Aggregate shape
128
+
129
+ ## Outputs
130
+
131
+ Does NOT produce own files. Modifies parent agent's structural decisions during code authoring and review.