@mrciphersmith/keryx 0.4.28 → 0.4.30

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 (132) hide show
  1. package/dist/cli.js +4916 -3655
  2. package/dist/core.js +91 -28
  3. package/dist/keryx-general-worker-entry.js +413 -240
  4. package/package.json +1 -1
  5. package/src/gdskills/bundled/install-manifest.json +3 -0
  6. package/src/gdskills/bundled/rules/core/api-contracts.mdc +21 -136
  7. package/src/gdskills/bundled/rules/core/async-patterns.mdc +18 -171
  8. package/src/gdskills/bundled/rules/core/clean-architecture.mdc +40 -150
  9. package/src/gdskills/bundled/rules/core/cli-interface-design.mdc +63 -194
  10. package/src/gdskills/bundled/rules/core/code-style-patterns.mdc +36 -48
  11. package/src/gdskills/bundled/rules/core/concurrency-patterns.mdc +32 -0
  12. package/src/gdskills/bundled/rules/core/database-patterns.mdc +26 -148
  13. package/src/gdskills/bundled/rules/core/error-handling.mdc +57 -109
  14. package/src/gdskills/bundled/rules/core/frontend-assistant.mdc +14 -29
  15. package/src/gdskills/bundled/rules/core/layout-rendering.mdc +51 -0
  16. package/src/gdskills/bundled/rules/core/mobx-store-template.mdc +69 -511
  17. package/src/gdskills/bundled/rules/core/nestjs-dto.mdc +18 -36
  18. package/src/gdskills/bundled/rules/core/playwright-testing.mdc +35 -308
  19. package/src/gdskills/bundled/rules/core/security-baseline.mdc +18 -140
  20. package/src/gdskills/bundled/rules/core/skill-authoring.mdc +190 -0
  21. package/src/gdskills/bundled/rules/core/skills-storage-workflow.mdc +5 -0
  22. package/src/gdskills/bundled/rules/core/solid-principles.mdc +70 -121
  23. package/src/gdskills/bundled/rules/core/storybook-guidelines.mdc +20 -22
  24. package/src/gdskills/bundled/rules/core/tdd-workflow.mdc +37 -74
  25. package/src/gdskills/bundled/rules/core/ui-anti-slop.mdc +48 -37
  26. package/src/gdskills/bundled/skills/orchestration/task-implementer/SKILL.md +2 -2
  27. package/src/gdskills/bundled/skills/quality/deprecation-path/SKILL.md +1 -1
  28. package/src/gdskills/bundled/skills/quality/tests-creator/SKILL.md +1 -1
  29. package/src/gdskills/bundled/skills/review/review-architecture/SKILL.md +25 -61
  30. package/src/gdskills/bundled/skills/review/review-backend/SKILL.md +15 -69
  31. package/src/gdskills/bundled/skills/review/review-clean-code/SKILL.md +84 -418
  32. package/src/gdskills/bundled/skills/review/review-core-boundaries/SKILL.md +2 -2
  33. package/src/gdskills/bundled/skills/review/review-degradation/SKILL.md +1 -1
  34. package/src/gdskills/bundled/skills/review/review-flow-graph/SKILL.md +1 -1
  35. package/src/gdskills/bundled/skills/review/review-frontend/SKILL.md +17 -311
  36. package/src/gdskills/bundled/skills/review/review-frontend-conventions/SKILL.md +8 -22
  37. package/src/gdskills/bundled/skills/review/review-highload/SKILL.md +84 -228
  38. package/src/gdskills/bundled/skills/review/review-layout/SKILL.md +22 -28
  39. package/src/gdskills/bundled/skills/review/review-logic/SKILL.md +9 -10
  40. package/src/gdskills/bundled/skills/review/review-performance/SKILL.md +16 -38
  41. package/src/gdskills/bundled/skills/review/review-premise/SKILL.md +1 -1
  42. package/src/gdskills/bundled/skills/review/review-regression/SKILL.md +1 -1
  43. package/src/gdskills/bundled/skills/review/review-security-code/SKILL.md +8 -8
  44. package/src/gdskills/bundled/skills/review/review-style/SKILL.md +49 -88
  45. package/src/gdskills/bundled/skills/review/review-testing-practices/SKILL.md +22 -40
  46. package/src/gdskills/bundled/skills/review/review-ui-ux/SKILL.md +42 -82
  47. package/src/gdskills/bundled/stacks/angular/rules/coding-style.mdc +15 -57
  48. package/src/gdskills/bundled/stacks/angular/rules/patterns.mdc +16 -60
  49. package/src/gdskills/bundled/stacks/angular/rules/security.mdc +11 -49
  50. package/src/gdskills/bundled/stacks/angular/rules/testing.mdc +13 -52
  51. package/src/gdskills/bundled/stacks/c-cpp/rules/coding-style.mdc +33 -57
  52. package/src/gdskills/bundled/stacks/c-cpp/rules/patterns.mdc +35 -62
  53. package/src/gdskills/bundled/stacks/c-cpp/rules/security.mdc +35 -62
  54. package/src/gdskills/bundled/stacks/c-cpp/rules/testing.mdc +34 -54
  55. package/src/gdskills/bundled/stacks/ci-github-gitlab/rules/patterns.mdc +27 -56
  56. package/src/gdskills/bundled/stacks/ci-github-gitlab/rules/security.mdc +51 -119
  57. package/src/gdskills/bundled/stacks/csharp-dotnet/rules/coding-style.mdc +42 -74
  58. package/src/gdskills/bundled/stacks/csharp-dotnet/rules/patterns.mdc +45 -83
  59. package/src/gdskills/bundled/stacks/csharp-dotnet/rules/security.mdc +34 -59
  60. package/src/gdskills/bundled/stacks/csharp-dotnet/rules/testing.mdc +33 -62
  61. package/src/gdskills/bundled/stacks/django/rules/coding-style.mdc +15 -56
  62. package/src/gdskills/bundled/stacks/django/rules/patterns.mdc +16 -68
  63. package/src/gdskills/bundled/stacks/django/rules/security.mdc +13 -71
  64. package/src/gdskills/bundled/stacks/django/rules/testing.mdc +16 -62
  65. package/src/gdskills/bundled/stacks/docker-k8s-terraform/rules/coding-style.mdc +30 -53
  66. package/src/gdskills/bundled/stacks/docker-k8s-terraform/rules/patterns.mdc +20 -56
  67. package/src/gdskills/bundled/stacks/docker-k8s-terraform/rules/security.mdc +52 -122
  68. package/src/gdskills/bundled/stacks/docker-k8s-terraform/rules/testing.mdc +23 -42
  69. package/src/gdskills/bundled/stacks/fastapi/rules/coding-style.mdc +13 -47
  70. package/src/gdskills/bundled/stacks/fastapi/rules/patterns.mdc +18 -81
  71. package/src/gdskills/bundled/stacks/fastapi/rules/security.mdc +13 -75
  72. package/src/gdskills/bundled/stacks/fastapi/rules/testing.mdc +14 -58
  73. package/src/gdskills/bundled/stacks/flutter-dart/rules/coding-style.mdc +36 -74
  74. package/src/gdskills/bundled/stacks/flutter-dart/rules/patterns.mdc +30 -66
  75. package/src/gdskills/bundled/stacks/flutter-dart/rules/security.mdc +33 -67
  76. package/src/gdskills/bundled/stacks/flutter-dart/rules/testing.mdc +41 -73
  77. package/src/gdskills/bundled/stacks/go/rules/coding-style.mdc +36 -57
  78. package/src/gdskills/bundled/stacks/go/rules/patterns.mdc +27 -42
  79. package/src/gdskills/bundled/stacks/go/rules/security.mdc +26 -43
  80. package/src/gdskills/bundled/stacks/go/rules/testing.mdc +23 -41
  81. package/src/gdskills/bundled/stacks/java-kotlin-spring/rules/coding-style.mdc +21 -40
  82. package/src/gdskills/bundled/stacks/java-kotlin-spring/rules/patterns.mdc +26 -43
  83. package/src/gdskills/bundled/stacks/java-kotlin-spring/rules/security.mdc +25 -37
  84. package/src/gdskills/bundled/stacks/java-kotlin-spring/rules/testing.mdc +34 -50
  85. package/src/gdskills/bundled/stacks/kotlin-android/rules/coding-style.mdc +28 -65
  86. package/src/gdskills/bundled/stacks/kotlin-android/rules/patterns.mdc +34 -78
  87. package/src/gdskills/bundled/stacks/kotlin-android/rules/security.mdc +35 -68
  88. package/src/gdskills/bundled/stacks/kotlin-android/rules/testing.mdc +34 -68
  89. package/src/gdskills/bundled/stacks/mobx/rules/coding-style.mdc +18 -64
  90. package/src/gdskills/bundled/stacks/mobx/rules/patterns.mdc +13 -66
  91. package/src/gdskills/bundled/stacks/mobx/rules/security.mdc +8 -35
  92. package/src/gdskills/bundled/stacks/mobx/rules/testing.mdc +10 -39
  93. package/src/gdskills/bundled/stacks/nestjs/rules/coding-style.mdc +32 -45
  94. package/src/gdskills/bundled/stacks/nestjs/rules/patterns.mdc +40 -60
  95. package/src/gdskills/bundled/stacks/nestjs/rules/security.mdc +30 -50
  96. package/src/gdskills/bundled/stacks/nestjs/rules/testing.mdc +27 -47
  97. package/src/gdskills/bundled/stacks/nextjs-nuxt/rules/coding-style.mdc +14 -48
  98. package/src/gdskills/bundled/stacks/nextjs-nuxt/rules/patterns.mdc +15 -67
  99. package/src/gdskills/bundled/stacks/nextjs-nuxt/rules/security.mdc +12 -50
  100. package/src/gdskills/bundled/stacks/nextjs-nuxt/rules/testing.mdc +11 -43
  101. package/src/gdskills/bundled/stacks/php-laravel/rules/coding-style.mdc +17 -58
  102. package/src/gdskills/bundled/stacks/php-laravel/rules/patterns.mdc +15 -56
  103. package/src/gdskills/bundled/stacks/php-laravel/rules/security.mdc +13 -50
  104. package/src/gdskills/bundled/stacks/php-laravel/rules/testing.mdc +14 -55
  105. package/src/gdskills/bundled/stacks/python/rules/coding-style.mdc +13 -41
  106. package/src/gdskills/bundled/stacks/python/rules/patterns.mdc +20 -61
  107. package/src/gdskills/bundled/stacks/python/rules/security.mdc +15 -57
  108. package/src/gdskills/bundled/stacks/python/rules/testing.mdc +16 -50
  109. package/src/gdskills/bundled/stacks/react/rules/coding-style.mdc +14 -40
  110. package/src/gdskills/bundled/stacks/react/rules/patterns.mdc +15 -55
  111. package/src/gdskills/bundled/stacks/react/rules/security.mdc +13 -49
  112. package/src/gdskills/bundled/stacks/react/rules/testing.mdc +10 -37
  113. package/src/gdskills/bundled/stacks/ruby-rails/rules/coding-style.mdc +15 -48
  114. package/src/gdskills/bundled/stacks/ruby-rails/rules/patterns.mdc +18 -67
  115. package/src/gdskills/bundled/stacks/ruby-rails/rules/security.mdc +11 -60
  116. package/src/gdskills/bundled/stacks/ruby-rails/rules/testing.mdc +14 -65
  117. package/src/gdskills/bundled/stacks/rust/rules/coding-style.mdc +39 -65
  118. package/src/gdskills/bundled/stacks/rust/rules/patterns.mdc +33 -60
  119. package/src/gdskills/bundled/stacks/rust/rules/security.mdc +35 -57
  120. package/src/gdskills/bundled/stacks/rust/rules/testing.mdc +29 -52
  121. package/src/gdskills/bundled/stacks/sql-db/rules/coding-style.mdc +12 -48
  122. package/src/gdskills/bundled/stacks/sql-db/rules/patterns.mdc +22 -113
  123. package/src/gdskills/bundled/stacks/sql-db/rules/security.mdc +11 -56
  124. package/src/gdskills/bundled/stacks/sql-db/rules/testing.mdc +14 -59
  125. package/src/gdskills/bundled/stacks/swift-ios/rules/coding-style.mdc +29 -65
  126. package/src/gdskills/bundled/stacks/swift-ios/rules/patterns.mdc +41 -88
  127. package/src/gdskills/bundled/stacks/swift-ios/rules/security.mdc +28 -53
  128. package/src/gdskills/bundled/stacks/swift-ios/rules/testing.mdc +32 -65
  129. package/src/gdskills/bundled/stacks/vue/rules/coding-style.mdc +17 -52
  130. package/src/gdskills/bundled/stacks/vue/rules/patterns.mdc +17 -63
  131. package/src/gdskills/bundled/stacks/vue/rules/security.mdc +11 -41
  132. package/src/gdskills/bundled/stacks/vue/rules/testing.mdc +16 -48
@@ -0,0 +1,190 @@
1
+ ---
2
+ description: "Content standard for skill, reviewer-lens and rule text: keep only what changes model behaviour — trigger, finish line, filters, calibration, output format, project decisions — and name a published canon instead of restating it."
3
+ alwaysApply: false
4
+ applies_to: process
5
+ ---
6
+
7
+ # Skill Authoring Standard
8
+
9
+ ## Purpose
10
+
11
+ Current models already know the published canon of software engineering: design principles,
12
+ well-known books, framework documentation. A skill earns its context with what the model
13
+ cannot know — this project's decisions, where the work ends, what not to report, how to grade
14
+ a result. Text that restates the canon is paid for on every load and changes nothing.
15
+
16
+ Measured on keryx's own clean-code review lens: replacing its restated textbook material with
17
+ a table of project decisions cut the lens from 531 to 220 lines with no loss of recall and no
18
+ added noise, and one filter ("a threshold counts only when this change crosses it") removed a
19
+ third of the noise findings. Filters and decisions moved the numbers; principles did not.
20
+
21
+ This rule governs **content**. Storage, frontmatter and length ceilings are in
22
+ `skills-storage-workflow.mdc`; freshness is in `skill-lifecycle.mdc`.
23
+
24
+ ## When To Apply
25
+
26
+ - Writing or editing a `SKILL.md`, a reviewer lens, a rule file, or a subagent instruction.
27
+ - Reviewing a change to any of those.
28
+ - Auditing existing skills and rules for text that no longer changes behaviour.
29
+
30
+ ## Mandatory Behavior
31
+
32
+ ### 1. Apply the deletion test to every line
33
+
34
+ A line stays only if a capable model would behave differently without it. These fail:
35
+ definitions of well-known concepts, restated principles, generic advice ("write readable
36
+ code"), and motivation for doing the task well. When unsure about a line you are writing,
37
+ leave it out and let the evidence in section 7 decide; for text that already ships, follow
38
+ section 9.
39
+
40
+ ### 2. Name the canon, then state what the name cannot carry
41
+
42
+ Reference a published standard by name, in one line. Then write the part the name leaves
43
+ open:
44
+
45
+ - which side wins where the canon contradicts itself or another named canon (small functions
46
+ against deep modules, removing duplication against keeping code local);
47
+ - where this project departs from the canon on purpose, and why — otherwise the departure is
48
+ reported as a defect on every run.
49
+
50
+ A named canon brings its dogma with it. Pair every such reference with filters (section 3),
51
+ or the output fills with findings the canon implies and the project does not want.
52
+
53
+ A line that mixes the two is split: in "functions should be small and focused; flag as
54
+ minor", the grade stays and the explanation goes.
55
+
56
+ ### 3. Carry the content a model cannot derive
57
+
58
+ Include each of these that applies to the skill:
59
+
60
+ - **Trigger** — `description` says what the skill does and when to use it. Conditions of use
61
+ live there, because the body is not loaded until the skill is chosen.
62
+ - **Finish line** — the state in which the work is done.
63
+ - **Filters** — what not to do or report: debt that predates the change, anything a linter
64
+ already catches, anything the change did not touch.
65
+ - **Calibration** — for a skill that grades: the severity scale, the confidence below which a
66
+ finding is dropped, and the evidence a finding must carry (a failing input, not "violates
67
+ a principle").
68
+ - **Input and output contracts** — a template or a schema, for what the skill receives
69
+ and what it returns.
70
+ - **Project decisions** — thresholds, conventions, and the departures from section 2. A
71
+ decision is a specific value or choice the canon leaves open: "40 lines", "locality wins".
72
+ A language's or framework's published default (camelCase in TypeScript) is canon;
73
+ choosing between published conventions, or departing from the default, is a decision.
74
+ In a shipped rule it is a default a project may override; it stays even when its origin
75
+ was never recorded, because the value still constrains the result where the explanation
76
+ around it does not.
77
+ - **Known default failures** — specific outputs the model produces by default and should
78
+ not. A change that adds one names the run where it was seen.
79
+
80
+ ### 4. Write steps only where order is a constraint
81
+
82
+ Use numbered steps when a step is a gate for the next one or the operation is fragile enough
83
+ that one path is safe. Otherwise state the goal and the finish line. An operation that must
84
+ run the same way every time belongs in a script the skill runs, not in prose the model
85
+ re-derives.
86
+
87
+ ### 5. Give the reason, not the emphasis
88
+
89
+ A hard rule states its reason in the same sentence, so the model can apply it to a case the
90
+ rule did not foresee. Capitalised emphasis is for a gate whose miss cannot be undone; used
91
+ elsewhere it makes the model apply the rule too widely.
92
+
93
+ ### 6. Offer one default
94
+
95
+ Give one recommended approach and the condition under which to use the alternative. A list
96
+ of equivalent options moves the choice back to the model without the context to make it.
97
+
98
+ ### 7. Add a line for an observed failure, keep it while it shows an effect
99
+
100
+ A new line answers a failure seen in a run, not one imagined in advance. For a shipped skill,
101
+ compare its routing and behaviour evals with and without the change; a line that moves
102
+ nothing is removed, and a change that makes them worse is recorded as
103
+ `skills-storage-workflow.mdc` ("Rejected Changes") requires.
104
+
105
+ ### 8. Check the smallest tier the skill runs on
106
+
107
+ A skill dispatched to a lighter tier (`model-selection.mdc`) is tested on that tier. A line
108
+ the flagship does not need can pass the deletion test for the lighter model; keep it, and say
109
+ which tier it is for. This protects procedure and precision, not restated canon or
110
+ motivation: every tier already knows the published canon.
111
+
112
+ ### 9. Audit existing text by what reading can decide
113
+
114
+ Reading settles sections 1 and 2; sections 4, 7 and 8 need a run. An audit of text that
115
+ already ships therefore sorts each block into one of three:
116
+
117
+ - **Remove** — restated canon or motivation, with no decision, filter or grade in it. A code
118
+ example of a published principle is restated canon; an example that shows a project
119
+ decision is not.
120
+ - **Keep** — anything section 3 lists, and any block a test pins or a required section
121
+ holds. For a skill, the required sections are its anatomy; for a rule, the headings
122
+ `rule-management-workflow.mdc` ("Rule File Standard") requires — the heading stays, its
123
+ content follows sections 1 and 2. A line that feeds a required field of the output (a
124
+ `Fix`, a severity) stays whole. To remove pinned text, change the check in the same
125
+ change.
126
+ - **Undecided** — everything else. It stays until a run decides: an eval comparison, or a
127
+ run on the lightest tier the skill is dispatched to. Where no eval covers the file, say
128
+ so; reading alone does not justify the removal.
129
+
130
+ Two findings are reported rather than sorted: a capitalised rule without a reason
131
+ (section 5) is rewritten with its reason, and numbered steps that are not gates
132
+ (section 4) are Undecided.
133
+
134
+ An existing line is not removed for lacking a record of the failure it answers; that record
135
+ is required only of lines added from now on.
136
+
137
+ A file that shrinks to a few lines stays a short file while anything cites it by name.
138
+ Shortness is the expected result, not a gap to refill.
139
+
140
+ ## Output Contract
141
+
142
+ When this rule drives an edit or a review of a skill or rule:
143
+
144
+ - Report each removed block as `file:line` with the section of this rule it failed.
145
+ - Report each added line with the observed failure it answers.
146
+ - Report the line count before and after; a trimmed shipped skill lowers its ceiling in the
147
+ same change (`skills-storage-workflow.mdc`, "Length Ceilings").
148
+ - Report each undecided block with the run that would decide it.
149
+ - Input and output formats and schemas, and safety, permission and confirmation text are out
150
+ of scope —
151
+ never removed under this rule.
152
+
153
+ ## Examples
154
+
155
+ ### Restated canon → named canon plus the project's decision
156
+
157
+ ```
158
+ # Before
159
+ The Single Responsibility Principle states that a class should have only one
160
+ reason to change. A function should do one thing, and do it well. Functions
161
+ should be small...
162
+
163
+ # After
164
+ Review against SOLID and Clean Code. In this project:
165
+ - a function mixing I/O with a transform is a finding at any length;
166
+ - length alone is a finding only past 40 lines;
167
+ - where "small functions" and locality conflict, locality wins.
168
+ ```
169
+
170
+ ### Principle → filter
171
+
172
+ ```
173
+ # Before
174
+ Report long functions, duplicated literals and long parameter lists.
175
+
176
+ # After
177
+ A threshold counts only when this change crosses it. One more line in a
178
+ function that was already too long is not a finding.
179
+ ```
180
+
181
+ ### Emphasis → reason
182
+
183
+ ```
184
+ # Before
185
+ NEVER report style issues.
186
+
187
+ # After
188
+ Leave style to the linter: a finding the linter already raises is noise
189
+ for the author and hides the ones it cannot see.
190
+ ```
@@ -11,6 +11,11 @@ Keep skill definitions consistent across master source and global agent director
11
11
  ## Trigger
12
12
  Apply when user asks to create, update, or sync a skill.
13
13
 
14
+ ## Content Standard
15
+ What a skill's text must and must not contain is in `skill-authoring.mdc` — read
16
+ it before writing or trimming skill prose. This rule covers where a skill lives
17
+ and how it is shipped.
18
+
14
19
  ## Mandatory Clarification Step
15
20
  Before creating or editing a skill, ask and confirm:
16
21
  1. Target location
@@ -1,149 +1,98 @@
1
1
  ---
2
- description: "SOLID principles for agent-generated code — focus on Single Responsibility, Open/Closed, and Dependency Inversion as the most commonly violated. Use when designing classes, modules, or service interfaces."
2
+ description: "SOLID and function-design standard shared by code writers and the code-quality, architecture and style reviewers, with the thresholds and severities they use: function length, parameter count, constructor dependencies, branch chains, file length, nesting, branching. Use when designing classes, modules or functions, or reviewing them."
3
3
  alwaysApply: false
4
4
  ---
5
5
 
6
- # SOLID Principles
6
+ # SOLID Principles and Function Design
7
7
 
8
8
  ## Purpose
9
- Prevent the three most common SOLID violations in AI-generated code: god classes, hardcoded dependencies, and modification-on-every-change designs.
9
+ One standard for designing and reviewing classes and functions. The thresholds and severities below are the ones the code-quality, architecture and style reviewers apply. A writer who stays inside them gets no finding, and a reviewer reports nothing inside them.
10
10
 
11
11
  ## When To Apply
12
- Apply when creating new classes, services, or modules; when adding logic to an existing class; when wiring up dependencies.
12
+ Apply when creating or extending classes, services, modules or functions, and when reviewing them.
13
13
 
14
14
  ---
15
15
 
16
- ## S — Single Responsibility Principle
17
-
18
- **One class/module = one reason to change.**
19
-
20
- ### Rules
21
- - A class that does more than one thing must be split
22
- - A function that is longer than ~30 lines almost certainly has multiple responsibilities
23
- - Mixins of data-fetching + business logic + rendering are always a violation
24
- - If you cannot name a class in ≤3 words without "and", it has too many responsibilities
25
-
26
- ### Signals of violation
27
- - Class name contains "Manager", "Handler", "Util", "Helper" (often catch-alls)
28
- - Constructor receives >5 dependencies
29
- - File is longer than 300 lines and is not a config or generated file
30
- - Method count exceeds 10 on a non-entity class
31
-
32
- ### Correct pattern
33
- ```typescript
34
- // BAD — does everything
35
- class UserService {
36
- fetchUser() { /* HTTP */ }
37
- validateUser() { /* domain logic */ }
38
- formatUserForUI() { /* presentation */ }
39
- saveToCache() { /* infrastructure */ }
40
- }
41
-
42
- // GOOD — each class has one job
43
- class UserRepository { fetchUser() {} }
44
- class UserValidator { validate() {} }
45
- class UserPresenter { format() {} }
46
- class UserCache { save() {} }
47
- ```
16
+ ## Thresholds (shared with review-clean-code)
48
17
 
49
- ---
18
+ | Signal | Threshold | When a reviewer reports it |
19
+ |---|---|---|
20
+ | Function body length | over 40 lines | Only when the function also mixes levels of abstraction or does two separable jobs. A long linear table, serializer or test is not a finding. |
21
+ | I/O mixed with a transform | any length | One function that reads or writes (file, network, store) and also transforms the data in between. Keep the transform a pure helper the I/O shell calls. |
22
+ | Positional parameters | 4 or more | When there is no options object and the parameters are not a natural ordered set the codebase already uses. |
23
+ | Boolean flag parameter | any | When the flag selects between two different behaviours, so that call sites read `run(x, true)`. |
24
+ | Constructor dependencies | more than 5 | As an SRP signal; name the two responsibilities. |
25
+ | Branch chain over a type discriminant | 4 or more branches, extended by the change | When the codebase already uses a lookup map or a strategy for the same kind of dispatch. |
26
+ | Duplicated block | 3 or more copies | Reported once, listing every copy. |
50
27
 
51
- ## O — Open/Closed Principle
52
-
53
- **Open for extension, closed for modification.**
54
-
55
- ### Rules
56
- - New behaviour must be addable without editing existing classes
57
- - Use polymorphism, strategy pattern, or configuration — not if/else chains
58
- - Every time you add an `else if` to handle a new variant, ask: "should this be a new strategy?"
59
- - Enums as switch-statement keys are the canonical violation — add a new enum value → touch N files
60
-
61
- ### Signals of violation
62
- - Switch/if-else over a type enum with 3+ cases
63
- - Adding a new payment provider / notification channel / export format requires editing core logic
64
- - A "type" field drives behaviour throughout the codebase
65
-
66
- ### Correct pattern
67
- ```typescript
68
- // BAD — every new type requires editing this function
69
- function notify(type: string, msg: string) {
70
- if (type === 'email') sendEmail(msg);
71
- else if (type === 'sms') sendSMS(msg);
72
- else if (type === 'push') sendPush(msg);
73
- }
74
-
75
- // GOOD — new channels added without touching existing code
76
- interface Notifier { send(msg: string): Promise<void>; }
77
- class EmailNotifier implements Notifier { send() {} }
78
- class SMSNotifier implements Notifier { send() {} }
79
- // registry → inject the right one
80
- ```
28
+ Under a threshold, the reviewer stays silent. When the change crosses one, the finding is rated by Review severities below.
81
29
 
82
- ---
30
+ ## Readability thresholds (shared with review-style)
83
31
 
84
- ## D — Dependency Inversion Principle
85
-
86
- **Depend on abstractions, not concretions.**
87
-
88
- ### Rules
89
- - High-level modules must not import low-level modules directly
90
- - Dependencies are injected, not constructed inside the class
91
- - `new ConcreteService()` inside a business-logic class is always a violation
92
- - Tests become trivially easy when DIP is followed — if mocking is hard, DIP is violated
93
-
94
- ### Signals of violation
95
- - `new` keyword used inside a service or use-case class body
96
- - Direct imports of `axios`, `prisma`, `fetch` in business logic layers
97
- - Constructor creates its own dependencies instead of receiving them
98
- - Testing requires monkey-patching module imports
99
-
100
- ### Correct pattern
101
- ```typescript
102
- // BAD — hard dependency on concrete HTTP client
103
- class OrderService {
104
- async createOrder(data: OrderDTO) {
105
- const client = new HttpClient(); // ← violation
106
- return client.post('/orders', data);
107
- }
108
- }
109
-
110
- // GOOD — depends on abstraction, injected externally
111
- interface HttpClient { post(url: string, body: unknown): Promise<unknown>; }
112
-
113
- class OrderService {
114
- constructor(private readonly http: HttpClient) {}
115
- async createOrder(data: OrderDTO) {
116
- return this.http.post('/orders', data);
117
- }
118
- }
119
- ```
32
+ `review-style` rates these; `review-clean-code` leaves them to it. Generated code, fixtures, migrations and test files are exempt.
120
33
 
121
- ---
34
+ | Signal | Threshold | Default |
35
+ |---|---|---|
36
+ | File length | over 500 lines; over 800 lines | `info`; `minor` |
37
+ | Nesting depth (callbacks or `if/else`) | more than 3 levels | `minor` |
38
+ | Decision branches in one function | more than 10 | `minor` |
39
+ | Boolean condition | more than 3 clauses without grouping | `minor` |
40
+ | Unrelated exports from one file | more than 5 | `minor` |
122
41
 
123
- ## L & I (Brief Notes)
42
+ A threshold in either table counts only when the change crosses it.
124
43
 
125
- **Liskov Substitution (L):** A subclass must be usable wherever the parent is expected. If overriding a method throws where the parent would not — that is a violation.
44
+ A stack rule may refine a threshold for its language, in this table form with the row label copied exactly; for that language, writers and reviewers use the stack value.
126
45
 
127
- **Interface Segregation (I):** Prefer small, focused interfaces. A class should not be forced to implement methods it does not use. Split fat interfaces into role interfaces.
46
+ | Row (exact label above) | Stack value | Marked |
47
+ |---|---|---|
48
+ | Function body length | the stack's own number | `override` |
128
49
 
129
50
  ---
130
51
 
131
- ## Iron Laws
52
+ ## S — Single Responsibility
53
+ **One class or module, one reason to change.**
54
+ - Do not mix fetching, business rules and presentation or persistence in one class or function.
55
+ - If you cannot name it in three words without "and", it does too much.
56
+ - A constructor assigns. It does not perform I/O or start async work.
57
+
58
+ ## O — Open/Closed
59
+ - Adding a variant should not mean editing a growing `if/else` or `switch`. It is a finding only at the Branch chain row: 4 or more branches over a type discriminant, extended by the change, where the codebase already dispatches that kind of thing through a map or a strategy. A chain that merely might grow is not one.
132
60
 
133
- **IRON LAW 1: A class with a name ending in "Manager", "Helper", or "Utils" MUST be reviewed for SRP before committing.**
134
- **IRON LAW 2: `new ConcreteClass()` inside business logic is forbidden. Pass dependencies via constructor.**
135
- **IRON LAW 3: Adding a new variant must not require editing more than 1 existing file. If it does, refactor first.**
61
+ ## L — Liskov Substitution
62
+ - An override must work wherever the base type is used. An override that throws "not supported", or rejects input the base accepts, breaks callers that hold the base type.
63
+
64
+ ## I — Interface Segregation
65
+ - An implementation that leaves methods as stubs or no-ops means the interface is too wide.
66
+
67
+ ## D — Dependency Inversion
68
+ - Business logic receives the dependencies it calls into (I/O, network, clock) instead of constructing them. Inside a module, constructing a plain helper or value object is fine.
69
+ - An interface belongs at an I/O or substitution boundary (repository, external client, clock). A single internal implementation gets none. Interfaces are named without an `I` prefix.
136
70
 
137
71
  ---
138
72
 
139
- ## Red Flags — Stop and re-read this rule if you are thinking:
73
+ ## Iron Laws
140
74
 
141
- | Rationalization | Why it's wrong |
142
- |---|---|
143
- | "It's just one extra method, I'll add it here" | Each small addition is how god classes are built — one method at a time |
144
- | "I'll inject it later, for now I'll just `new` it" | "Later" never comes; the hard dependency ships to production |
145
- | "An interface is overkill for this simple case" | Interfaces cost nothing at compile time and enable testing at zero extra effort |
146
- | "I'll use a switch, there are only 3 cases" | 3 cases becomes 10 over time — the OCP violation compounds |
147
- | "The constructor is getting long but refactoring is risky" | A long constructor is a signal the class has too many responsibilities — refactor now, not later |
75
+ **IRON LAW 1: An override never throws where its base type would not.**
76
+ **IRON LAW 2: A constructor performs no I/O.**
77
+ **IRON LAW 3: The thresholds and severities in this file are the standard for both writing and review. Change them here, never in a reviewer.**
78
+
79
+ ---
148
80
 
149
- **IRON LAW: CODE THAT CANNOT BE TESTED WITHOUT MOCKING FILESYSTEM OR NETWORK IN BUSINESS LOGIC HAS A DIP VIOLATION.**
81
+ ## Review severities (shared with reviewers)
82
+
83
+ `review-clean-code` rates SRP, OCP, LSP, ISP, duplication, magic literals and comments by this table; `review-style` rates names and the Readability thresholds; `review-architecture` rates DIP. A row counts only when the change crosses it: debt the change did not create is not a finding. Unused imports and variables, and import grouping or order, belong to the linter and are never a finding.
84
+
85
+ | Signal | A finding when | Default | Not a finding |
86
+ |---|---|---|---|
87
+ | Any Thresholds row crossed (Function body length, I/O mixed with a transform, Positional parameters, Boolean flag parameter, Constructor dependencies, Branch chain, Duplicated block) | the change crosses the row's threshold under its stated condition | `minor`; `major` only with a named trigger and outcome | under the threshold; a long linear table, serializer or test; a chain that might grow; 2 copies |
88
+ | Any Readability row crossed | the change crosses the threshold | the row's Default | generated code, fixtures, migrations, test files |
89
+ | Override throws "not supported" or rejects input the base accepts (LSP) | always | `major`; `blocker` when the broken caller is in the diff | an override the base contract documents as optional |
90
+ | Constructor does I/O or async work | always | `minor`; `major` only with a named defect it causes | — |
91
+ | Output argument | a function fills a caller-supplied argument instead of returning | `minor` | — |
92
+ | Two change drivers in one class or function | both can be named (validation and persistence) | `minor` | — |
93
+ | Interface wider than its implementers (ISP) | implementers leave stubs or no-ops | `minor` | — |
94
+ | Business logic constructs an I/O, network or clock dependency (DIP) | always | `minor` | a plain helper or value object built inside a module |
95
+ | Magic number or repeated string literal | it has business meaning and no named constant | `minor` | `0`, `1`, `100` and other neutral values |
96
+ | Name | it needs a comment, is generic (`data`, `temp`), gives one concept two names, or has ambiguous boolean polarity | `minor`; `major` only when it already produced a named wrong outcome at a call site | loop counters; project abbreviations |
97
+ | Comment | stale, contradicting, redundant, commented-out code, or compensating for a bad name | `minor` | intent, a domain constraint, a warning, a TODO with an issue |
98
+ | Stylistic opinion, or a future issue with no current violation | — | `info` | — |
@@ -1,5 +1,5 @@
1
1
  ---
2
- description: "Storybook setup, story authoring, and review checklist."
2
+ description: "Storybook standard shared by code writers and reviewers, with the severities reviewers use: typed stories, which states every component's stories cover (default and empty always, loading and error when the component has them, stress cases for lists and long text), fn() for actions, no side effects in render. Use when writing or reviewing *.stories.tsx."
3
3
  alwaysApply: false
4
4
  globs:
5
5
  - ".storybook/**"
@@ -9,29 +9,27 @@ stack_requires: "react"
9
9
 
10
10
  # Storybook Guidelines
11
11
 
12
- ## Purpose
13
- Standardize story creation, validation, and visual regression readiness.
12
+ Canon applies: the Storybook documentation (CSF 3, args, decorators, `@storybook/test`). This rule holds only this project's decisions.
14
13
 
15
- ## When To Apply
16
- Apply when creating, reviewing, or updating Storybook stories (`*.stories.tsx`).
14
+ ## Rules
17
15
 
18
- ## Run Commands
19
- - Local: `npm run storybook`
20
- - Clean restart: `npm run storybook:clean`
21
- - Static build: `npm run build-storybook`
22
- - Static preview: `npm run storybook:preview`
16
+ 1. **Typed CSF stories**: `*.stories.tsx` with `Meta` and `StoryObj`; state variants through `args`; providers and theme through decorators.
17
+ 2. **States covered.** Every component has a default story, and an empty story when it can render empty. A component with a loading or error state has a story for each. A list, or a component that shows user text, has a stress story: many items, long text.
18
+ 3. **No side effects.** Story callbacks are `fn()` from `@storybook/test`; a story never calls a real API, writes storage or logs in place of an action.
19
+ 4. **Visual changes** update the screenshot tests in the same change.
23
20
 
24
- ## Story Authoring Rules
25
- - Use `*.stories.tsx` with `Meta` and `StoryObj` typing.
26
- - Prefer `args` for state variants.
27
- - Use `fn()` from `@storybook/test` for actions.
28
- - Use decorators for providers/context.
21
+ Commands: `npm run storybook`, `npm run build-storybook`.
29
22
 
30
- ## Review Checklist
31
- - Cover key states: default/loading/error/empty.
32
- - Avoid side effects during render.
33
- - Respect global theme/locale decorators.
34
- - Update screenshot tests when visual behavior changes.
23
+ ---
24
+
25
+ ## Review severities (shared with reviewers)
26
+
27
+ `review-frontend` rates these patterns by this table. Change a row here, never in a reviewer.
35
28
 
36
- ## Output Contract
37
- - Story examples in responses must be fenced Markdown code blocks.
29
+ | Signal | A finding when | Default | Not a finding |
30
+ |---|---|---|---|
31
+ | Missing default or empty story (Rule 2) | the component renders that state | `minor` | a component that cannot be empty |
32
+ | Missing loading or error story (Rule 2) | the component has that state (a prop or branch) | `minor` | a component without that state |
33
+ | Missing stress story (Rule 2) | a list, or user text that can be long | `minor` | fixed-length content |
34
+ | A story calls a real API or has another side effect (Rule 3) | always | `minor`; `major` when it writes to a real backend | `fn()` |
35
+ | Visual change without updated screenshot tests (Rule 4) | the project has screenshot tests | `minor` | — |
@@ -1,69 +1,20 @@
1
1
  ---
2
- description: "TDD workflow rules: red-green-refactor cycle, test-first mandate, no-done-without-green invariant. Use when implementing features, fixing bugs, or verifying acceptance criteria."
2
+ description: "Testing standard shared by code writers and reviewers: red-green order, no done without green, tests colocated, new logic gets a test, mock at the boundary, no real network or clock, flaky tests fixed by waiting on a state, and the severities reviewers use. Use when implementing features, fixing bugs, writing or reviewing unit and integration tests."
3
3
  alwaysApply: false
4
4
  ---
5
5
 
6
6
  # TDD Workflow
7
7
 
8
- ## Purpose
9
- Enforce Test-Driven Development: tests are written before implementation code. An agent MUST NOT claim `STATUS: DONE` unless all tests pass.
8
+ Canon applies: the test framework's documentation. This rule holds this project's decisions and the order an implementer works in.
10
9
 
11
- ## When To Apply
12
- Apply during any implementation task. Always loaded alongside `task-implementer` and `tests-creator` workflows.
10
+ ## Process (implementer)
13
11
 
14
- ---
15
-
16
- ## The Red-Green-Refactor Cycle
12
+ 1. **RED.** Write the failing test first, from the task's `acceptance_criteria` (each criterion maps to at least one test; use `test_case_specs` or run `tests-creator` when none exist). Run it and confirm it fails for the right reason: a test that passes before the implementation is broken.
13
+ 2. **GREEN.** Write the minimal code that passes it. Run the tests after each logical chunk.
14
+ 3. **REFACTOR.** Clean up with the suite green; re-run it after every step.
15
+ 4. **Report.** The full suite (`bun test`, `npm test`, `pytest` or the project's equivalent) passes with 0 failures before `STATUS: DONE`.
17
16
 
18
- Every implementation must follow this exact sequence:
19
-
20
- ```
21
- 1. RED → Write a failing test that describes the desired behaviour
22
- 2. GREEN → Write the minimal code to make that test pass
23
- 3. REFACTOR → Clean up code without breaking the test
24
- ```
25
-
26
- **CRITICAL: Never skip RED.** Writing code before a failing test exists violates TDD. Even if the test seems trivial, it must be written first.
27
-
28
- ---
29
-
30
- ## Mandatory Steps
31
-
32
- ### Step 1: Receive Acceptance Criteria
33
- - Parse `acceptance_criteria` from the task object (provided by `issue-analyzer` or `tests-creator`)
34
- - Each criterion maps to ≥1 test case
35
- - If no criteria exist, derive them from the task description before proceeding
36
-
37
- ### Step 2: Run tests-creator (or use pre-generated specs)
38
- - If `test_case_specs` are provided in the task object → use them directly
39
- - If not → invoke `tests-creator` to generate specs before writing any code
40
- - **DO NOT start implementation until test specs are confirmed**
41
-
42
- ### Step 3: Write tests (RED phase)
43
- - Create test file(s) at the correct location (co-located or in `__tests__/`)
44
- - Run the test suite — confirm tests FAIL for the right reason
45
- - A test that passes before implementation is a broken test
46
-
47
- ### Step 4: Implement (GREEN phase)
48
- - Write the minimal code to satisfy each failing test
49
- - Do not add features not covered by tests
50
- - Run tests after each logical chunk — do not batch all implementation before running
51
-
52
- ### Step 5: Refactor
53
- - Clean up code: extract helpers, rename variables, remove duplication
54
- - Re-run full test suite after every refactor step
55
- - Refactoring is complete only when all tests are green
56
-
57
- ### Step 6: Verify and Report
58
- - Final `bun test` / `npm test` / `pytest` / equivalent must pass with 0 failures
59
- - Include test output summary in the result object
60
- - Report `STATUS: DONE` only when all criteria are covered by passing tests
61
-
62
- ---
63
-
64
- ## Output Contract Extension
65
-
66
- When reporting task completion, include:
17
+ Output contract on completion:
67
18
 
68
19
  ```
69
20
  tests_written: <N>
@@ -72,25 +23,37 @@ tests_failing: 0
72
23
  coverage_notes: "<which acceptance criteria are covered>"
73
24
  ```
74
25
 
75
- ---
26
+ **Iron laws.** Never claim `STATUS: DONE` with a failing test. Never write implementation before a failing test exists for that behaviour. Never delete or skip a test to make the suite green; fix the code.
76
27
 
77
- ## Iron Laws
28
+ ## Rules
78
29
 
79
- **IRON LAW 1: NEVER claim STATUS: DONE with failing tests. Zero exceptions.**
80
- **IRON LAW 2: NEVER write implementation before a failing test exists for that behaviour.**
81
- **IRON LAW 3: NEVER delete tests to make the suite green. Fix the code instead.**
30
+ A stack pack's `testing.mdc` adds its framework, layout and tools on top of these and does not repeat them.
82
31
 
83
- ---
32
+ 1. **One toolchain.** Use the project's test framework, assertion and mocking libraries; never add a second one.
33
+ 2. **Unit tests are colocated** with the code (`foo.test.ts` beside `foo.ts`). A separate folder is for e2e only.
34
+ 3. **New or changed logic gets a test in the same change**: a branch, a calculation, error handling. A bug fix gets a regression test that fails before the fix. Trivial getters, pass-through and configuration need none.
35
+ 4. **Mock at the boundary** (network, filesystem, clock, other services), never an internal collaborator of the unit under test.
36
+ 5. **A unit test uses no real network and no wall-clock time**; fake both.
37
+ 6. **Never wait with a sleep or a fixed delay.** Await the result, the event or the signal.
38
+ 7. **A flaky test is fixed by waiting on the state it races**, never with a retry, a longer timeout or a skip.
84
39
 
85
- ## Red Flags — Stop and re-read this rule if you are thinking:
86
-
87
- | Rationalization | Why it's wrong |
88
- |---|---|
89
- | "The logic is simple, I don't need a test first" | Simplicity is never a reason to skip TDD — the cycle builds confidence, not just test coverage |
90
- | "I'll add tests after to save time" | Tests written after implementation verify what the code does, not what it should do |
91
- | "The tests are flaky, I'll skip them for now" | Flaky tests signal real design problems — fix the flakiness, not the test |
92
- | "All the important logic is covered, a few edge tests can wait" | Untested edge cases are exactly where bugs live |
93
- | "I'll mark it DONE and add tests in a follow-up PR" | STATUS: DONE means done — not "done except for tests" |
94
- | "The test framework setup is complex, I'll just verify manually" | Manual verification is not reproducible and cannot be reviewed by other agents |
40
+ ---
95
41
 
96
- **IRON LAW: AN AGENT THAT SHIPS CODE WITHOUT PASSING TESTS HAS NOT COMPLETED ITS TASK.**
42
+ ## Review severities (shared with reviewers)
43
+
44
+ `review-testing-practices` rates these patterns by this table. Change a row here, never in the reviewer.
45
+
46
+ | Signal | A finding when | Default | Not a finding |
47
+ |---|---|---|---|
48
+ | Test that passes while the behaviour it names is broken | a mutation run or a fixture that never reaches the code shows it | `blocker` | — |
49
+ | Real network or wall-clock dependence in a unit test (Rule 5) | a real call or a time-based assertion is reachable | `major` | a faked clock or a mocked boundary |
50
+ | Sleep or fixed delay for async work (Rule 6) | always | `major` | fake timers advanced by the test |
51
+ | Flake "fixed" by a retry, a longer timeout or a skip (Rule 7) | one of them is added to a flaky test | `major` | a wait on the proving signal |
52
+ | Test deleted, skipped (`.skip`, `xit`, `todo`) or its assertion weakened to go green (Iron law) | the pinned behaviour still exists and no other test covers it | `major`; `blocker` where that behaviour is now broken | the behaviour was removed in the same change |
53
+ | Shared state mutated across tests, or a real filesystem or service hit (Rule 4) | a named order or run breaks it | `major`; else `minor` | — |
54
+ | Internal collaborator mocked instead of the boundary (Rule 4) | always | `minor` | a collaborator that is itself a boundary |
55
+ | New or changed logic with no test (Rule 3) | the diff adds a branch, calculation or error path with no test hunk | `minor`; `major` where an acceptance criterion has no test | a trivial getter, pass-through or config |
56
+ | Bug fix with no regression test (Rule 3) | always | `minor`; `major` where the bug is named high-impact | — |
57
+ | Second test framework, assertion or mocking library (Rule 1) | always | `minor` | — |
58
+ | Unit test outside the code's folder (Rule 2) | always | `info` | an e2e spec |
59
+ | Test on a trivial getter, pass-through or config (Rule 3) | always | `info` | — |