@lenardangeloolajay/len-toolkit 1.1.0

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 (114) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +209 -0
  3. package/bin/cli.js +244 -0
  4. package/package.json +35 -0
  5. package/src/installer.js +236 -0
  6. package/templates/configs/.editorconfig +12 -0
  7. package/templates/configs/sample.gitignore +8 -0
  8. package/templates/docs/FEATURE.md +40 -0
  9. package/templates/docs/HANDOFF.md +39 -0
  10. package/templates/docs/IMPLEMENTATION_PLAN.md +47 -0
  11. package/templates/docs/SPEC_INDEX.md +12 -0
  12. package/templates/docs/VERIFICATION.md +14 -0
  13. package/templates/docs/product/ARCHITECTURE.md +22 -0
  14. package/templates/docs/product/CONSTRAINTS.md +22 -0
  15. package/templates/docs/product/DATA_MODEL.md +22 -0
  16. package/templates/docs/product/OVERVIEW.md +22 -0
  17. package/templates/examples/flutter-handoff/EXERCISES.md +16 -0
  18. package/templates/examples/flutter-handoff/HANDOFF.md +32 -0
  19. package/templates/examples/flutter-handoff/docs/SPEC_INDEX.md +19 -0
  20. package/templates/examples/flutter-handoff/docs/evidence/FEAT-001-verification.md +14 -0
  21. package/templates/examples/flutter-handoff/docs/features/FEAT-001-local-note.md +40 -0
  22. package/templates/examples/flutter-handoff/docs/plans/FEAT-001-implementation.md +43 -0
  23. package/templates/examples/flutter-handoff/docs/product/ARCHITECTURE.md +24 -0
  24. package/templates/examples/flutter-handoff/docs/product/CONSTRAINTS.md +13 -0
  25. package/templates/examples/flutter-handoff/docs/product/DATA_MODEL.md +20 -0
  26. package/templates/examples/flutter-handoff/docs/product/OVERVIEW.md +26 -0
  27. package/templates/rules/.cursorrules +7 -0
  28. package/templates/rules/AGENTS.md +61 -0
  29. package/templates/rules/GEMINI.md +7 -0
  30. package/templates/skills/a-philosophy-of-software-design/SKILL.md +11 -0
  31. package/templates/skills/a-philosophy-of-software-design/a-philosophy-of-software-design.md +370 -0
  32. package/templates/skills/a-philosophy-of-software-design/a-philosophy-of-software-design.mini.md +46 -0
  33. package/templates/skills/a-philosophy-of-software-design/a-philosophy-of-software-design.nano.md +35 -0
  34. package/templates/skills/clean-architecture/SKILL.md +11 -0
  35. package/templates/skills/clean-architecture/clean-architecture.md +515 -0
  36. package/templates/skills/clean-architecture/clean-architecture.mini.md +49 -0
  37. package/templates/skills/clean-architecture/clean-architecture.nano.md +36 -0
  38. package/templates/skills/clean-code/SKILL.md +11 -0
  39. package/templates/skills/clean-code/clean-code.md +297 -0
  40. package/templates/skills/clean-code/clean-code.mini.md +47 -0
  41. package/templates/skills/clean-code/clean-code.nano.md +32 -0
  42. package/templates/skills/code-complete/SKILL.md +11 -0
  43. package/templates/skills/code-complete/code-complete.md +354 -0
  44. package/templates/skills/code-complete/code-complete.mini.md +56 -0
  45. package/templates/skills/code-complete/code-complete.nano.md +41 -0
  46. package/templates/skills/council/SKILL.md +37 -0
  47. package/templates/skills/designing-data-intensive-applications/SKILL.md +11 -0
  48. package/templates/skills/designing-data-intensive-applications/designing-data-intensive-applications.md +393 -0
  49. package/templates/skills/designing-data-intensive-applications/designing-data-intensive-applications.mini.md +55 -0
  50. package/templates/skills/designing-data-intensive-applications/designing-data-intensive-applications.nano.md +34 -0
  51. package/templates/skills/domain-driven-design/SKILL.md +11 -0
  52. package/templates/skills/domain-driven-design/domain-driven-design.md +979 -0
  53. package/templates/skills/domain-driven-design/domain-driven-design.mini.md +48 -0
  54. package/templates/skills/domain-driven-design/domain-driven-design.nano.md +39 -0
  55. package/templates/skills/domain-driven-design-distilled/SKILL.md +11 -0
  56. package/templates/skills/domain-driven-design-distilled/domain-driven-design-distilled.md +317 -0
  57. package/templates/skills/domain-driven-design-distilled/domain-driven-design-distilled.mini.md +56 -0
  58. package/templates/skills/domain-driven-design-distilled/domain-driven-design-distilled.nano.md +41 -0
  59. package/templates/skills/implementation-plan/SKILL.md +42 -0
  60. package/templates/skills/implementing-domain-driven-design/SKILL.md +11 -0
  61. package/templates/skills/implementing-domain-driven-design/implementing-domain-driven-design.md +337 -0
  62. package/templates/skills/implementing-domain-driven-design/implementing-domain-driven-design.mini.md +57 -0
  63. package/templates/skills/implementing-domain-driven-design/implementing-domain-driven-design.nano.md +37 -0
  64. package/templates/skills/patterns-of-enterprise-application-architecture/SKILL.md +11 -0
  65. package/templates/skills/patterns-of-enterprise-application-architecture/patterns-of-enterprise-application-architecture.md +404 -0
  66. package/templates/skills/patterns-of-enterprise-application-architecture/patterns-of-enterprise-application-architecture.mini.md +54 -0
  67. package/templates/skills/patterns-of-enterprise-application-architecture/patterns-of-enterprise-application-architecture.nano.md +35 -0
  68. package/templates/skills/ponytail/SKILL.md +124 -0
  69. package/templates/skills/ponytail-audit/SKILL.md +45 -0
  70. package/templates/skills/ponytail-debt/SKILL.md +48 -0
  71. package/templates/skills/ponytail-gain/SKILL.md +17 -0
  72. package/templates/skills/ponytail-help/SKILL.md +42 -0
  73. package/templates/skills/ponytail-review/SKILL.md +61 -0
  74. package/templates/skills/refactoring/SKILL.md +11 -0
  75. package/templates/skills/refactoring/refactoring.md +433 -0
  76. package/templates/skills/refactoring/refactoring.mini.md +49 -0
  77. package/templates/skills/refactoring/refactoring.nano.md +37 -0
  78. package/templates/skills/refactoring-guru/SKILL.md +11 -0
  79. package/templates/skills/refactoring-guru/refactoring-guru.md +765 -0
  80. package/templates/skills/refactoring-guru/refactoring-guru.mini.md +64 -0
  81. package/templates/skills/refactoring-guru/refactoring-guru.nano.md +41 -0
  82. package/templates/skills/release-it/SKILL.md +11 -0
  83. package/templates/skills/release-it/release-it.md +382 -0
  84. package/templates/skills/release-it/release-it.mini.md +48 -0
  85. package/templates/skills/release-it/release-it.nano.md +38 -0
  86. package/templates/skills/security-audit/AI-AND-LLM.md +83 -0
  87. package/templates/skills/security-audit/ATTACK-CLASSES.md +130 -0
  88. package/templates/skills/security-audit/CLIENT-SIDE.md +83 -0
  89. package/templates/skills/security-audit/CLOUD-AND-DEPLOYMENT.md +86 -0
  90. package/templates/skills/security-audit/DATA-ISOLATION-AND-LIFECYCLE.md +84 -0
  91. package/templates/skills/security-audit/DESKTOP-MOBILE-AND-LOCAL-IPC.md +89 -0
  92. package/templates/skills/security-audit/HUNTING.md +251 -0
  93. package/templates/skills/security-audit/MEMORY-SAFETY-AND-BINARY.md +101 -0
  94. package/templates/skills/security-audit/PROTOCOLS-RPC-AND-MESSAGING.md +81 -0
  95. package/templates/skills/security-audit/RECONNAISSANCE.md +156 -0
  96. package/templates/skills/security-audit/RESOURCE-EXHAUSTION-AND-AVAILABILITY.md +78 -0
  97. package/templates/skills/security-audit/SKILL.md +192 -0
  98. package/templates/skills/security-audit/SUPPLY-CHAIN-AND-RELEASE.md +73 -0
  99. package/templates/skills/security-audit/VALIDATION-AND-REPORTING.md +186 -0
  100. package/templates/skills/security-audit/WEB-PROTOCOL-AND-AUTH.md +105 -0
  101. package/templates/skills/security-audit/report-schema.json +461 -0
  102. package/templates/skills/security-audit/validate-coverage-ledger.cjs +872 -0
  103. package/templates/skills/security-audit/validate-coverage-ledger.test.cjs +740 -0
  104. package/templates/skills/security-audit/validate-findings.cjs +773 -0
  105. package/templates/skills/security-audit/validate-findings.test.cjs +652 -0
  106. package/templates/skills/spec/SKILL.md +55 -0
  107. package/templates/skills/the-pragmatic-programmer/SKILL.md +11 -0
  108. package/templates/skills/the-pragmatic-programmer/the-pragmatic-programmer.md +359 -0
  109. package/templates/skills/the-pragmatic-programmer/the-pragmatic-programmer.mini.md +65 -0
  110. package/templates/skills/the-pragmatic-programmer/the-pragmatic-programmer.nano.md +44 -0
  111. package/templates/skills/working-effectively-with-legacy-code/SKILL.md +11 -0
  112. package/templates/skills/working-effectively-with-legacy-code/working-effectively-with-legacy-code.md +371 -0
  113. package/templates/skills/working-effectively-with-legacy-code/working-effectively-with-legacy-code.mini.md +50 -0
  114. package/templates/skills/working-effectively-with-legacy-code/working-effectively-with-legacy-code.nano.md +35 -0
@@ -0,0 +1,35 @@
1
+ # OBEY A Philosophy of Software Design by John Ousterhout
2
+
3
+ ## When to use
4
+
5
+ Use when the main risk is accidental complexity, shallow abstractions, leaky interfaces, or tactical patches.
6
+
7
+ ## Primary bias to correct
8
+
9
+ Working code, small pieces, and familiar wrappers are not automatically simple.
10
+
11
+ ## Decision rules
12
+
13
+ - Optimize for lower cognitive load and local understandability, not shorter files, familiar patterns, fewer lines, or clever compactness.
14
+ - Prefer deep modules; reject wrappers, layers, helpers, facades, and split-outs that do not hide real complexity.
15
+ - Hide volatile decisions, representations, storage, protocol facts, workflow bookkeeping, and messy edge handling in one owning module.
16
+ - Make interfaces caller-centered and semantic; avoid staged APIs, flags, setup sequences, and mechanism leakage when the module can provide the right operation.
17
+ - If a change feels awkward or spreads widely, improve ownership and abstraction instead of adding tactical special cases.
18
+ - Combine or split by total complexity: keep shared knowledge together and split only at independently understandable boundaries.
19
+ - Treat names and comments as design signals: precise abstraction names, explicit contracts, and no comments that compensate for bad decomposition.
20
+ - Add complexity for performance, trends, patterns, frameworks, tests, or exception handling only when evidence or caller needs justify it.
21
+
22
+ ## Trigger rules
23
+
24
+ - When adding a helper, layer, option, callback, pattern, or abstraction, prove it removes complexity for callers.
25
+ - When an API requires sequencing, representation, storage, transport, caching, protocol, or file-format knowledge, redesign the boundary.
26
+ - When naming is hard, comments get long, or reviewers are surprised, treat it as design evidence.
27
+ - When one change spreads widely, look for duplicated knowledge, hidden dependencies, temporal coupling, or the wrong owner.
28
+ - When optimizing or adding exception paths, keep the common path simple and require evidence or a stronger invariant.
29
+
30
+ ## Final checklist
31
+
32
+ - Fewer concepts to hold?
33
+ - More complexity hidden below the right boundary?
34
+ - Fewer special cases, knobs, leaks, and call-order traps?
35
+ - Better names, contracts, ownership, and evidence for any added complexity?
@@ -0,0 +1,11 @@
1
+ ---
2
+ name: clean-architecture
3
+ description: Apply Robert C. Martin-inspired architecture rules when separating business policy from frameworks, databases, UI, or infrastructure details.
4
+ license: MIT
5
+ ---
6
+
7
+ # Clean Architecture Skill
8
+
9
+ Use this skill when a task involves architectural boundaries, dependency direction, use cases, entities, interface adapters, framework isolation, or technology churn.
10
+
11
+ Before making design or code decisions, read and apply [clean-architecture.mini.md](clean-architecture.mini.md). Use [clean-architecture.md](clean-architecture.md) only as a deeper reference when the mini rules are not enough for the current architectural tradeoff.
@@ -0,0 +1,515 @@
1
+ # OBEY Clean Architecture by Robert C. Martin
2
+
3
+ ## Purpose
4
+
5
+ This repository must follow **Clean Architecture**.
6
+ When writing, modifying, or reviewing code, prefer decisions that preserve:
7
+ - independent business rules
8
+ - inward-pointing dependencies
9
+ - framework independence
10
+ - database independence
11
+ - UI independence
12
+ - testability
13
+ - replaceable details
14
+
15
+ Treat this file as a binding implementation policy: `MUST` is binding, `SHOULD` is a strong default, and `MUST NOT` is forbidden.
16
+
17
+ ---
18
+
19
+ ## Non-Negotiable Rules
20
+
21
+ 1. **Follow the Dependency Rule**
22
+ - Source code dependencies must point inward, toward higher-level policies.
23
+ - Inner layers must not import or depend on outer layers.
24
+ - Business rules must not depend on frameworks, web handlers, database drivers, UI libraries, queues, external services, or other details.
25
+
26
+ 2. **Keep Business Rules Pure**
27
+ - Entities and use cases must contain business policy.
28
+ - Business rules must not read web requests, environment variables, framework context, database-bound structures, or database rows directly.
29
+ - Pass plain data into use cases through request models or arguments.
30
+
31
+ 3. **Treat Frameworks as Details**
32
+ - Frameworks are tools, not the foundation of the design.
33
+ - Keep framework annotations, decorators, controllers, routes, middleware, serializers, and database artifacts at the edges.
34
+ - Do not let framework types leak into core policies.
35
+
36
+ 4. **Treat the Database as a Detail**
37
+ - Do not shape the domain model around tables.
38
+ - Use gateways to isolate persistence.
39
+ - Business rules must work without a real database.
40
+
41
+ 5. **Treat the Web as a Detail**
42
+ - Controllers and endpoints translate delivery input into input models for use cases.
43
+ - Use cases must not know about web transport, status codes, cookies, headers, or routing.
44
+ - Presenters or response mappers translate use case output for delivery mechanisms.
45
+
46
+ 6. **Use Explicit Boundaries**
47
+ - Define interfaces at architectural seams.
48
+ - External systems, persistence, messaging, file systems, clocks, and service clients must sit behind boundaries.
49
+ - Prefer adapters over direct calls from policy code to implementation details.
50
+
51
+ 7. **Organize by Use Case**
52
+ - Prefer feature and use-case oriented structure over generic technical buckets.
53
+ - The architecture should scream the domain and application intent.
54
+ - Avoid codebases dominated by generic technical buckets that do not reveal use cases or business purpose.
55
+
56
+ 8. **Use Cases Must Orchestrate**
57
+ - A use case coordinates entities and gateways.
58
+ - A use case should not contain delivery concerns, database concerns, or presentation formatting concerns.
59
+ - A use case should represent one application action.
60
+
61
+ 9. **Entities Must Guard Invariants**
62
+ - Critical domain rules belong in entities or equivalent domain objects.
63
+ - Entities must protect invariants and consistency.
64
+ - Do not leave core rules in controllers, jobs, handlers, or database scripts.
65
+
66
+ 10. **Outer Layers May Depend on Inner Layers, Never the Reverse**
67
+ - Controllers may depend on use cases.
68
+ - Gateways may implement interfaces defined by the use case or domain layer.
69
+ - Presenters may implement output boundaries owned by inner layers.
70
+ - Never invert this relationship accidentally.
71
+
72
+ ---
73
+
74
+ ## Required Layer Responsibilities
75
+
76
+ ### Domain Layer
77
+ Contains:
78
+ - entities
79
+ - enterprise business rules
80
+ - domain invariants
81
+ - core business rules
82
+
83
+ These may be implemented with plain objects, functions, modules, or other structures. Clean Architecture requires independent business rules; it does not require a specific domain modeling style.
84
+
85
+ Must:
86
+ - be framework free
87
+ - be persistence ignorant
88
+ - be delivery mechanism agnostic
89
+ - avoid annotations and infrastructure imports where possible
90
+
91
+ Must not:
92
+ - import web libraries
93
+ - import database access types
94
+ - import external service clients
95
+ - perform I/O
96
+ - read configuration directly
97
+
98
+ ### Application Layer
99
+ Contains:
100
+ - use cases
101
+ - input models
102
+ - output models
103
+ - ports and boundaries
104
+ - orchestration logic
105
+
106
+ Must:
107
+ - depend on domain abstractions and models
108
+ - define interfaces for required external behavior
109
+ - coordinate workflows explicitly
110
+
111
+ Must not:
112
+ - contain controller logic
113
+ - contain database access details
114
+ - return framework response types
115
+ - format UI strings unless explicitly part of a presenter boundary
116
+
117
+ ### Interface Adapters Layer
118
+ Contains:
119
+ - controllers
120
+ - presenters
121
+ - view models
122
+ - gateway adapters
123
+ - mappers between external and internal models
124
+
125
+ Must:
126
+ - translate between external formats and internal models
127
+ - depend inward on application and domain code
128
+ - isolate framework and vendor details
129
+
130
+ Must not:
131
+ - move business policy out of the use case or domain layer
132
+ - bypass use cases to call gateways directly unless explicitly justified by architecture
133
+
134
+ ### Infrastructure Layer
135
+ Contains:
136
+ - framework bootstrap
137
+ - object graph and component wiring
138
+ - database access details
139
+ - external service integrations
140
+ - message bus clients
141
+ - filesystem implementations
142
+ - network clients
143
+
144
+ Must:
145
+ - remain replaceable
146
+ - implement interfaces owned by inner layers
147
+ - stay at the outermost edge
148
+
149
+ Must not:
150
+ - define business rules
151
+ - dictate domain shapes
152
+ - leak vendor types inward
153
+
154
+ ---
155
+
156
+ ## Code Generation Rules
157
+
158
+ When generating code, always apply the following.
159
+
160
+ ### 1. Define the Use Case First
161
+ For every non-trivial feature:
162
+ - identify the use case
163
+ - define the input
164
+ - define the output
165
+ - define required ports
166
+ - keep orchestration in one place
167
+
168
+ Prefer this order:
169
+ 1. domain rule or entity behavior
170
+ 2. use case
171
+ 3. boundary interfaces
172
+ 4. presenter contract
173
+ 5. gateway contract
174
+ 6. adapters
175
+ 7. framework wiring
176
+
177
+ ### 2. Use Plain Models at Boundaries
178
+ - Use request and response models owned by the application layer.
179
+ - Do not pass database-bound entities, web requests, or framework-bound data structures into core logic.
180
+ - Do not return framework objects from use cases.
181
+
182
+ ### 3. Create Ports for Volatile Dependencies
183
+ Introduce interfaces for:
184
+ - gateways
185
+ - mailers
186
+ - payment providers
187
+ - message publishers
188
+ - storage providers
189
+ - clocks
190
+ - ID generators
191
+ - transaction runners if needed
192
+
193
+ Do not call volatile details directly from core use cases.
194
+
195
+ ### 4. Keep Wiring in the Main Component
196
+ - Object construction belongs in the composition root.
197
+ - Do not instantiate infrastructure dependencies inside use cases or entities.
198
+ - Use explicit construction, factories, or composition in the outer layer.
199
+
200
+ ### 5. Prefer Stable Dependencies
201
+ - Inner layers own the abstractions they need.
202
+ - Outer layers implement those abstractions.
203
+ - Avoid shared "common" packages that create sideways coupling.
204
+
205
+ ### 6. Keep Boundaries Visible
206
+ - When in doubt, introduce a boundary sooner.
207
+ - Partial boundaries are acceptable if they preserve future extraction options.
208
+ - Use interfaces, request models, and output models to avoid coupling to details.
209
+
210
+ ---
211
+
212
+ ## Architecture Heuristics
213
+
214
+ ### Dependency Direction
215
+ Always verify:
216
+ - Does this import point inward?
217
+ - Is a high-level policy depending on a low-level detail?
218
+ - Is a framework or vendor type leaking into a core layer?
219
+ - Is an adapter bypassing the intended boundary?
220
+
221
+ If yes, refactor.
222
+
223
+ ### Policy vs Detail
224
+ When placing code, ask:
225
+ - Is this business policy?
226
+ - Is this orchestration?
227
+ - Is this translation?
228
+ - Is this infrastructure?
229
+
230
+ Put the code in the highest-level place that matches its responsibility.
231
+
232
+ ### Stable Core, Replaceable Edge
233
+ Prefer designs where you can replace:
234
+ - web framework
235
+ - persistence technology
236
+ - message broker
237
+ - job runner
238
+ - cloud vendor
239
+ - serializer
240
+ - UI
241
+ without rewriting business rules.
242
+
243
+ ### Feature First Structure
244
+ Prefer:
245
+ - feature/use-case names
246
+ - business-capability/use-case names
247
+ - names that reveal the application's use cases
248
+
249
+ Over:
250
+ - generic controller, service, or gateway buckets
251
+ - generic technical buckets
252
+
253
+ Technical subfolders are acceptable only when they do not obscure use-case ownership.
254
+
255
+ ---
256
+
257
+ ## Architecture Economics and Priority
258
+
259
+ 1. Treat architecture as a way to keep future change cost proportional to the scope of change.
260
+ 2. Do not sacrifice important architectural work merely because urgent feature work is louder.
261
+ 3. Preserve options around frameworks, databases, delivery mechanisms, and deployment topology until evidence justifies commitment.
262
+ 4. Choose boundaries by volatility, policy importance, substitution value, testability, and cost.
263
+ 5. Do not overbuild boundaries whose cost exceeds the option value they preserve.
264
+ 6. Revisit architecture when change shape, team ownership, deployment needs, or operational constraints reveal rising cost.
265
+
266
+ ---
267
+
268
+ ## Paradigm and Component Rules
269
+
270
+ 1. Use structured programming to make behavior decomposable and testable.
271
+ 2. Use polymorphism to invert dependencies when high-level policy must not know low-level details.
272
+ 3. Use immutability or controlled mutation when it protects policy from accidental state coupling.
273
+ 4. Apply SRP by separating code that changes for different actors or reasons.
274
+ 5. Apply the Open-Closed Principle by protecting stable policy from volatile extension details.
275
+ 6. Apply LSP by ensuring substitutable implementations preserve caller expectations.
276
+ 7. Apply ISP by keeping interfaces focused on what each client actually needs.
277
+ 8. Apply DIP by making source dependencies point toward stable policy and abstractions.
278
+ 9. Group components by cohesion and release pressure; do not group unrelated policy just because it shares a technical layer.
279
+ 10. Avoid component cycles; break cycles before they harden into deployment or test bottlenecks.
280
+ 11. Balance stability and abstraction: stable components should not depend on unstable details, and abstract components should have concrete reason to exist.
281
+
282
+ ---
283
+
284
+ ## Boundary Cost, Deployment, and Operations
285
+
286
+ 1. A boundary may be a source boundary, deployment boundary, process boundary, service boundary, or partial boundary.
287
+ 2. Choose the lightest boundary that preserves the needed independence.
288
+ 3. Use partial boundaries when a full deployment/runtime split is too expensive but future separation is valuable.
289
+ 4. Keep development, deployment, operation, and maintenance concerns visible without letting them own business policy.
290
+ 5. Do not combine unrelated use cases just because operational wiring is easier.
291
+ 6. Do not eliminate duplication when the shared code would couple use cases that change for different actors.
292
+ 7. Make architectural boundaries enforceable through package structure, tests, dependency rules, or build constraints.
293
+
294
+ ---
295
+
296
+ ## Services, Distribution, and Embedded Boundaries
297
+
298
+ 1. A service is not automatically an architectural boundary; source dependencies and data ownership still decide coupling.
299
+ 2. Remote calls must be treated as I/O boundaries, not as local method calls.
300
+ 3. Keep service listeners humble: translate external messages into use case calls and return through output boundaries.
301
+ 4. Keep embedded and hardware details behind interfaces so policy can be tested without the target device.
302
+ 5. Do not let real-time, firmware, database, web, or framework concerns pull policy outward.
303
+
304
+ ---
305
+
306
+ ## Naming Rules
307
+
308
+ - Name modules and packages after business capabilities or use cases.
309
+ - Name use cases with action verbs from the application's use cases.
310
+ - Name ports by the role they play for the use case.
311
+ - Name adapters by the external detail or delivery mechanism they adapt.
312
+ - Avoid vague technical names when a use case, policy, boundary, presenter, controller, gateway, or entity role is more precise.
313
+ - If a class is named `Service`, justify why it is not a use case, adapter, or domain object.
314
+
315
+ ---
316
+
317
+ ## Testing Rules
318
+
319
+ ### Core Tests First
320
+ Prioritize tests for:
321
+ - entities
322
+ - use cases
323
+ - boundary contracts
324
+
325
+ These tests must:
326
+ - run without the real framework
327
+ - run without the real database
328
+ - run without the network
329
+ - run fast and deterministically
330
+
331
+ ### Adapter Tests
332
+ Test adapters separately for:
333
+ - mapping correctness
334
+ - gateway behavior
335
+ - controller translation
336
+ - presenter formatting
337
+ - integration with framework or external service
338
+
339
+ Do not use slow integration tests as a substitute for testing business rules.
340
+
341
+ ### Test Through Supported Boundaries
342
+ - Avoid reaching private internals when a public use case boundary exists.
343
+ - Prefer testing use cases with fakes or mocks for ports.
344
+ - Use integration tests only where architectural seams meet real details.
345
+
346
+ ---
347
+
348
+ ## Forbidden Patterns
349
+
350
+ Do not generate or keep code that does any of the following unless explicitly required and justified.
351
+
352
+ ### Framework Leakage
353
+ - domain entities annotated with database or web framework metadata when avoidable
354
+ - use cases depending on `Request`, `Response`, controller base classes, framework sessions, or middleware objects
355
+ - application layer importing serializer or database base classes
356
+
357
+ ### Database Leakage
358
+ - use cases returning table rows or database-bound entities
359
+ - domain rules embedded in gateway implementations or database access
360
+ - domain objects designed primarily around persistence convenience
361
+
362
+ ### Controller-Centric Logic
363
+ - controllers containing branching business rules
364
+ - controllers performing validation that belongs to business policy
365
+ - controllers calling gateways directly instead of use cases
366
+
367
+ ### God Services
368
+ - large `*Service` classes that create, fetch, validate, persist, publish, and present everything
369
+ - services that own unrelated use cases
370
+ - application services that become dumping grounds
371
+
372
+ ### Layer Bypass
373
+ - controllers bypassing use cases to call gateways
374
+ - presenters reading directly from databases
375
+ - infrastructure code importing inward and also being imported by domain code
376
+
377
+ ### Direction Violations
378
+ - gateway interfaces defined in infrastructure and consumed by core policy
379
+ - entities importing adapters
380
+ - use cases depending on concrete implementations
381
+
382
+ ### Utility Dumping Grounds
383
+ - generic utility, shared, base, or core folders used as architecture escape hatches
384
+ - generic abstractions with no clear ownership
385
+ - convenience modules that hide bad dependency direction
386
+
387
+ ---
388
+
389
+ ## Refactoring Rules
390
+
391
+ When modifying existing code:
392
+
393
+ 1. **Move business rules inward**
394
+ - Extract domain logic from controllers, handlers, views, gateway classes, and jobs.
395
+
396
+ 2. **Introduce boundaries around details**
397
+ - Wrap external services, database access, message buses, filesystem operations, and clocks.
398
+
399
+ 3. **Replace concrete dependencies with ports**
400
+ - Define interfaces in inner layers.
401
+ - Implement them in outer layers.
402
+
403
+ 4. **Separate translation from policy**
404
+ - Request parsing, data mapping, serialization, and presentation formatting belong outside core business rules.
405
+
406
+ 5. **Break up god services**
407
+ - Split by use case.
408
+ - Give each use case one clear application action.
409
+
410
+ 6. **Eliminate framework coupling from tests**
411
+ - Rewrite tests to target use cases and entities directly where possible.
412
+
413
+ 7. **Preserve behavior while improving direction**
414
+ - Refactor incrementally.
415
+ - Prefer safe boundary extraction over large rewrites.
416
+
417
+ ---
418
+
419
+ ## Output Expectations
420
+
421
+ When asked to implement a feature, default to producing:
422
+ - a domain model or entity if business invariants exist
423
+ - a focused use case
424
+ - input and output models if needed
425
+ - ports/interfaces for external dependencies
426
+ - adapters for web, persistence, or messaging details
427
+ - composition root wiring outside the use case
428
+
429
+ When asked to modify existing code:
430
+ - keep or improve dependency direction
431
+ - avoid adding framework dependencies to inner layers
432
+ - call out architectural debt explicitly if it cannot be fixed safely now
433
+
434
+ When asked to review code:
435
+ - identify boundary violations
436
+ - identify dependency rule violations
437
+ - identify framework leakage
438
+ - identify misplaced business rules
439
+ - identify god services and layer bypass
440
+ - propose concrete refactorings toward Clean Architecture
441
+
442
+ ---
443
+
444
+ ## Review Checklist
445
+
446
+ Before finalizing any change, verify:
447
+
448
+ - Are business rules independent from frameworks?
449
+ - Are use cases independent from delivery and persistence details?
450
+ - Do source dependencies point inward?
451
+ - Are controllers thin?
452
+ - Are gateways just persistence adapters?
453
+ - Are entities guarding domain invariants?
454
+ - Are ports owned by inner layers?
455
+ - Is composition happening at the edge?
456
+ - Can core tests run without the web framework and database?
457
+ - Does the project structure reflect the domain and use cases?
458
+ - Did we avoid generic utility dumping grounds?
459
+ - Did we avoid creating another god service?
460
+ - Did we keep details replaceable?
461
+
462
+ If any answer is no, revise the design before shipping.
463
+
464
+ ---
465
+
466
+ ## Preferred Default Shapes
467
+
468
+ ### Preferred feature shape
469
+ - domain
470
+ - application
471
+ - adapters
472
+ - infrastructure
473
+
474
+ Or, if feature-oriented:
475
+ - feature/domain
476
+ - feature/application
477
+ - feature/adapters
478
+ - feature/infrastructure
479
+
480
+ ### Preferred use case shape
481
+ - request model
482
+ - use case
483
+ - output boundary or response model
484
+ - ports
485
+ - adapter implementations outside
486
+
487
+ ### Preferred dependency pattern
488
+ - inner layer defines interface
489
+ - outer layer implements interface
490
+ - composition root wires them together
491
+
492
+ ---
493
+
494
+ ## When Tradeoffs Are Necessary
495
+
496
+ If constraints force a compromise:
497
+ - keep the compromise at the outermost layer possible
498
+ - document the boundary violation clearly in code comments or review notes
499
+ - avoid normalizing the compromise into the core architecture
500
+ - preserve a future path to separation
501
+
502
+ Choose the design that minimizes long-term coupling, not the one that is only shortest today.
503
+
504
+ ---
505
+
506
+ ## Final Instruction
507
+
508
+ When uncertain, choose the option that:
509
+ 1. keeps business rules independent
510
+ 2. points dependencies inward
511
+ 3. isolates details behind boundaries
512
+ 4. improves testability
513
+ 5. makes replacement of frameworks, databases, and delivery mechanisms easier
514
+
515
+ If a proposed change conflicts with these priorities, reject it and propose a cleaner architectural alternative.
@@ -0,0 +1,49 @@
1
+ # OBEY Clean Architecture by Robert C. Martin
2
+
3
+ ## When to use
4
+
5
+ Use when adding, changing, reviewing, or refactoring code whose business rules should survive changes in frameworks, databases, delivery mechanisms, services, devices, vendors, deployment shape, or schedule pressure.
6
+
7
+ ## Primary bias to correct
8
+
9
+ Do not let details become the architecture. Business policy stays independent, dependencies point inward, and volatile mechanisms remain replaceable.
10
+
11
+ ## Decision rules
12
+
13
+ - Preserve independent business rules, inward dependencies, testability, and replaceable details even when the immediate feature would be shorter without them.
14
+ - Source dependencies must point inward toward higher-level policy. Domain and use cases must not import frameworks, databases, web handlers, queues, external service clients, UI types, or other details.
15
+ - Put enterprise rules and invariants in entities or equivalent domain objects; put application-specific orchestration in focused use cases.
16
+ - Pass plain request and response models across use-case boundaries. Do not pass web requests, framework contexts, ORM rows, database-bound structures, or framework response objects into or out of core policy.
17
+ - Treat frameworks, databases, web delivery, messaging, filesystems, clocks, service clients, networks, devices, and vendors as outer-layer details behind ports, gateways, presenters, mappers, or adapters.
18
+ - Inner layers own the interfaces they need; outer layers implement them. Object construction and concrete wiring belong in the composition root or other outer-layer main component.
19
+ - Keep adapters humble. Controllers, endpoints, presenters, gateway adapters, service listeners, and hardware adapters translate external formats to use-case calls and back; they do not own business decisions.
20
+ - Organize by use case, feature, or business capability before generic technical buckets. The structure should reveal domain intent and application actions.
21
+ - Choose boundaries by volatility, policy importance, substitution value, testability, and cost. Use the lightest enforceable boundary, including partial boundaries, when full deployment or runtime separation is too expensive.
22
+ - Do not merge unrelated use cases or eliminate duplication when sharing would couple actors, change reasons, team ownership, deployment needs, or release pressure.
23
+ - Use structured code, dependency inversion, role-sized interfaces, substitutable implementations, controlled mutation, acyclic components, and stability-directed dependencies to protect policy from volatile details.
24
+ - Enforce boundaries with package structure, dependency rules, build constraints, tests, visibility, or narrow APIs. A diagram, service split, package name, or shared `common` folder is not enough.
25
+ - Test entities, use cases, and boundary contracts first, without the real framework, database, network, external service, or target hardware. Test adapters separately at the seams.
26
+ - Preserve behavior while improving dependency direction. Prefer incremental boundary extraction over rewrites, and call out architectural debt when it cannot be fixed safely now.
27
+
28
+ ## Trigger rules
29
+
30
+ - When urgent delivery would skip architecture, state the future change, test, replacement, or operational cost before accepting the shortcut.
31
+ - When framework annotations, request/response objects, serializers, ORM rows, schemas, vendor SDKs, config, environment reads, device registers, or transport formats enter core policy, move translation outward.
32
+ - When controllers, jobs, handlers, views, presenters, gateways, repositories, SQL, service listeners, scripts, or hardware adapters contain business branching or validation, move the rule inward.
33
+ - When a use case instantiates infrastructure, calls a volatile dependency directly, or depends on a concrete implementation, introduce a policy-owned port and wire the concrete detail at the edge.
34
+ - When a `*Service`, utility folder, shared module, base package, or generic `core` package becomes an escape hatch, split by use case, role, or ownership and restore dependency direction.
35
+ - When an adapter bypasses a use case, a presenter reads persistence directly, or infrastructure is both imported by and importing inward code, restore the intended boundary.
36
+ - When service boundaries, process boundaries, remote calls, deployment boundaries, or embedded hardware appear, still verify source dependencies, data ownership, I/O cost, and policy independence.
37
+ - When tests need the framework, database, network, service, or hardware to verify business rules, move tests to use cases/entities with fakes or add a stable boundary contract.
38
+ - When a compromise is unavoidable, keep it at the outermost layer possible, document the violation, avoid normalizing it, and preserve a path to separation.
39
+
40
+ ## Final checklist
41
+
42
+ - Business rules independent from frameworks, databases, UI, services, devices, and vendors?
43
+ - Dependencies point inward, with ports owned by inner policy and concrete details outside?
44
+ - Entities guard invariants and focused use cases orchestrate one application action?
45
+ - Boundaries explicit and enforced in code, tests, packages, or build rules?
46
+ - Controllers, presenters, gateways, service listeners, and adapters humble?
47
+ - Structure reveals use cases and business capabilities instead of generic technical buckets?
48
+ - Core tests run fast without real delivery, persistence, network, external service, or hardware?
49
+ - Details remain replaceable without rewriting business rules?
@@ -0,0 +1,36 @@
1
+ # OBEY Clean Architecture by Robert C. Martin
2
+
3
+ ## When to use
4
+
5
+ Use when tight context still needs to prevent framework-first design, database-shaped policy, layer bypass, or fake boundaries.
6
+
7
+ ## Primary bias to correct
8
+
9
+ Details are plugins to policy, not the center of the design.
10
+
11
+ ## Decision rules
12
+
13
+ - Source dependencies point inward. Domain and use cases must not import frameworks, databases, web, UI, queues, service clients, device, vendor, or infrastructure details.
14
+ - Entities guard enterprise invariants; focused use cases orchestrate application actions with plain input and output models.
15
+ - Frameworks, databases, web delivery, messaging, filesystems, clocks, networks, services, and hardware sit behind policy-owned ports and outer-layer adapters.
16
+ - Controllers, presenters, gateways, service listeners, mappers, and hardware adapters translate; they do not own business rules.
17
+ - Organize by use case, feature, or business capability. Avoid generic technical buckets, god services, shared utility escape hatches, and sideways coupling.
18
+ - Choose the lightest enforceable boundary that preserves likely change independence; a service, package, diagram, or folder name is not enough.
19
+ - Test policy through entities, use cases, and boundary contracts without real frameworks, databases, networks, services, or hardware.
20
+
21
+ ## Trigger rules
22
+
23
+ - When framework, ORM, request, response, schema, transport, config, vendor, or hardware types enter core policy, move translation outward.
24
+ - When controllers, jobs, handlers, gateways, repositories, SQL, presenters, service listeners, or `*Service` classes grow business rules, move policy inward and split by use case.
25
+ - When core code constructs or calls volatile details directly, define an inward-owned port and wire the concrete implementation at the edge.
26
+ - When a shortcut bypasses a use case, crosses layers, creates a cycle, or hides coupling in `common` or `utils`, restore dependency direction and ownership.
27
+ - When constraints force a compromise, keep it outermost, name the violation, and preserve a future path to separation.
28
+
29
+ ## Final checklist
30
+
31
+ - Policy independent of details?
32
+ - Dependencies inward?
33
+ - Use cases visible?
34
+ - Adapters humble?
35
+ - Boundaries enforced?
36
+ - Core tests detail-free?
@@ -0,0 +1,11 @@
1
+ ---
2
+ name: clean-code
3
+ description: Apply Robert C. Martin-inspired clean code rules when improving readability, naming, function design, responsibilities, or testable everyday code.
4
+ license: MIT
5
+ ---
6
+
7
+ # Clean Code Skill
8
+
9
+ Use this skill when a task involves everyday implementation quality, naming, small functions, readable control flow, responsibilities, comments, errors, or tests.
10
+
11
+ Before making design or code decisions, read and apply [clean-code.mini.md](clean-code.mini.md). Use [clean-code.md](clean-code.md) only as a deeper reference when the mini rules are not enough for the current code-quality tradeoff.