@adbayb/stack 3.6.0 → 3.7.0-next.1794137250723.d0dade1

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/dist/index.js CHANGED
@@ -931,7 +931,7 @@ const createWatchCommand = (program) => {
931
931
 
932
932
  //#endregion
933
933
  //#region package.json
934
- var version = "3.6.0";
934
+ var version = "3.7.0-next.1794137250723.d0dade1";
935
935
 
936
936
  //#endregion
937
937
  //#region src/index.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adbayb/stack",
3
- "version": "3.6.0",
3
+ "version": "3.7.0-next.1794137250723.d0dade1",
4
4
  "description": "My opinionated JavaScript-based toolchain",
5
5
  "keywords": [
6
6
  "development",
@@ -6,8 +6,8 @@ metadata:
6
6
  author: adbayb
7
7
  repository: adbayb/stack
8
8
  requires:
9
- - "software-design >=1.1.0"
10
- version: "1.1.0"
9
+ - "software-design >=1.2.0"
10
+ version: "1.2.0"
11
11
  ---
12
12
 
13
13
  # Software Audit
@@ -83,9 +83,9 @@ Present the `Output` section's report first. For a PR review, default to the rep
83
83
  ```markdown
84
84
  ## Audit findings
85
85
 
86
- | # | Location | Severity | Criterion(s) | Issue | Solution |
87
- | --- | ------------------------- | -------- | ---------------- | --------------------------------------------------------------------------------- | ----------------------------- |
88
- | 1 | `src/refund/refund.ts:42` | Major | C. SOLID / GRASP | SRP: unrelated callers change validation and retry, coupling their change reasons | Separate the responsibilities |
86
+ | # | Location | Severity | Criterion(s) | Issue | Solution |
87
+ | --- | ----------------------------- | -------- | ---------------- | --------------------------------------------------------------------------------- | ----------------------------- |
88
+ | 1 | `src/refund/<source-file>:42` | Major | C. SOLID / GRASP | SRP: unrelated callers change validation and retry, coupling their change reasons | Separate the responsibilities |
89
89
  ```
90
90
 
91
91
  For each finding, name the in-scope scoring dimension or dimensions it affects, using the checklist's letter and title. Write each Issue as one sentence: the violated rule or smell, then the evidence and its consequence; cite the rule instead of pasting its prose or theory. Keep each Solution to a fix direction.
@@ -96,7 +96,7 @@ Then total counts by severity, a per-dimension coverage line (findings count or
96
96
 
97
97
  Request: "Audit `src/refund/` and fix what matters."
98
98
 
99
- - Report: 1 Major (SRP at `src/refund/refund.ts:42`), 1 Minor (a new `fetchRefund` helper uses a banned verb); G skipped, no new input boundary.
99
+ - Report: 1 Major (SRP at `src/refund/<source-file>:42`), 1 Minor (a new `fetchRefund` helper uses a banned verb); G skipped, no new input boundary.
100
100
  - Fixes: retry policy extracted (blast radius: one module and its test); helper renamed to `getRefund`.
101
101
  - Verification: unit tests, lint, and type checks pass; the re-scan finds no new violations.
102
102
  - Criteria after fixes: A-F each 2/2; G inapplicable, excluded from the denominator.
@@ -8,14 +8,14 @@ Depth: each dimension is exhaustive within scope. Walk every Evidence item again
8
8
 
9
9
  Rules: `software-design` reference `api-surface.md`.
10
10
 
11
- - Evidence: YAGNI gate per resource/field/flag/option/export (requirement, add-later cost, removal cost), including unused "future" hooks, duplicate routes, and default-expanded relations; one purpose per unit and CQS (queries that mutate, commands returning more than identity/Result); parameter count (Parameter Object only when inputs are cohesive), parameter order (required inputs after an options object, options holding required settings), boolean traps, observable behavior becoming an accidental contract (Hyrum's Law), `any`/wide inputs; leaked infrastructure types (ORM entities, `Request`/`Response`, SDK DTOs, driver rows/cursors/errors) and hidden mechanisms (ordering, retries, batching, storage); lowest sufficient scope (importers checked, counterpart exported before first consumer, implementations exported instead of contracts); invariant ownership across every entry path and invalid state combinations (flags vs discriminated unions, exhaustiveness, mutable aliases); money/quantity/time-zone units, precision, and rounding; transaction boundary at the use case, partial-failure recovery (outbox/compensation only where the required consistency needs it), unit-of-work ownership in the application layer, transaction held across network calls; read-check-write races and conflict behavior; typed stable errors without stack traces or driver messages; versioning, and source/wire/storage/behavioral compatibility (error shapes, defaults, mixed-version readers/writers); callers and slices touched (blast radius).
11
+ - Evidence: YAGNI gate per resource/field/flag/option/export (requirement, add-later cost, removal cost), including unused "future" hooks, duplicate routes, and default-expanded relations; one purpose per unit and CQS (queries that mutate, commands returning more than identity or the project's standard success/failure outcome); parameter count (Parameter Object only when inputs are cohesive), parameter order (required inputs after an options object, options holding required settings), boolean traps, observable behavior becoming an accidental contract (Hyrum's Law), `any`/wide inputs; leaked infrastructure types (ORM entities, `Request`/`Response`, SDK DTOs, driver rows/cursors/errors) and hidden mechanisms (ordering, retries, batching, storage); lowest sufficient scope (importers checked, counterpart exported before first consumer, implementations exported instead of contracts); invariant ownership across every entry path and invalid state combinations (flags vs discriminated unions, exhaustiveness, mutable aliases); money/quantity/time-zone units, precision, and rounding; transaction boundary at the use case, partial-failure recovery (outbox/compensation only where the required consistency needs it), unit-of-work ownership in the application layer, transaction held across network calls; read-check-write races and conflict behavior; typed stable errors without stack traces or driver messages; versioning, and source/wire/storage/behavioral compatibility (error shapes, defaults, mixed-version readers/writers); callers and slices touched (blast radius).
12
12
  - Deltas: trace each finding to a current consumer or contract; distinguish an internal signature change from an incompatible published contract. Apply reference exceptions; generated code/test doubles exempt.
13
13
 
14
14
  ## B. Structure
15
15
 
16
- Rules: `software-design` reference `architecture-styles.md`.
16
+ Rules: `software-design` reference `architecture-styles.md` and `software-design` reference `language-conventions.md`.
17
17
 
18
- - Evidence: slice boundary and inner style stated or inferable, then vertical slicing by capability (no global `controllers/`/`services/`/`models/` sprawl, no `features/` container) and one consistent inner style per module; dependency direction; cross-slice/module imports and deep imports; cross-slice communication via contracts/events only; database-shaped types shared across slices or cross-slice joins; barrel/`index.ts` files containing only re-exports (no imports, declarations, or wiring) and imports through the barrel; sharing threshold and shared-kernel size; composition-root/startup wiring and hosts; hexagonal specifics (ports named for purpose not technology, driver vs driven split, adapters per tech implementing one port, adapters never importing each other, hexagon free of framework/adapter imports, persistence ignorance, clock via param/port, test adapters); clean-architecture specifics (layers bypassed, controller calling repository, controller/presenter mixed, use cases returning view-shaped data, module extraction justified, workspace-name cross-module imports); MVVM viewmodel purity; single `infra/` tree (Périphérique); premature event bus/CQRS/service split; boundary enforcement (linter restricted imports, package `exports`, or convention).
18
+ - Evidence: slice boundary and inner style stated or inferable, then vertical slicing by capability (no global `controllers/`/`services/`/`models/` sprawl, no `features/` container) and one consistent inner style per module; dependency direction; cross-slice/module imports and deep imports; cross-slice communication via contracts/events only; database-shaped types shared across slices or cross-slice joins; in TypeScript/JavaScript, barrel files (such as `index.ts` or `index.js`) containing only re-exports and imports through the barrel; in other languages, the project's idiomatic module/export boundaries; sharing threshold and shared-kernel size; composition-root/startup wiring and hosts; hexagonal specifics (ports named for purpose not technology, driver vs driven split, adapters per tech implementing one port, adapters never importing each other, hexagon free of framework/adapter imports, persistence ignorance, clock via param/port, test adapters); clean-architecture specifics (layers bypassed, controller calling repository, controller/presenter mixed, use cases returning view-shaped data, module extraction justified, workspace-name cross-module imports); MVVM viewmodel purity; single `infra/` tree (Périphérique); premature event bus/CQRS/service split; boundary enforcement (linter restricted imports, package `exports`, or convention).
19
19
  - Deltas: establish the chosen style before reporting layer bypasses; direct repository calls are valid in flat transaction scripts. Check whether tooling can enforce a claimed boundary; do not invent layers to satisfy the checklist.
20
20
 
21
21
  ## C. SOLID / GRASP
@@ -35,16 +35,16 @@ Rules: `software-design` reference `smells-antipatterns.md` and `software-design
35
35
 
36
36
  ## E. Clean code
37
37
 
38
- Rules: `software-design` reference `clean-code.md`.
38
+ Rules: `software-design` reference `clean-code.md` and `software-design` reference `language-conventions.md`.
39
39
 
40
- - Evidence: laws (KISS cleverness, DRY knowledge ownership, POLA surprises, Gall/YAGNI over-building, Kernighan hard-to-debug code, Conway/unclear ownership, Boy Scout/Broken Windows small decay left in touched code); naming (intent, one verb per meaning, banned synonyms, `All` infix, boolean `is*/has*/can*`, `input`/`output` generics vs domain names, `<Fn>Input`/`<Fn>Output` boundary contracts, `on<Event>` handlers, verb-first functions/noun types, stutter, type prefixes, `Manager`/`Helper`/`Util` identifiers, scope-sized names, consistency with the slice's existing verbs); function size/nesting/guards, single-level abstraction, output args; explanatory variables, encapsulated and positive conditionals, pass-through single-use aliases; named constants for domain policy and arbitrary defaults/limits/timeouts/retry counts (with stated reason); temporal coupling and logical dependencies left implicit (ambient order, hidden initialization); comments (why not what), commented-out code; type-checker silencing (`as any`, `@ts-ignore`, `!`); redundant annotations; top-down file ordering and const use-before-define; error handling convention (Result mapping at adapters, absence vs failed I/O, preserved causes, swallowed errors, error codes mixed with values); silent domain (logging/metrics in entities or use cases); `undefined` vs `null` semantics; neutral text; public interface docs/TSDoc.
40
+ - Evidence: laws (KISS cleverness, DRY knowledge ownership, POLA surprises, Gall/YAGNI over-building, Kernighan hard-to-debug code, Conway/unclear ownership, Boy Scout/Broken Windows small decay left in touched code); naming (intent, one verb per meaning, banned synonyms, `All` infix, boolean `is*/has*/can*`, `input`/`output` generics vs domain names, `<Fn>Input`/`<Fn>Output` boundary contracts, `on<Event>` handlers, verb-first functions/noun types, stutter, type prefixes, `Manager`/`Helper`/`Util` identifiers, scope-sized names, consistency with the slice's existing verbs); function size/nesting/guards, single-level abstraction, output args; explanatory variables, encapsulated and positive conditionals, pass-through single-use aliases; modern, idiomatic syntax when it improves clarity or reduces code, provided it preserves readability and behavior and is supported by declared targets and toolchain; avoid assumed performance gains and unsupported compiler transforms or runtime shims; named constants for domain policy and arbitrary defaults/limits/timeouts/retry counts (with stated reason); temporal coupling and logical dependencies left implicit (ambient order, hidden initialization); comments (why not what), commented-out code; language-appropriate type-safety escape hatches (for TypeScript, `as any`, `@ts-ignore`, `@ts-expect-error`, and non-null `!`; for JavaScript, relevant TypeScript-checking suppressions); redundant annotations; primary public APIs before supporting types and implementation details where the language permits, test scenarios before test helpers, and initialization-order hazards (including `const` use-before-define in TypeScript/JavaScript modules); project-standard error handling and boundary mapping (including Result mapping at adapters where applicable), absence vs failed I/O, preserved causes, swallowed errors, and error codes mixed with successful values; silent domain (logging/metrics in entities or use cases); optional/nullability semantics (for TypeScript/JavaScript, `undefined` vs `null`); neutral text; public API documentation in the target language's standard form (TSDoc/JSDoc for TypeScript/JavaScript).
41
41
  - Deltas: scope naming/style to new or edited code, neutral-text checks to introduced text.
42
42
 
43
43
  ## F. Tests / cohesion / coupling / errors
44
44
 
45
- Rules: `software-design` reference `cohesion-coupling.md`, `software-design` reference `testing-refactoring.md`, and `software-design` reference `clean-code.md`.
45
+ Rules: `software-design` reference `cohesion-coupling.md`, `software-design` reference `testing-refactoring.md`, `software-design` reference `clean-code.md`, and `software-design` reference `language-conventions.md`.
46
46
 
47
- - Evidence: cohesion (co-located handler/domain/tests/mapping, functional cohesion); sharing threshold (second consumer for a symbol, Rule of Three for a module, premature promotion or lingering duplication); coupling (cycles, globals, hidden I/O, Demeter/Tell-Don't-Ask, surprise side effects, direct call vs port vs event choice, events lacking delivery/duplicate/ordering handling, files changed per change); new third-party dependencies or ones replacing available platform features/existing dependencies (maintenance, security, size, license vs owning the code); testability (pure domain separated from I/O, explicit injection over module mocking, fakes beside ports, no DI framework solely for tests); tests (colocated, behavior through public interface, one behavior per test and scenario naming, `test.each` for overlap, boundaries and failure paths, awaited async/`resolves`/`rejects`, deterministic clocks/randomness/no sleeps, cleanup and mock/global restoration, no implementation-coupled or redundant tests, pyramid balance, adapter contract tests, weakened/deleted tests); refactor hygiene (green baseline, characterization tests, behavior fixes separate, callers updated with blast radius); error convention/boundary mapping/query purity/absence; resource ownership and cleanup on failure/cancellation, unawaited async work, timeouts, retry bounds and stacked retries, idempotency keys claimed atomically, bounded concurrency/queues/payloads, backpressure, unmeasured caches/batching and their invalidation.
47
+ - Evidence: cohesion (co-located handler/domain/tests/mapping, functional cohesion); sharing threshold (second consumer for a symbol, Rule of Three for a module, premature promotion or lingering duplication); coupling (cycles, globals, hidden I/O, Demeter/Tell-Don't-Ask, surprise side effects, direct call vs port vs event choice, events lacking delivery/duplicate/ordering handling, files changed per change); new third-party dependencies or ones replacing available platform features/existing dependencies (maintenance, security, size, license vs owning the code); testability (pure domain separated from I/O, explicit injection over module mocking, fakes beside ports, no DI framework solely for tests); tests (colocated by language/project convention, behavior through public interface, one behavior per test and scenario naming, boundaries and failure paths, deterministic clocks/randomness/no sleeps, cleanup and mock/global restoration, no implementation-coupled or redundant tests, pyramid balance, adapter contract tests, weakened/deleted tests); in TypeScript/JavaScript, also apply applicable runner-specific checks such as `test.each`, Vitest async assertions, and `vi` cleanup APIs; for other languages, use the target project's test framework; refactor hygiene (green baseline, characterization tests, behavior fixes separate, callers updated with blast radius); error convention/boundary mapping/query purity/absence; resource ownership and cleanup on failure/cancellation, unawaited async work, timeouts, retry bounds and stacked retries, idempotency keys claimed atomically, bounded concurrency/queues/payloads, backpressure, unmeasured caches/batching and their invalidation.
48
48
  - Deltas: a diff that omits test files alone does not establish a coverage gap. Before reporting one, identify a behavior contract changed by the reviewed diff; an audit-only finding about existing behavior does not make that contract changed. If no changed contract is in scope, do not report or deduct for absent coverage. For a changed contract, inspect the relevant suite to confirm its boundary or failure behavior is untested; if that evidence is unavailable, record an investigation gap rather than a finding or score deduction. Trace success, rejection, timeout/cancellation, duplicate/concurrent execution, and partial-failure paths when relevant; check final state, effect count, cleanup, and reported errors.
49
49
 
50
50
  ## G. Security
@@ -5,7 +5,7 @@ license: MIT
5
5
  metadata:
6
6
  author: adbayb
7
7
  repository: adbayb/stack
8
- version: "1.1.0"
8
+ version: "1.2.0"
9
9
  ---
10
10
 
11
11
  # Software Design
@@ -32,7 +32,7 @@ Follow in order; skip only with a reason. Ask when a wrong guess is costly; othe
32
32
 
33
33
  ### 1. Shape the slice
34
34
 
35
- - Load `references/architecture-styles.md`; decide the slice boundary and inner style before writing code.
35
+ - Load `references/language-conventions.md` and `references/architecture-styles.md`; decide the target language's module, test, naming, and documentation conventions, then choose the slice boundary and inner style before writing code.
36
36
  - State the choice in one sentence.
37
37
 
38
38
  ### 2. Design the public surface
@@ -14,10 +14,10 @@ If (1) has no answer, do not add it. Speculative Generality and Second-System Ef
14
14
 
15
15
  ## Design rules
16
16
 
17
- - **One purpose per unit.** Endpoints, functions, and classes serve one cohesive purpose. Split commands from queries (CQS): `createOrder(input): Result<OrderId>` mutates and returns a Result; `getOrder(id)` does not change business state. Read-side I/O and adapter observability are allowed.
18
- This is the documented exception: a command may return the created identity or a Result; queries never mutate.
19
- - **Few, explicit parameters.** Prefer at most 3 parameters. At 4+, check whether the function has multiple responsibilities or its inputs form a cohesive Parameter Object; use an object when it improves clarity, otherwise keep the simple signature. Put required inputs first and at most one options object last, holding only optional settings so callers can omit it and it can grow without reordering; a newly required input becomes positional before it: `scan(path, options, signal)` -> `scan(path, signal, options)`. Platform conventions such as callback-last APIs still win. No boolean traps: `send(email, true)` -> `sendWelcome(email)` / `sendReset(email)`.
20
- - **Narrow interfaces.** Prefer `create(order: Order)` over `create(data: any)`. Return domain types, not driver rows. Keep storage-native cursors, SQL fragments, and SDK errors internal; expose an opaque pagination token only when a current contract needs it.
17
+ - **One purpose per unit.** Endpoints, functions, and classes serve one cohesive purpose. Split commands from queries (CQS): for example, `createOrder` mutates and returns the created identity or a success/failure outcome in the project's idiom; `getOrder(id)` does not change business state. Read-side I/O and adapter observability are allowed.
18
+ This is the documented exception: a command may return the created identity or the project's standard success/failure outcome (such as a `Result` where idiomatic); queries never mutate.
19
+ - **Few, explicit parameters.** Prefer at most 3 parameters. At 4+, check whether the function has multiple responsibilities or its inputs form a cohesive parameter record (object/struct); use one when it improves clarity, otherwise keep the simple signature. Where the language's call conventions support it, put required inputs before at most one optional options record, so adding a required input does not follow an optional one (`scan(path, options, signal)` -> `scan(path, signal, options)`). Platform conventions such as callback-last APIs still win. No boolean traps: `send(email, true)` -> `sendWelcome(email)` / `sendReset(email)`.
20
+ - **Narrow interfaces.** Prefer a domain type over an unbounded or dynamic input type (in TypeScript, for example, `any`). Return domain types, not driver rows. Keep storage-native cursors, SQL fragments, and SDK errors internal; expose an opaque pagination token only when a current contract needs it.
21
21
  - **Input and invariants.** Follow `security.md` for untrusted-input validation. Parse transport shape at the adapter; enforce business invariants in domain constructors and transitions for every entry path, including internal callers. Use types to prevent invalid states where practical; do not repeat transport parsing inside the domain.
22
22
  - **Hide what can change.** Keep ordering, retries, batching, and storage choices internal. Expose facts and intents, not mechanisms.
23
23
  - **No leakage.** Infrastructure types (ORM entities, `Request`/`Response`, SDK DTOs) stop at the adapter. Map to domain at the port.
@@ -2,22 +2,24 @@
2
2
 
3
3
  A slice is one business feature cut vertically through the layers, owning its handler, domain/hexagon, adapters, and tests. Vertical slicing is mandatory. Modules are optional: use them for larger applications with heavy rules, where they enforce cohesion and minimize coupling. Choose one inner style per module (or app) and keep it consistent; a module may choose locally (e.g. MVC/flat for light logic, Clean/Hexagonal for heavy rules).
4
4
 
5
+ Folder and file names below illustrate boundaries; apply the target language and project's naming conventions as described in `language-conventions.md`.
6
+
5
7
  ## Vertical slice (default)
6
8
 
7
9
  - Structure by capability: one folder per feature under `src/` (e.g. `src/refund/`), named with a noun, owning its handler, domain/hexagon, adapters, and tests. No `features/` container; the extra level adds nothing.
8
10
  In a clean module, features take the use-case verb form instead: see Clean Architecture essentials.
9
11
  - Cross-slice communication only via explicit contracts or domain events. No deep imports (`../../other-slice/internals`).
10
- - Hexagonal/clean modules expose each folder's public surface through `index.ts`; any file serving as a barrel, including a package entrypoint, contains only re-export declarations, including type-only re-exports, with no imports, local declarations, or executable implementation. Keep startup and wiring in runtime entrypoints or composition roots, not in barrels. Import via the barrel, never deep into another folder's internals. Flat/MVVM slices may import directly within the slice, but never deep-import another slice's internals.
12
+ - In TypeScript/JavaScript projects, hexagonal/clean modules expose each folder's public surface through a language-appropriate barrel (`index.ts` for TypeScript, `index.js` for JavaScript); any such barrel, including a package entrypoint, contains only re-export declarations, including type-only re-exports where supported, with no imports, local declarations, or executable implementation. Keep startup and wiring in runtime entrypoints or composition roots, not in barrels. Import via the barrel, never deep into another folder's internals. For other languages, use the project's idiomatic module and export conventions rather than requiring barrels. Flat/MVVM slices may import directly within the slice, but never deep-import another slice's internals.
11
13
  - Shared kernel holds only truly shared code and stays tiny; everything else is duplicated deliberately until the sharing threshold (`cohesion-coupling.md`) proves shared.
12
14
 
13
15
  ## Inside a slice
14
16
 
15
- | Situation | Inner style | Layout hint |
16
- | ------------------------------------------------------------------------------------ | ---------------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
17
- | Same logic through swappable adapters/techs or contexts; hexagon tested in isolation | Hexagonal (ports & adapters) | `hexagon/<use-case>.ts`, `hexagon/ports/driver\|driven/<port-name>.ts`, `adapters/<tech>/<port-name>.ts`, `startup/<tech>.ts` |
18
- | Business logic built on enterprise rules shared across apps/modules | Clean architecture | `entities/`, `useCases/`, `adapters/`, `frameworks/` pointing inward |
19
- | UI-driven with rich view state, thin domain logic | MVVM / MVP | `view`, `viewmodel` (no I/O), `model`/ports for data |
20
- | Single script, CRUD, glue (transaction script) | Flat modular | one slice + tests; no ports ceremony |
17
+ | Situation | Inner style | Layout hint |
18
+ | ------------------------------------------------------------------------------------ | ---------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
19
+ | Same logic through swappable adapters/techs or contexts; hexagon tested in isolation | Hexagonal (ports & adapters) | `hexagon/<use-case>.<source-extension>`, `hexagon/ports/driver\|driven/<port-name>.<source-extension>`, `adapters/<tech>/<port-name>.<source-extension>`, `startup/<tech>.<source-extension>` |
20
+ | Business logic built on enterprise rules shared across apps/modules | Clean architecture | `entities/`, `use-cases/`, `adapters/`, `frameworks/` pointing inward |
21
+ | UI-driven with rich view state, thin domain logic | MVVM / MVP | `view`, `viewmodel` (no I/O), `model`/ports for data |
22
+ | Single script, CRUD, glue (transaction script) | Flat modular | one slice + tests; no ports ceremony |
21
23
 
22
24
  In layered styles, dependencies point inward: inner layers know nothing of outer layers, and adapters implement inner-owned ports. Flat slices need no artificial layers; keep their I/O explicit and testable.
23
25
 
@@ -28,8 +30,8 @@ Follows https://jmgarridopaz.github.io/content/hexagonalarchitecture-ig/intro.ht
28
30
  - Goal: drivers drive the hexagon in isolation from real devices; test cases are the first drivers: the hexagon is done when it passes with test doubles, real adapters come after.
29
31
  - Ports are named for purpose (`ForParkingCars`, `ForObtainingRates`), not technology; each port publishes its interface + DTOs, implementation stays hidden. Split by side: driver (called by adapters) vs driven (implemented by adapters).
30
32
  - Hexagon = business logic implementing driver ports and depending on driven ports (constructor-injected). Inner organization is orthogonal: single class or app/domain split, your choice.
31
- - Adapters are grouped by tech (`adapters/<tech>/<port-name>.ts`; tech such as `http`, `web`, `cli`, `file`, `postgres`, or `stripe`). Provide at least two per port: a default test adapter (driver: test harness; driven: stub/fake/mock) and a real adapter. Adapters are swappable, implement one port and one role each (SRP), and never import each other.
32
- - Startup: one entry per driver technology (`startup/<tech>.ts`, e.g. `http.ts`, `cli.ts`, or host per driver); it depends on hexagon + adapters (hexagon has no adapter/framework dependencies; each adapter depends on hexagon + its tech).
33
+ - Adapters are grouped by tech (`adapters/<tech>/<port-name>.<source-extension>`; tech such as `http`, `web`, `cli`, `file`, `postgres`, or `stripe`). In TypeScript/JavaScript projects, use the project's `.ts`, `.tsx`, `.js`, or `.jsx` convention; elsewhere use the language's source-file conventions. Provide at least two per port: a default test adapter (driver: test harness; driven: stub/fake/mock) and a real adapter. Adapters are swappable, implement one port and one role each (SRP), and never import each other.
34
+ - Startup: one entry per driver technology (`startup/<tech>.<source-extension>`, e.g. `http` or `cli`); use the project's `.ts`, `.tsx`, `.js`, or `.jsx` convention for TypeScript/JavaScript and the target language's source-file conventions otherwise. It depends on hexagon + adapters (hexagon has no adapter/framework dependencies; each adapter depends on hexagon + its tech).
33
35
  Per entry: 1. instantiate driven adapters, 2. instantiate hexagon injecting driven ports, 3. instantiate driver adapter with driver port, 4. run it. Test entries wire doubles, production entries wire real adapters.
34
36
  - Configurable Dependency both sides (triggerer knows dependency: driver adapter -> driver port; hexagon -> driven port). Domain never imports infrastructure.
35
37
  - Persistence Ignorance: entities do not extend ORM base classes, carry decorators, or know table names. Clock passed as param or via driven port for testability.
@@ -39,10 +41,10 @@ Follows https://jmgarridopaz.github.io/content/hexagonalarchitecture-ig/intro.ht
39
41
  Follows the reference implementation at https://github.com/adbayb/clean-architecture.
40
42
 
41
43
  - Split by module: one module per bounded context (`modules/<context>/`) owns everything from presentation to data. Modules are decision-autonomous, so only business-heavy modules pay for these layers.
42
- - Top-level entries inside a module are business features and shared entities side by side (`modules/catalog/src/` holds `GetProducts/` next to `Product/`); second-level directories are the layers, so the dependency rule is materialized in the folder tree.
43
- - Each module is a workspace package (`modules/<context>/package.json`). Cross-module imports use workspace package names only, never deep relative imports; build/test run per module. Enforce boundaries as below: package membership alone does not prevent forbidden imports.
44
+ - Top-level entries inside a module are business features and shared entities side by side (`modules/catalog/src/` holds `get-products/` next to `product/`); second-level directories are the layers, so the dependency rule is materialized in the folder tree.
45
+ - Each module is a package or workspace unit; use the target ecosystem's manifest and module naming. Cross-module imports use public package, crate, or module names rather than deep relative imports; build/test run per unit. Enforce boundaries as below: package membership alone does not prevent forbidden imports.
44
46
  - Extract a new module when language diverges (same word, different meaning), change cadence splits, or team ownership demands it. Never do it for a single team shipping one deploy with one language; that is slices, not modules.
45
- - Layers, inward only: `frameworks/` (views, data sources, DB clients) -> `adapters/` (gateways, presenters) -> `useCases/` (application business rules) -> `entities/` (enterprise business rules). Runtime calls may point outward through inner-owned ports; source imports must not.
47
+ - Layers, inward only: `frameworks/` (views, data sources, DB clients) -> `adapters/` (gateways, presenters) -> `use-cases/` (application business rules) -> `entities/` (enterprise business rules). Runtime calls may point outward through inner-owned ports; source imports must not.
46
48
  - Shared Kernel (`modules/shared/`) is a shared module holding shareable entities coupled to gateways: not a dumping ground.
47
49
  - Shared entities live as siblings of features directly under `src/`, never in a `shared/` folder and never imported feature-to-feature.
48
50
  A shared entity is a full vertical unit, not just a domain class: it embeds all its layers including gateway implementations (`Product/` carries `entities/` + `adapters/` + `frameworks/`, only `useCases/` missing since entities have no use case).
@@ -64,7 +66,7 @@ Follows the transaction-script pattern (https://martinfowler.com/eaaCatalog/tran
64
66
 
65
67
  ## What not to do
66
68
 
67
- - Do not rely on convention alone for boundaries: encode the dependency rule, module boundaries, and barrel entry points in the linter (restricted imports) and in workspace `package.json` `exports`, so violations fail the check instead of slipping through review.
69
+ - Do not rely on convention alone for boundaries: encode dependency rules and module boundaries in the project's lint and package tooling where supported. In TypeScript/JavaScript workspaces, use restricted-import lint rules and `package.json` `exports` where appropriate; in other ecosystems, use their equivalent boundary checks.
68
70
  - Do not lump all infrastructure in one tree (`infra/` with web controllers next to database repositories); it lets outer layers call each other around the domain (Périphérique antipattern). Split infrastructure per adapter and keep every crossing behind a port.
69
71
  - Do not create global `controllers/`, `services/`, `models/` layers for a sliced system: that is horizontal sprawl with high coupling.
70
72
  - Do not share a database-shaped type across slices. Map at each boundary.
@@ -14,24 +14,25 @@
14
14
 
15
15
  ## Code rules
16
16
 
17
+ - Prefer modern, idiomatic syntax when it improves clarity or reduces code, and only when supported by the project's declared targets and toolchain. Preserve readability and behavior; don't assume newer syntax is faster, and avoid syntax that requires unsupported compiler transforms or runtime shims.
17
18
  - Names reveal intent: `refundOverdueOrders(clock, repo)` beats `process(data, 1)`. No abbreviations, no `tmp`/`data2`, no misleading names (`getAll` that is actually a map).
18
19
  - Functions are small, single-level, single-purpose. Prefer guard clauses and shallow nesting; deeper nesting is a signal to check for mixed responsibilities or hard-to-follow control flow. For new or substantially edited functions approaching 20 lines, check whether extraction improves cohesion and readability; line count alone is not a reason to add indirection. Leave unrelated existing functions for a scoped refactor.
19
- - Use `async`/`await` to sequence asynchronous work; generators instead provide lazy iteration. Use a generator when incremental production is needed and it makes the flow clearer than a direct loop or platform stream, not just to express ordinary async control flow.
20
+ - Use the language's idiomatic mechanism to sequence asynchronous work; use `async`/`await` where supported. Generators instead provide lazy iteration; use one when incremental production is needed and it makes the flow clearer than a direct loop or platform stream, not just to express ordinary async control flow.
20
21
  - Use `api-surface.md` for command/query separation. No output args. Name literals that encode domain policy or recur with the same meaning; leave self-explanatory structural literals inline.
21
22
  - Match the surrounding annotation style: skip annotations that only repeat an inferred type, but keep explicit types where the file or exported contract already uses them; annotate when a stricter type than inferred is wanted (e.g. an enum instead of `string`).
22
- - Order files top-down: public-facing interface and high-level policy before implementation details; describe/test cases before helpers in test files. Do not call a `const` helper at module load before it is defined.
23
+ - Order production files top-down when supported by the language: put the primary public API first, followed by supporting types and implementation details. In test files, describe scenarios before test helpers. Avoid initialization-order dependencies; in TypeScript/JavaScript modules, do not call a `const` helper at module load before it is initialized.
23
24
  - Comments explain why, never what. Delete commented-out code and obvious narration. Code should read without them.
24
25
  - Error handling is explicit: use the project's established convention. In Result-based code, represent expected failures as Results and map foreign exceptions at adapters; do not introduce a Result library or migrate throw-based code for this rule. Distinguish expected absence from failed I/O; never turn a failed lookup into an empty result. Preserve error causes for boundary reporting, without leaking infrastructure or secrets. Hosts map failures to responses and logs; do not swallow errors or mix error codes with successful values.
25
26
  - Silent domain: no logging or metrics in entities or use cases. Observability lives in adapters/hosts (middleware/decorators); the domain signals through typed errors and return values.
26
27
  - Name the middle steps: break complex expressions into explanatory variables and encapsulate boolean conditions (`if (isEligibleForRefund)` beats an inline predicate). Prefer positive conditionals; no double negatives (`isEnabled`, not `isNotDisabled`).
27
- - Every name must earn its place: a single-use const is justified only if it adds meaning, binds an await, narrows a type, or centralizes a literal; pure pass-through aliases get inlined.
28
+ - Every name must earn its place: a single-use binding is justified only if it adds meaning, holds an awaited result where applicable, narrows a type where supported, or centralizes a literal; pure pass-through aliases get inlined.
28
29
  - No hidden temporal coupling: never require callers to invoke methods in a specific order. Make the sequence unrepresentable (single entry point, builder, or explicit state) or pass the prerequisite as a parameter.
29
30
  - Make logical dependencies physical: if one unit needs another, say so with an import, parameter, or injection. No action at a distance, no reliance on ambient execution or initialization order.
30
31
  - Don't be arbitrary: every default, limit, timeout, and retry count is a named constant with a stated reason, at the top of its module or the composition root. Never a bare literal buried in logic.
31
- - Don't silence the type checker: no `as any`, `@ts-ignore`/`@ts-expect-error`, or non-null `!` to make an error go away. If unavoidable, narrow to the smallest scope and add a why-comment.
32
+ - Don't silence the type checker to make an error go away. In TypeScript/JavaScript, avoid `as any`, `@ts-ignore`/`@ts-expect-error`, and non-null `!`; in other languages, follow equivalent type-safety guidance for that language. If an exception is unavoidable, narrow it to the smallest scope and explain why.
32
33
  - Scope-sized names: long descriptive names for wide scopes, short ones only for tiny scopes (loop counters). No type prefixes or encodings (`strName`, `iCount`); no `Manager`/`Helper`/`Util` grab-bag classes or functions. File/module names may describe shared infrastructure (for example `helpers.ts`); the ban applies to class and function identifiers.
33
- - Prefer `undefined` for optional internal values in new code; preserve `null` where a platform, schema, protocol, or established public contract assigns it meaning. Distinguish missing, empty, and explicit clearing when the contract needs them.
34
- - Public/exported production APIs carry a TSDoc (`/** */`) stating the contract (what it promises, including edge behavior; `@param`/`@returns` only when the description adds info beyond the types). Internal production helpers may omit it; non-obvious test helpers may keep a short contract comment.
34
+ - In TypeScript/JavaScript, prefer `undefined` for optional internal values in new code and preserve `null` where a platform, schema, protocol, or established public contract assigns it meaning. In other languages, use the language's idiomatic optional and nullable representations. In either case, distinguish missing, empty, and explicit clearing when the contract needs them.
35
+ - Public/exported production APIs carry contract documentation in the target language's standard form. In TypeScript/JavaScript, use TSDoc or JSDoc (`/** */`) according to the project convention to state the contract (what it promises, including edge behavior; `@param`/`@returns` only when the description adds info beyond the types). Internal production helpers may omit it; non-obvious test helpers may keep a short contract comment.
35
36
  - Document what the API does and returns from the caller's perspective. Preserve contract details needed for correct use. Include implementation details only when they meaningfully clarify observable behavior.
36
37
  - Formatting is automated and non-negotiable; diffs stay focused.
37
38
  - Generated text stays neutral: never emit em dashes (`—`, U+2014), decorative en-dashes/double-hyphens, or invisible unicode (U+00A0, U+200B-U+200D, stray U+FEFF). Restructure the sentence or use plain ASCII equivalents (hyphen, regular space) instead.
@@ -43,7 +44,7 @@ Pick one verb per contract and use it everywhere. Same verb must always mean the
43
44
 
44
45
  - **Queries (no mutation):** `get` (lookup by identity), `find` (search by criteria/filter), `exists` / `count`. Missing values use the absence convention above; failures use the project's error convention. Use `getOrThrow` only for an explicit missing-value exception contract; an I/O failure alone does not require renaming a query. Collections use a plural noun, never an `All` infix (`getOrders`, `findOverdueOrders`, not `getAllOrders`).
45
46
  - **Commands (side effects):** `create`, `update`, `remove` for plain lifecycle; rich domain behavior uses intention verbs (`refundOrder`, `activateAccount`) instead of `setStatus` / `updateFlag`.
46
- - **Banned synonyms:** `fetch` / `retrieve` / `load` / `read` / `list` -> `get`, `query` (as verb) -> `find` / `exists`, `delete` / `clear` -> `remove`, `add` / `insert` / `save` -> `create` / `update`, `set` -> an intention verb (`refundOrder`, not `setStatus`; plain `set` only for dumb holders/builders/DTOs and React state setters), `process` / `handle` / `manage` / `do` -> the specific intention verb, `data` / `info` / `util` -> a domain noun (`Order`, `RefundPolicy`). Third-party and platform APIs (e.g. `fetch`) keep their own names.
47
+ - **Banned synonyms:** `fetch` / `retrieve` / `load` / `read` / `list` -> `get`, `query` (as verb) -> `find` / `exists`, `delete` / `clear` -> `remove`, `add` / `insert` / `save` -> `create` / `update`, `set` -> an intention verb (`refundOrder`, not `setStatus`; plain `set` only for dumb holders/builders/DTOs or when a framework specifically requires it, as React does for state setters), `process` / `handle` / `manage` / `do` -> the specific intention verb, `data` / `info` / `util` -> a domain noun (`Order`, `RefundPolicy`). Third-party and platform APIs (e.g. `fetch`) keep their own names.
47
48
  - **Booleans:** `is*`, `has*`, `can*` (`isOverdue`, `hasAccess`, `canRefund`).
48
49
  - **Generic utilities:** parameters with no domain meaning use `input` (`...inputs` for rest) and results use `output`, instead of `data`/`arg`/`val`/`x`. A parameter with domain meaning always takes the domain name (`userId`, not `input`); destructured properties and task keys keep distinct domain names.
49
50
  - **Boundary contracts:** when a function's input/output shape exists nowhere else (bespoke aggregation at a boundary, also serving as the Parameter Object), name it `<FunctionName>Input` / `<FunctionName>Output` (PascalCase of the verb-first function: `createMessage` takes `CreateMessageInput`). Reuse domain types directly otherwise: never alias a domain entity per function, never wrap a single existing value.
@@ -0,0 +1,10 @@
1
+ # Language Conventions
2
+
3
+ The design principles in this skill apply across languages; code examples and ecosystem-specific practices do not.
4
+
5
+ - Identify the language and conventions from the files, manifests, toolchain, and existing code before designing a change.
6
+ - Treat example paths and identifiers as illustrations; render them using the target language's and project's module and naming conventions.
7
+ - Let the target language's and project's established naming conventions take precedence over literal examples and naming rules elsewhere in this skill. Preserve their intent, such as clear names and consistent verb semantics, but do not require specific English verbs, casing, signatures, or type syntax when they conflict with idiomatic conventions.
8
+ - Apply TypeScript/JavaScript-specific guidance in this skill only when the target project or touched code uses TypeScript or JavaScript. This includes file extensions and barrels, test filenames and runner APIs, type-checker syntax, optional-value semantics, and TSDoc/JSDoc according to the language and project convention.
9
+ - For other languages, follow the target project's established module/export, test, naming, and documentation conventions. If the project has no established convention, use idiomatic conventions for that language and ecosystem; do not translate TypeScript/JavaScript constructs literally.
10
+ - In a mixed-language project, apply conventions per language boundary and keep cross-language contracts explicit.
@@ -5,13 +5,13 @@
5
5
  - Separate pure domain logic from I/O: unit-test without mocks of databases, clocks, or network.
6
6
  - Prefer real collaborators when fast, deterministic, and safe; otherwise inject small fakes or stubs at I/O boundaries (clock, ID generator, repository, HTTP client).
7
7
  - Prefer explicit dependency injection over module interception or global mocking. Function parameters often suffice; do not add a DI framework, interfaces, or layers solely for tests. Retain mocks for legacy or platform boundaries where an injection seam would require disproportionate changes.
8
- - Colocate tests with source (`*.test.ts` next to implementation); fakes live beside the ports they implement.
8
+ - Colocate tests with source according to the project's conventions. In TypeScript/JavaScript projects, use the established `*.test.ts`/`*.test.js` convention; for other languages, use the target language's and project's test layout. Fakes live beside the ports they implement where that fits the project's conventions.
9
9
  - Test behavior through the public interface and keep the suite lean. Assert observable results and effects; verify interaction order or call counts only when they are part of the contract, not incidental implementation details.
10
10
 
11
11
  ## Tests
12
12
 
13
13
  - Use the project's existing test runner and conventions; do not introduce or replace tooling just to add tests.
14
- - Await asynchronous operations and assertions, or return their promises to the runner. With Vitest, await or return `expect(...).resolves` and `expect(...).rejects`.
14
+ - Await asynchronous operations and assertions, or return their promises to the runner where the language and runner use promises. In TypeScript/JavaScript projects using Vitest, await or return `expect(...).resolves` and `expect(...).rejects`; elsewhere use the project's runner and idioms.
15
15
  - Every test earns its place: it covers a behavior, a boundary, or a failure path through the public interface. No coverage fillers, no assertions on implementation details.
16
16
  - One behavior per test, named by scenario and expectation (`refund fails when the order is already refunded`).
17
17
  - Consolidate overlapping cases with `test.each` (or the language's table-driven equivalent) when they share setup and assertions; keep distinct scenarios separate.
@@ -19,7 +19,7 @@
19
19
  - Remove redundant, obsolete, or implementation-coupled tests in files you touch.
20
20
  - Follow `FIRST` and the Testing Pyramid: many fast unit tests on pure domain, fewer integration tests at adapters, minimal end-to-end.
21
21
  - Never weaken or delete a failing test, or suppress a check, to make a fix pass. A test encoding wrong behavior changes only in the behavior-fix lane below, with the previous contract recorded.
22
- - Keep tests deterministic: control clocks/randomness, isolate state, and synchronize asynchronous work by observable events instead of sleeps. Clean up resources and restore mocks, globals, timers, and working-directory changes even after assertions fail; with Vitest, use cleanup hooks and the appropriate `vi` restoration APIs.
22
+ - Keep tests deterministic: control clocks/randomness, isolate state, and synchronize asynchronous work by observable events instead of sleeps. Clean up resources and restore mocks, globals, timers, and working-directory changes even after assertions fail; in TypeScript/JavaScript projects using Vitest, use cleanup hooks and the appropriate `vi` restoration APIs, and otherwise use the project's test framework.
23
23
  - Verify adapter contracts with focused integration tests where fakes could hide query, serialization, transaction, or external error semantics; mock-only tests do not prove an adapter works.
24
24
  - For changed concurrent or retried behavior, exercise the relevant conflict, duplicate, timeout/cancellation, and partial-failure cases. Assert the final state and effect count; use controlled scheduling rather than probabilistic timing.
25
25