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.
- package/README.md +6 -0
- package/core/agents/jdi-architect.md +19 -0
- package/core/agents/jdi-researcher.md +2 -1
- package/core/commands/jdi-add-phase.md +171 -0
- package/core/commands/jdi-remove-phase.md +228 -0
- 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/agents.md +4 -0
- 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-add-phase/SKILL.md +171 -0
- package/runtimes/antigravity/skills/jdi-architect/SKILL.md +19 -0
- package/runtimes/antigravity/skills/jdi-remove-phase/SKILL.md +228 -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/CLAUDE.md +4 -0
- package/runtimes/claude/agents/jdi-architect.md +19 -0
- package/runtimes/claude/agents/jdi-researcher.md +2 -1
- package/runtimes/claude/commands/jdi-add-phase.md +171 -0
- package/runtimes/claude/commands/jdi-remove-phase.md +228 -0
- 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/copilot/copilot-instructions.md +4 -0
- package/runtimes/copilot/prompts/jdi-add-phase.prompt.md +171 -0
- package/runtimes/copilot/prompts/jdi-remove-phase.prompt.md +228 -0
- package/runtimes/opencode/AGENTS.md +4 -0
- package/runtimes/opencode/agents/jdi-architect.md +19 -0
- package/runtimes/opencode/agents/jdi-researcher.md +2 -1
- package/runtimes/opencode/commands/jdi-add-phase.md +171 -0
- package/runtimes/opencode/commands/jdi-remove-phase.md +228 -0
- 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,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.
|
|
3
|
+
"version": "0.1.3",
|
|
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"
|
|
@@ -12,6 +12,10 @@ Este projeto usa **JDI (Just Do It)** como workflow de desenvolvimento. JDI eh u
|
|
|
12
12
|
/jdi-do <N> -> executa via doer specialist
|
|
13
13
|
/jdi-verify <N> -> gates via reviewer specialist
|
|
14
14
|
/jdi-ship <N> -> finaliza phase
|
|
15
|
+
|
|
16
|
+
# Roadmap mutation (qualquer hora)
|
|
17
|
+
/jdi-add-phase "<name>" [--goal "<t>"] [--at <pos>] -> adiciona phase
|
|
18
|
+
/jdi-remove-phase <N> [--force] -> remove future/pending phase
|
|
15
19
|
```
|
|
16
20
|
|
|
17
21
|
`/jdi-create [desc]` cria agents/skills no `core/` (so dentro do repo JDI).
|
|
@@ -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.
|
|
@@ -0,0 +1,118 @@
|
|
|
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
|
+
triggers:
|
|
5
|
+
- "Hexagonal"
|
|
6
|
+
- "Ports and Adapters"
|
|
7
|
+
- "Alistair Cockburn"
|
|
8
|
+
- "driving adapter"
|
|
9
|
+
- "driven adapter"
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# Skill: Hexagonal Architecture (Ports and Adapters)
|
|
13
|
+
|
|
14
|
+
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).
|
|
15
|
+
|
|
16
|
+
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.
|
|
17
|
+
|
|
18
|
+
## Mandatory structure
|
|
19
|
+
|
|
20
|
+
The system consists of exactly three structural elements:
|
|
21
|
+
|
|
22
|
+
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.
|
|
23
|
+
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.
|
|
24
|
+
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.
|
|
25
|
+
|
|
26
|
+
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.
|
|
27
|
+
|
|
28
|
+
## Driving vs Driven (mandatory)
|
|
29
|
+
|
|
30
|
+
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.
|
|
31
|
+
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.
|
|
32
|
+
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.
|
|
33
|
+
4. **Direction of dependency: adapters depend on ports; ports live in the core; the core depends on nothing infrastructural.**
|
|
34
|
+
|
|
35
|
+
## Inviolable rules
|
|
36
|
+
|
|
37
|
+
### Core purity
|
|
38
|
+
|
|
39
|
+
1. The core has zero imports from any framework, ORM, HTTP library, vendor SDK, file system API, or transport library.
|
|
40
|
+
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.
|
|
41
|
+
3. The core does not know the identity of any adapter. It interacts only with ports.
|
|
42
|
+
4. The core does not perform I/O. All I/O happens through driven ports.
|
|
43
|
+
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.
|
|
44
|
+
|
|
45
|
+
### Ports
|
|
46
|
+
|
|
47
|
+
6. A port is an interface. It has no logic.
|
|
48
|
+
7. Ports live in the core's package / module. They are not in an "infrastructure" or "adapters" package.
|
|
49
|
+
8. The core defines a port; the adapter implements it. A port defined outside the core, or implemented in the core, is forbidden.
|
|
50
|
+
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`).
|
|
51
|
+
10. Port methods receive and return only types defined inside the core. They do not receive HTTP requests, ORM entities, or framework-specific types.
|
|
52
|
+
|
|
53
|
+
### Adapters
|
|
54
|
+
|
|
55
|
+
11. An adapter implements exactly one port (driving or driven). An adapter that mixes driving and driven roles is forbidden.
|
|
56
|
+
12. A driving adapter translates an external trigger (HTTP request, CLI command, message, schedule) into a core-defined input and invokes a driving port.
|
|
57
|
+
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.
|
|
58
|
+
14. Adapters contain only translation and I/O. Business rules in an adapter are forbidden — they must move into the core.
|
|
59
|
+
15. Adapters never call other adapters directly. Coordination between adapters happens through the core via a driving adapter → core → driven adapter sequence.
|
|
60
|
+
16. Adapters never call the core's internal classes directly. They go through ports.
|
|
61
|
+
|
|
62
|
+
### Composition
|
|
63
|
+
|
|
64
|
+
17. The Composition Root assembles adapters and injects them into the core at startup. The core does not construct its own adapters.
|
|
65
|
+
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.
|
|
66
|
+
19. Multiple adapters may implement the same port. The core does not know how many.
|
|
67
|
+
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.
|
|
68
|
+
|
|
69
|
+
## Forbidden patterns (inviolable)
|
|
70
|
+
|
|
71
|
+
- **Framework types crossing into the core.** No HTTP request type, no ORM entity, no vendor SDK type referenced in core code.
|
|
72
|
+
- **Business rules in adapters.** A driven adapter computing a price, a driving adapter validating a domain rule — both forbidden.
|
|
73
|
+
- **Adapters calling adapters.** Adapter coordination outside the core is forbidden.
|
|
74
|
+
- **Core code instantiating an adapter.** Construction happens in the Composition Root.
|
|
75
|
+
- **Ports defined outside the core.** A port placed in an "infrastructure" module is a violation.
|
|
76
|
+
- **Anemic core.** A core without behavior is a violation — adapters become a leak path for rules.
|
|
77
|
+
- **A driving port returning a framework-specific type** (a port returning `HttpResponse` is wrong).
|
|
78
|
+
- **Driven ports leaking persistence concepts** (a port named `SqlUserRepository` is wrong; it must be domain-named).
|
|
79
|
+
- **Mixed-role adapter** (one adapter both responding to HTTP and writing to DB).
|
|
80
|
+
- **Bypassing ports** by injecting an adapter directly where a port should appear.
|
|
81
|
+
- **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.
|
|
82
|
+
|
|
83
|
+
## Naming conventions
|
|
84
|
+
|
|
85
|
+
- Driving ports: domain capability verbs (`PlaceOrder`, `RegisterCustomer`).
|
|
86
|
+
- Driven ports: dependency names in domain language (`OrderRepository`, `EmailSender`, `PaymentGateway`).
|
|
87
|
+
- Adapters: technology-qualified (`HttpPlaceOrderAdapter`, `PostgresOrderRepositoryAdapter`, `SmtpEmailSenderAdapter`).
|
|
88
|
+
- The core never references a name containing a technology word.
|
|
89
|
+
|
|
90
|
+
## Reviewer enforcement (gate 5)
|
|
91
|
+
|
|
92
|
+
Reviewer rejects (BLOCKED) when:
|
|
93
|
+
- Core code imports a framework / ORM / HTTP / vendor SDK / file-system type.
|
|
94
|
+
- A port is defined outside the core or implemented inside the core.
|
|
95
|
+
- A port method's signature mentions a framework-specific type.
|
|
96
|
+
- An adapter contains business logic.
|
|
97
|
+
- An adapter calls another adapter directly.
|
|
98
|
+
- The core instantiates an adapter.
|
|
99
|
+
- A driven port name leaks a persistence technology.
|
|
100
|
+
- A driving adapter returns the result of a port call without translating from a core type to an external type.
|
|
101
|
+
|
|
102
|
+
Reviewer warns (APPROVED_WITH_WARNINGS) when:
|
|
103
|
+
- An adapter file is doing more translation than necessary (smell: complex mapping suggesting hidden rules).
|
|
104
|
+
- A port is implemented by a single adapter and is unlikely ever to vary (still allowed — keep the port).
|
|
105
|
+
- A core class has no behavior (anemic).
|
|
106
|
+
- Composition wiring is scattered instead of centralized in a Composition Root.
|
|
107
|
+
|
|
108
|
+
## Anti-patterns
|
|
109
|
+
|
|
110
|
+
- "Service" layer between core and adapters (no such thing in Hexagonal)
|
|
111
|
+
- Repository implemented inside the core (must be a port)
|
|
112
|
+
- Use Case classes shaped after Clean Architecture's Use Case layer (the structure is core/ports/adapters)
|
|
113
|
+
- Ports tied to a transport (e.g., `RestOrderPort`) — ports are domain-shaped, adapters are transport-shaped
|
|
114
|
+
- "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)
|
|
115
|
+
|
|
116
|
+
## Outputs
|
|
117
|
+
|
|
118
|
+
Does NOT produce own files. Modifies parent agent's structural decisions during code authoring and review.
|