jdi-cli 0.1.1 → 0.1.3

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 (50) hide show
  1. package/README.md +6 -0
  2. package/core/agents/jdi-architect.md +19 -0
  3. package/core/agents/jdi-researcher.md +2 -1
  4. package/core/commands/jdi-add-phase.md +171 -0
  5. package/core/commands/jdi-remove-phase.md +228 -0
  6. package/core/skills/clean-architecture/SKILL.md +134 -0
  7. package/core/skills/ddd/SKILL.md +140 -0
  8. package/core/skills/hexagonal/SKILL.md +127 -0
  9. package/core/skills/onion/SKILL.md +133 -0
  10. package/core/skills/the-method/SKILL.md +139 -0
  11. package/core/skills/vertical-slice/SKILL.md +127 -0
  12. package/package.json +1 -1
  13. package/runtimes/antigravity/agents.md +4 -0
  14. package/runtimes/antigravity/skills/clean-architecture/SKILL.md +125 -0
  15. package/runtimes/antigravity/skills/ddd/SKILL.md +131 -0
  16. package/runtimes/antigravity/skills/hexagonal/SKILL.md +118 -0
  17. package/runtimes/antigravity/skills/jdi-add-phase/SKILL.md +171 -0
  18. package/runtimes/antigravity/skills/jdi-architect/SKILL.md +19 -0
  19. package/runtimes/antigravity/skills/jdi-remove-phase/SKILL.md +228 -0
  20. package/runtimes/antigravity/skills/jdi-researcher/SKILL.md +2 -1
  21. package/runtimes/antigravity/skills/onion/SKILL.md +124 -0
  22. package/runtimes/antigravity/skills/the-method/SKILL.md +130 -0
  23. package/runtimes/antigravity/skills/vertical-slice/SKILL.md +118 -0
  24. package/runtimes/claude/CLAUDE.md +4 -0
  25. package/runtimes/claude/agents/jdi-architect.md +19 -0
  26. package/runtimes/claude/agents/jdi-researcher.md +2 -1
  27. package/runtimes/claude/commands/jdi-add-phase.md +171 -0
  28. package/runtimes/claude/commands/jdi-remove-phase.md +228 -0
  29. package/runtimes/claude/skills/clean-architecture/SKILL.md +120 -0
  30. package/runtimes/claude/skills/ddd/SKILL.md +125 -0
  31. package/runtimes/claude/skills/hexagonal/SKILL.md +112 -0
  32. package/runtimes/claude/skills/onion/SKILL.md +119 -0
  33. package/runtimes/claude/skills/the-method/SKILL.md +124 -0
  34. package/runtimes/claude/skills/vertical-slice/SKILL.md +113 -0
  35. package/runtimes/copilot/agents/jdi-architect.agent.md +19 -0
  36. package/runtimes/copilot/agents/jdi-researcher.agent.md +2 -1
  37. package/runtimes/copilot/copilot-instructions.md +4 -0
  38. package/runtimes/copilot/prompts/jdi-add-phase.prompt.md +171 -0
  39. package/runtimes/copilot/prompts/jdi-remove-phase.prompt.md +228 -0
  40. package/runtimes/opencode/AGENTS.md +4 -0
  41. package/runtimes/opencode/agents/jdi-architect.md +19 -0
  42. package/runtimes/opencode/agents/jdi-researcher.md +2 -1
  43. package/runtimes/opencode/commands/jdi-add-phase.md +171 -0
  44. package/runtimes/opencode/commands/jdi-remove-phase.md +228 -0
  45. package/runtimes/opencode/skills/clean-architecture/SKILL.md +120 -0
  46. package/runtimes/opencode/skills/ddd/SKILL.md +125 -0
  47. package/runtimes/opencode/skills/hexagonal/SKILL.md +112 -0
  48. package/runtimes/opencode/skills/onion/SKILL.md +119 -0
  49. package/runtimes/opencode/skills/the-method/SKILL.md +124 -0
  50. package/runtimes/opencode/skills/vertical-slice/SKILL.md +113 -0
@@ -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.
@@ -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.