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.
- package/core/agents/jdi-architect.md +19 -0
- package/core/agents/jdi-researcher.md +2 -1
- package/core/skills/clean-architecture/SKILL.md +134 -0
- package/core/skills/ddd/SKILL.md +140 -0
- package/core/skills/hexagonal/SKILL.md +127 -0
- package/core/skills/onion/SKILL.md +133 -0
- package/core/skills/the-method/SKILL.md +139 -0
- package/core/skills/vertical-slice/SKILL.md +127 -0
- package/package.json +1 -1
- package/runtimes/antigravity/skills/clean-architecture/SKILL.md +125 -0
- package/runtimes/antigravity/skills/ddd/SKILL.md +131 -0
- package/runtimes/antigravity/skills/hexagonal/SKILL.md +118 -0
- package/runtimes/antigravity/skills/jdi-architect/SKILL.md +19 -0
- package/runtimes/antigravity/skills/jdi-researcher/SKILL.md +2 -1
- package/runtimes/antigravity/skills/onion/SKILL.md +124 -0
- package/runtimes/antigravity/skills/the-method/SKILL.md +130 -0
- package/runtimes/antigravity/skills/vertical-slice/SKILL.md +118 -0
- package/runtimes/claude/agents/jdi-architect.md +19 -0
- package/runtimes/claude/agents/jdi-researcher.md +2 -1
- package/runtimes/claude/skills/clean-architecture/SKILL.md +120 -0
- package/runtimes/claude/skills/ddd/SKILL.md +125 -0
- package/runtimes/claude/skills/hexagonal/SKILL.md +112 -0
- package/runtimes/claude/skills/onion/SKILL.md +119 -0
- package/runtimes/claude/skills/the-method/SKILL.md +124 -0
- package/runtimes/claude/skills/vertical-slice/SKILL.md +113 -0
- package/runtimes/copilot/agents/jdi-architect.agent.md +19 -0
- package/runtimes/copilot/agents/jdi-researcher.agent.md +2 -1
- package/runtimes/opencode/agents/jdi-architect.md +19 -0
- package/runtimes/opencode/agents/jdi-researcher.md +2 -1
- package/runtimes/opencode/skills/clean-architecture/SKILL.md +120 -0
- package/runtimes/opencode/skills/ddd/SKILL.md +125 -0
- package/runtimes/opencode/skills/hexagonal/SKILL.md +112 -0
- package/runtimes/opencode/skills/onion/SKILL.md +119 -0
- package/runtimes/opencode/skills/the-method/SKILL.md +124 -0
- package/runtimes/opencode/skills/vertical-slice/SKILL.md +113 -0
|
@@ -0,0 +1,119 @@
|
|
|
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
|
+
---
|
|
5
|
+
|
|
6
|
+
# Skill: Onion Architecture
|
|
7
|
+
|
|
8
|
+
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.
|
|
9
|
+
|
|
10
|
+
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.
|
|
11
|
+
|
|
12
|
+
## The shells (mandatory order from center outward)
|
|
13
|
+
|
|
14
|
+
1. **Domain Model** — entities and value objects expressing the business state. No behavior dependent on infrastructure. The absolute center.
|
|
15
|
+
2. **Domain Services** — domain operations that do not belong to a single entity/value object. Pure domain logic. Stateless.
|
|
16
|
+
3. **Application Services** — orchestrate use cases. Coordinate Domain Services and Domain Model. Define interfaces for infrastructure dependencies (repository contracts, external system contracts).
|
|
17
|
+
4. **Infrastructure** — persistence implementations, external system clients, UI, tests, framework bindings. The outermost shell.
|
|
18
|
+
|
|
19
|
+
Every code unit belongs to exactly one of these 4 shells. A unit that does not fit must be redesigned.
|
|
20
|
+
|
|
21
|
+
## The Dependency Direction (inviolable)
|
|
22
|
+
|
|
23
|
+
**Dependencies point inward.** Every shell may depend on shells closer to the center; no shell may depend on shells farther from the center.
|
|
24
|
+
|
|
25
|
+
1. Domain Model depends on nothing else in the system.
|
|
26
|
+
2. Domain Services depend on Domain Model only.
|
|
27
|
+
3. Application Services depend on Domain Model and Domain Services.
|
|
28
|
+
4. Infrastructure depends on Application Services, Domain Services, and Domain Model.
|
|
29
|
+
5. Names defined in Infrastructure (ORM types, framework types, vendor SDK types) never appear in any inner shell.
|
|
30
|
+
|
|
31
|
+
## Inversion across infrastructure (inviolable)
|
|
32
|
+
|
|
33
|
+
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.
|
|
34
|
+
2. **Infrastructure implements those interfaces.** The implementation class lives in Infrastructure. The interface lives inward.
|
|
35
|
+
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.
|
|
36
|
+
|
|
37
|
+
## Domain Model rules
|
|
38
|
+
|
|
39
|
+
1. The Domain Model contains only entities and value objects in domain language.
|
|
40
|
+
2. The Domain Model has no annotations, no inheritance from framework base classes, no persistence concerns, no serialization concerns.
|
|
41
|
+
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.
|
|
42
|
+
4. Value objects are immutable. Replacing is the only mutation pattern.
|
|
43
|
+
5. The Domain Model does not know how it is persisted, displayed, or transmitted.
|
|
44
|
+
|
|
45
|
+
## Domain Services rules
|
|
46
|
+
|
|
47
|
+
6. Domain Services are stateless. They contain pure domain logic that does not naturally belong to a single Entity or Value Object.
|
|
48
|
+
7. Domain Services depend on the Domain Model only. They never call repositories, infrastructure, or Application Services.
|
|
49
|
+
8. Domain Services do not perform I/O.
|
|
50
|
+
9. Names of Domain Services are domain operations, not technical operations.
|
|
51
|
+
|
|
52
|
+
## Application Services rules
|
|
53
|
+
|
|
54
|
+
10. Application Services orchestrate use cases. One Application Service method = one application-level operation.
|
|
55
|
+
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).
|
|
56
|
+
12. Application Services do not contain business rules — they coordinate. Business rules live in Domain Model and Domain Services.
|
|
57
|
+
13. Application Services do not import any Infrastructure class. They depend on the interfaces they themselves declare.
|
|
58
|
+
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.
|
|
59
|
+
|
|
60
|
+
## Infrastructure rules
|
|
61
|
+
|
|
62
|
+
15. Infrastructure implements interfaces declared by inner shells. It does not introduce interfaces of its own that inner shells consume.
|
|
63
|
+
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.
|
|
64
|
+
17. Infrastructure does not contain business rules.
|
|
65
|
+
18. Infrastructure classes are named with their technology when the technology is the encapsulated concern (e.g., `SqlOrderRepository`, `HttpPaymentGateway`).
|
|
66
|
+
19. Two infrastructure classes do not call each other to fulfill a use case. Coordination happens via Application Services.
|
|
67
|
+
|
|
68
|
+
## Forbidden patterns (inviolable)
|
|
69
|
+
|
|
70
|
+
- **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.
|
|
71
|
+
- **Persistence annotations or framework types in the Domain Model.**
|
|
72
|
+
- **Repository interface placed in Infrastructure.** The interface must live inward (Application Services or Domain Services).
|
|
73
|
+
- **Domain Services performing I/O.**
|
|
74
|
+
- **Application Services containing business rules.**
|
|
75
|
+
- **Infrastructure-defined interfaces consumed by inner shells.**
|
|
76
|
+
- **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).
|
|
77
|
+
- **Anemic Domain Model.**
|
|
78
|
+
- **CRUD-only Application Services** with no application semantics.
|
|
79
|
+
- **Cross-shell reach-around** (Infrastructure A calling Infrastructure B to fulfill a use case without going through an Application Service).
|
|
80
|
+
|
|
81
|
+
## Naming conventions
|
|
82
|
+
|
|
83
|
+
- Domain Model classes: domain nouns (`Customer`, `Order`, `Subscription`).
|
|
84
|
+
- Domain Services: domain verb-noun (`OrderPricingPolicy`, `SubscriptionRenewalRules`).
|
|
85
|
+
- Application Services: application-level operations (`RegisterCustomerService`, `RenewSubscriptionService`).
|
|
86
|
+
- Interfaces consumed by Application Services: domain-meaningful (`IOrderRepository`, `IPaymentGateway`, `INotificationSender`).
|
|
87
|
+
- Infrastructure classes: technology-qualified (`SqlOrderRepository`, `StripePaymentGateway`, `SmtpNotificationSender`).
|
|
88
|
+
|
|
89
|
+
## Reviewer enforcement (gate 5)
|
|
90
|
+
|
|
91
|
+
Reviewer rejects (BLOCKED) when:
|
|
92
|
+
- Domain Model, Domain Services, or Application Services import a framework / ORM / HTTP / vendor SDK type.
|
|
93
|
+
- A repository or external-system interface is declared in Infrastructure and consumed inward.
|
|
94
|
+
- An inner shell file imports an outer shell file.
|
|
95
|
+
- Application Services contain business rules that belong on Domain Model or Domain Services.
|
|
96
|
+
- Domain Services perform I/O or call a repository.
|
|
97
|
+
- Infrastructure classes coordinate use cases instead of being driven by Application Services.
|
|
98
|
+
- Infrastructure introduces an interface that inner shells depend on.
|
|
99
|
+
|
|
100
|
+
Reviewer warns (APPROVED_WITH_WARNINGS) when:
|
|
101
|
+
- Domain Model is anemic.
|
|
102
|
+
- Application Services are named after CRUD verbs without semantic meaning.
|
|
103
|
+
- Composition Root is fragmented across multiple infrastructure modules.
|
|
104
|
+
- An entity is mutable in places where a value object would be correct.
|
|
105
|
+
|
|
106
|
+
## Anti-patterns
|
|
107
|
+
|
|
108
|
+
- "Service" layer mixing Domain Services with Application Services indistinguishably
|
|
109
|
+
- Generic repository (`IRepository<T>`) declared at the Infrastructure level
|
|
110
|
+
- Domain Model classes inheriting from an ORM base
|
|
111
|
+
- Domain Services calling repositories
|
|
112
|
+
- Application Services holding state across calls
|
|
113
|
+
- Direct controller-to-repository wiring
|
|
114
|
+
- Infrastructure types appearing as parameters to inner-shell methods
|
|
115
|
+
- "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
|
|
116
|
+
|
|
117
|
+
## Outputs
|
|
118
|
+
|
|
119
|
+
Does NOT produce own files. Modifies parent agent's structural decisions during code authoring and review.
|
|
@@ -0,0 +1,124 @@
|
|
|
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
|
+
---
|
|
5
|
+
|
|
6
|
+
# Skill: The Method (Juval Löwy)
|
|
7
|
+
|
|
8
|
+
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.
|
|
9
|
+
|
|
10
|
+
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.
|
|
11
|
+
|
|
12
|
+
## Core principle (inviolable)
|
|
13
|
+
|
|
14
|
+
**Decompose the system by axes of volatility, never by functionality.**
|
|
15
|
+
|
|
16
|
+
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.
|
|
17
|
+
|
|
18
|
+
If a component has no clear volatility it encapsulates, it must not exist.
|
|
19
|
+
|
|
20
|
+
## The Universal Hierarchy (mandatory)
|
|
21
|
+
|
|
22
|
+
Every system has exactly these 5 architectural categories plus 1 cross-cutting category. No other category may be invented.
|
|
23
|
+
|
|
24
|
+
1. **Clients** — entry points. UI, CLI, public API endpoints, scheduled triggers, test harnesses. Volatility: presentation, protocol, channel.
|
|
25
|
+
2. **Managers** — own a use case end-to-end. Sequence the work. Hold the workflow. Volatility: business workflow, use case orchestration.
|
|
26
|
+
3. **Engines** — stateless business algorithms. Pure rules, calculations, validation logic. Volatility: business algorithm, formula, policy.
|
|
27
|
+
4. **ResourceAccess** — only path to a Resource. Hides the technology of the data store. Volatility: data access technology.
|
|
28
|
+
5. **Resources** — the actual data store / external system / queue / cache. Volatility: storage technology, vendor, schema.
|
|
29
|
+
|
|
30
|
+
Cross-cutting (callable from any layer):
|
|
31
|
+
|
|
32
|
+
6. **Utilities** — Security, Logging, Diagnostics, Hosting, Configuration, Localization, Pub/Sub bus, Identity. Stateless cross-cutting concerns. Volatility: infrastructure technology.
|
|
33
|
+
|
|
34
|
+
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.
|
|
35
|
+
|
|
36
|
+
## Communication rules (inviolable)
|
|
37
|
+
|
|
38
|
+
The hierarchy is strictly directed. Communication that violates these rules is a defect, regardless of how convenient it appears.
|
|
39
|
+
|
|
40
|
+
1. **Clients call Managers only.** Clients do not call Engines, ResourceAccess, Resources, or other Clients.
|
|
41
|
+
2. **Managers call Engines and ResourceAccess.** Managers may also call Utilities.
|
|
42
|
+
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.
|
|
43
|
+
4. **Engines do not call Engines.** Composition of engines happens in the Manager.
|
|
44
|
+
5. **Engines do not call ResourceAccess.** The Manager pulls data via ResourceAccess and passes it into the Engine.
|
|
45
|
+
6. **Engines and ResourceAccess do not call Clients.** No upward calls.
|
|
46
|
+
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.
|
|
47
|
+
8. **Resources do not call anything.** They are passive.
|
|
48
|
+
9. **Utilities are callable by any layer, but do not contain business logic.** Utilities never call Managers, Engines, or ResourceAccess.
|
|
49
|
+
10. **No skip-level calls upward.** Lower layers never call higher layers synchronously.
|
|
50
|
+
11. **Calls fan out, never fan in across the same layer synchronously.** No sideways synchronous calls within Managers or within Engines.
|
|
51
|
+
|
|
52
|
+
## Volatility rules (inviolable)
|
|
53
|
+
|
|
54
|
+
1. A component exists only to **encapsulate one axis of volatility**. State it explicitly.
|
|
55
|
+
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.
|
|
56
|
+
3. The more volatile the area, the deeper inside the architecture it lives. The more stable, the closer to the edges.
|
|
57
|
+
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.
|
|
58
|
+
5. **Naming after volatility, not noun.** Prefer `PricingEngine` (algorithm volatility) over `OrderService` (feature). Prefer `OrderRepository` only if data-access technology is the encapsulated volatility.
|
|
59
|
+
|
|
60
|
+
## Composability rules
|
|
61
|
+
|
|
62
|
+
1. Every Manager must be composable. Adding a new Client (new UI, new API) must not require touching the Manager.
|
|
63
|
+
2. Engines and ResourceAccess components must be reusable across Managers. If they cannot be reused, the volatility encapsulation is wrong.
|
|
64
|
+
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.
|
|
65
|
+
|
|
66
|
+
## Forbidden patterns (inviolable)
|
|
67
|
+
|
|
68
|
+
- **No domain-driven aggregates, anti-corruption layers, or bounded contexts** — that is DDD.
|
|
69
|
+
- **No use cases as a separate layer** — Managers ARE the use cases. Do not create a "UseCase" layer on top of Managers.
|
|
70
|
+
- **No ports & adapters / hexagonal terminology** — ResourceAccess plays the role of adapter for Resources. Do not introduce additional port/adapter layers.
|
|
71
|
+
- **No vertical slices** — code is organized by category, never by feature folder.
|
|
72
|
+
- **No Onion shells.** No "domain core" layer above Engines.
|
|
73
|
+
- **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.
|
|
74
|
+
- **No anemic Engine** — an Engine without business logic is forbidden. An Engine with only getters/setters is a defect.
|
|
75
|
+
- **No business logic in Clients.** Clients only translate input to a Manager call and present a Manager response.
|
|
76
|
+
- **No business logic in ResourceAccess.** ResourceAccess maps technology to in-memory representations and nothing more.
|
|
77
|
+
- **No business logic in Resources.** Stored procedures, triggers, or business-logic-bearing schemas are violations.
|
|
78
|
+
- **No business logic in Utilities.** Utilities are infrastructure.
|
|
79
|
+
- **No bypassing ResourceAccess** to touch a Resource (no ORM call in a Manager, no raw SQL in an Engine).
|
|
80
|
+
- **No shared mutable state across components.** Engines are stateless. Managers hold transient workflow state only.
|
|
81
|
+
|
|
82
|
+
## Mandatory acceptance per code unit
|
|
83
|
+
|
|
84
|
+
Before any Manager / Engine / ResourceAccess / Client / Utility is committed, the author must be able to answer:
|
|
85
|
+
|
|
86
|
+
1. Which one of the 6 categories does this belong to? (must be exactly one)
|
|
87
|
+
2. What single axis of volatility does it encapsulate? (must be statable in 1 sentence)
|
|
88
|
+
3. Which categories does it call? (must comply with the communication rules above)
|
|
89
|
+
4. What change in the system would cause it to be edited? (must be the volatility it encapsulates, nothing else)
|
|
90
|
+
5. Is it composable: can another Manager / Client be added without modifying this unit? (must be yes for non-Client units)
|
|
91
|
+
|
|
92
|
+
A unit failing any answer must be redesigned before it ships.
|
|
93
|
+
|
|
94
|
+
## Reviewer enforcement (gate 5)
|
|
95
|
+
|
|
96
|
+
Reviewer rejects (BLOCKED) when:
|
|
97
|
+
- A Client calls Engine / ResourceAccess / Resource directly.
|
|
98
|
+
- A Manager calls another Manager synchronously.
|
|
99
|
+
- An Engine calls another Engine.
|
|
100
|
+
- An Engine calls ResourceAccess.
|
|
101
|
+
- Any code outside ResourceAccess touches a Resource.
|
|
102
|
+
- A Utility contains business logic.
|
|
103
|
+
- 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).
|
|
104
|
+
- The PR adds a new top-level category not in the universal hierarchy.
|
|
105
|
+
- The PR splits code by feature folders instead of by category.
|
|
106
|
+
|
|
107
|
+
Reviewer warns (APPROVED_WITH_WARNINGS) when:
|
|
108
|
+
- A component's encapsulated volatility is not declared (missing 1-line statement at top of file or class).
|
|
109
|
+
- An Engine has no behavior (anemic).
|
|
110
|
+
- A new Manager was added without a Client-level entry point.
|
|
111
|
+
|
|
112
|
+
## Anti-patterns
|
|
113
|
+
|
|
114
|
+
- "Service layer" with mixed Manager + Engine responsibilities
|
|
115
|
+
- "Helper" / "Util" classes containing business logic
|
|
116
|
+
- Domain entity classes with both data and behavior bound to persistence
|
|
117
|
+
- "Facade" components that hide multiple Managers behind a single class
|
|
118
|
+
- ResourceAccess methods that return business-decided values instead of raw data
|
|
119
|
+
- Cross-Manager transactions implemented via direct calls
|
|
120
|
+
- Synchronous chains crossing 3+ layers
|
|
121
|
+
|
|
122
|
+
## Outputs
|
|
123
|
+
|
|
124
|
+
Does NOT produce own files. Modifies parent agent's structural decisions during code authoring and review.
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: vertical-slice
|
|
3
|
+
description: Vertical Slice Architecture (Jimmy Bogard). Organize by feature, not by technical layer. Each feature owns its full request-to-response path with minimal sharing. Language-agnostic rigid rules. Mutually exclusive with The Method, DDD, Clean Architecture, Hexagonal, Onion.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Skill: Vertical Slice Architecture
|
|
7
|
+
|
|
8
|
+
Rigid, inviolable rules from Jimmy Bogard's Vertical Slice Architecture. The system is organized by **feature**, not by technical layer. Each slice owns the full path from external request to external response.
|
|
9
|
+
|
|
10
|
+
Vertical Slice is the ONLY allowed design when PROJECT.md `Code Design: LOCKED: Vertical Slice`. Do not impose Clean Architecture's 4-layer structure, Onion shells, Hexagonal core/ports/adapters, DDD aggregates as primary structure, or The Method's universal hierarchy on top.
|
|
11
|
+
|
|
12
|
+
## Mandatory structure
|
|
13
|
+
|
|
14
|
+
1. **Each feature is one slice.** A feature is a single user-facing capability (e.g., `RegisterCustomer`, `CancelOrder`, `RenewSubscription`).
|
|
15
|
+
2. **A slice owns its full pipeline:** input contract, validator, handler, business logic, persistence access, output contract, and slice-specific tests.
|
|
16
|
+
3. **Slices live in feature folders / packages.** The primary code organization is `features/{feature-name}/` (or equivalent in the language). Technical-layer folders (`controllers/`, `services/`, `repositories/`, `models/`) as the primary structure are forbidden.
|
|
17
|
+
4. **Each feature folder is self-contained.** Inside a folder live only the artifacts that serve that feature.
|
|
18
|
+
5. **No shared "Service" layer, no shared "Repository" layer, no shared "Manager" layer across slices.** Each slice has its own.
|
|
19
|
+
|
|
20
|
+
## Slice isolation rules (inviolable)
|
|
21
|
+
|
|
22
|
+
1. **Slices do not call each other directly.** If slice A needs work done by slice B, slice A either duplicates the minimum needed code OR they both publish/subscribe to a shared event bus. Direct invocation of slice B's handler from slice A is forbidden.
|
|
23
|
+
2. **No shared mutable state across slices.** A slice never mutates state owned by another slice except through the shared persistence boundary, and never through another slice's handler.
|
|
24
|
+
3. **DRY applies inside a slice, not across slices.** Two slices that look similar today are still allowed to diverge tomorrow. Forced sharing is the enemy.
|
|
25
|
+
4. **Cross-slice abstractions are introduced only when 3+ slices need the exact same behavior with the exact same shape, and that behavior is stable.** Premature shared abstractions are violations.
|
|
26
|
+
|
|
27
|
+
## Slice composition (mandatory contents)
|
|
28
|
+
|
|
29
|
+
Each slice MUST contain:
|
|
30
|
+
|
|
31
|
+
1. **Request / Command / Query contract** — a structure describing the input.
|
|
32
|
+
2. **Handler** — receives the request, executes the logic, returns the response.
|
|
33
|
+
3. **Validator** (if input requires validation) — slice-local validation rules.
|
|
34
|
+
4. **Response contract** — the output shape returned to the caller.
|
|
35
|
+
5. **Slice-local types** — any DTOs, view models, or projections the slice needs.
|
|
36
|
+
6. **Slice-local tests** — integration tests that exercise the slice end-to-end.
|
|
37
|
+
|
|
38
|
+
A slice MAY contain:
|
|
39
|
+
|
|
40
|
+
- A slice-specific persistence access path (raw query, ORM query, projection, command-side persistence).
|
|
41
|
+
- A slice-specific external system call.
|
|
42
|
+
- Slice-local pre/post processing.
|
|
43
|
+
|
|
44
|
+
A slice MUST NOT contain:
|
|
45
|
+
|
|
46
|
+
- References to another slice's handler, request, or response types.
|
|
47
|
+
- References to a shared "Service" abstracting multiple slices.
|
|
48
|
+
- A "Manager" coordinating multiple slices.
|
|
49
|
+
|
|
50
|
+
## Cross-cutting concerns (inviolable)
|
|
51
|
+
|
|
52
|
+
1. Cross-cutting concerns (logging, authentication, authorization, transactions, validation pipeline, error handling) are applied as **pipeline behaviors / middleware** that wrap the handler, never as shared services injected into the handler.
|
|
53
|
+
2. Authentication and authorization decisions may use shared types (claims, principals) but are enforced at the pipeline level, not inside the handler.
|
|
54
|
+
3. Validation runs as a pipeline step before the handler executes. The handler assumes valid input.
|
|
55
|
+
4. Logging, tracing, metrics: pipeline behaviors. The handler does not invoke logging libraries for cross-cutting purposes.
|
|
56
|
+
|
|
57
|
+
## Persistence rules
|
|
58
|
+
|
|
59
|
+
1. **No generic repository spanning slices.** A slice that needs persistence either uses the ORM/database client directly within the slice OR has its own slice-local repository.
|
|
60
|
+
2. **Reads and writes may diverge structurally.** A slice that reads may use a different model than a slice that writes; this is encouraged.
|
|
61
|
+
3. **No "Domain Model" required to be shared across slices.** Each slice models the data it needs in the shape it needs.
|
|
62
|
+
4. **A shared schema (database) is acceptable; a shared in-code model abstraction is not.**
|
|
63
|
+
|
|
64
|
+
## Forbidden patterns (inviolable)
|
|
65
|
+
|
|
66
|
+
- **Technical-layer primary folders** (`controllers/`, `services/`, `repositories/`, `models/`) used as the system's primary organization.
|
|
67
|
+
- **A handler calling another handler.**
|
|
68
|
+
- **A "Service" class injected into multiple handlers** to provide their business logic.
|
|
69
|
+
- **A "Manager" class coordinating multiple slices.**
|
|
70
|
+
- **A shared "Repository" abstraction** consumed by 5+ slices.
|
|
71
|
+
- **Cross-slice imports of internal slice types.** Slice A importing `B.HandleQuery` or `B.RequestDto` is forbidden.
|
|
72
|
+
- **Slice A invoking slice B via an internal interface** instead of via the public boundary (HTTP, queue, event).
|
|
73
|
+
- **DRY refactoring that merges 2 slices into 1 because they share 80% of the code.** Slices stay separate until 3+ identical use cases exist with stable shape.
|
|
74
|
+
- **Forcing all slices through a shared base handler class** that contains business logic.
|
|
75
|
+
- **A shared "Domain Model" referenced by all slices** as the primary modeling element.
|
|
76
|
+
|
|
77
|
+
## Naming conventions
|
|
78
|
+
|
|
79
|
+
- Feature folders: feature name in domain language (`RegisterCustomer/`, `CancelOrder/`, `ViewCustomerDashboard/`).
|
|
80
|
+
- Request types: domain operation name (`RegisterCustomerCommand`, `CancelOrderCommand`, `ViewCustomerDashboardQuery`).
|
|
81
|
+
- Handler types: paired with request (`RegisterCustomerHandler`).
|
|
82
|
+
- Validator types: paired with request (`RegisterCustomerValidator`).
|
|
83
|
+
- Response types: domain output name (`RegisterCustomerResponse`).
|
|
84
|
+
- Internal slice types: prefixed by feature name when shared inside the slice (`RegisterCustomerEmailTemplate`).
|
|
85
|
+
|
|
86
|
+
## Reviewer enforcement (gate 5)
|
|
87
|
+
|
|
88
|
+
Reviewer rejects (BLOCKED) when:
|
|
89
|
+
- The codebase is primarily organized by technical layer instead of by feature.
|
|
90
|
+
- A handler invokes another slice's handler, request, or response type.
|
|
91
|
+
- A new "Service" / "Manager" / "Coordinator" class is introduced that spans multiple slices and carries business logic.
|
|
92
|
+
- A shared generic repository is introduced and consumed by multiple slices.
|
|
93
|
+
- Cross-cutting concerns are injected into handlers as shared services instead of applied as pipeline behaviors.
|
|
94
|
+
- Slice A imports types from slice B's internal folder.
|
|
95
|
+
|
|
96
|
+
Reviewer warns (APPROVED_WITH_WARNINGS) when:
|
|
97
|
+
- Two slices share an identical small helper that has been duplicated 3+ times (candidate for extraction, not required).
|
|
98
|
+
- A slice contains logic that appears to belong to a different slice.
|
|
99
|
+
- A slice handler is long enough to suggest splitting into pipeline behaviors.
|
|
100
|
+
- A slice references a "Domain Service" or "Aggregate" terminology that may indicate a different design creeping in.
|
|
101
|
+
|
|
102
|
+
## Anti-patterns
|
|
103
|
+
|
|
104
|
+
- "Vertical slices" implemented inside an MVC controllers/services/repositories folder structure (the folders betray the layer-primary structure)
|
|
105
|
+
- A "Domain" project that all slices reference, containing entities + services + repositories — that is layered or Onion in disguise
|
|
106
|
+
- Cross-slice "Coordinator" classes that orchestrate two handlers
|
|
107
|
+
- A shared "BaseHandler" that contains transaction management AND business logic
|
|
108
|
+
- A slice handler that delegates 90% of its work to a shared service (the slice is hollow)
|
|
109
|
+
- Premature "DRY" extraction that merges slices into a generic handler with strategy patterns
|
|
110
|
+
|
|
111
|
+
## Outputs
|
|
112
|
+
|
|
113
|
+
Does NOT produce own files. Modifies parent agent's structural decisions during code authoring and review.
|