sdlc-framework 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +321 -0
  3. package/bin/install.js +193 -0
  4. package/package.json +39 -0
  5. package/src/commands/close.md +200 -0
  6. package/src/commands/debug.md +124 -0
  7. package/src/commands/fast.md +149 -0
  8. package/src/commands/fix.md +104 -0
  9. package/src/commands/help.md +144 -0
  10. package/src/commands/hotfix.md +99 -0
  11. package/src/commands/impl.md +142 -0
  12. package/src/commands/init.md +93 -0
  13. package/src/commands/milestone.md +136 -0
  14. package/src/commands/pause.md +115 -0
  15. package/src/commands/research.md +136 -0
  16. package/src/commands/resume.md +103 -0
  17. package/src/commands/review.md +195 -0
  18. package/src/commands/spec.md +164 -0
  19. package/src/commands/status.md +118 -0
  20. package/src/commands/verify.md +153 -0
  21. package/src/references/clarification-strategy.md +352 -0
  22. package/src/references/engineering-laws.md +374 -0
  23. package/src/references/loop-phases.md +331 -0
  24. package/src/references/playwright-testing.md +298 -0
  25. package/src/references/prompt-detection.md +264 -0
  26. package/src/references/sub-agent-strategy.md +260 -0
  27. package/src/rules/commands.md +180 -0
  28. package/src/rules/style.md +354 -0
  29. package/src/rules/templates.md +238 -0
  30. package/src/rules/workflows.md +314 -0
  31. package/src/templates/HANDOFF.md +121 -0
  32. package/src/templates/LAWS.md +521 -0
  33. package/src/templates/PROJECT.md +112 -0
  34. package/src/templates/REVIEW.md +145 -0
  35. package/src/templates/ROADMAP.md +101 -0
  36. package/src/templates/SPEC.md +231 -0
  37. package/src/templates/STATE.md +106 -0
  38. package/src/templates/SUMMARY.md +126 -0
  39. package/src/workflows/close-phase.md +189 -0
  40. package/src/workflows/debug-flow.md +302 -0
  41. package/src/workflows/fast-forward.md +340 -0
  42. package/src/workflows/fix-findings.md +235 -0
  43. package/src/workflows/hotfix-flow.md +190 -0
  44. package/src/workflows/impl-phase.md +229 -0
  45. package/src/workflows/init-project.md +249 -0
  46. package/src/workflows/milestone-management.md +169 -0
  47. package/src/workflows/pause-work.md +153 -0
  48. package/src/workflows/research.md +219 -0
  49. package/src/workflows/resume-project.md +159 -0
  50. package/src/workflows/review-phase.md +337 -0
  51. package/src/workflows/spec-phase.md +379 -0
  52. package/src/workflows/transition-phase.md +203 -0
  53. package/src/workflows/verify-phase.md +280 -0
@@ -0,0 +1,337 @@
1
+ <purpose>Perform engineering laws compliance review on all files modified during implementation. Every law configured in LAWS.md is checked at its configured severity. Blockers must be fixed before proceeding to close.</purpose>
2
+ <when_to_use>Run after /sdlc:verify passes. STATE.md must show loop_position = VERIFY ✓ and next_required_action = /sdlc:review.</when_to_use>
3
+ <required_reading>.sdlc/STATE.md, the current SPEC.md (for modified files list), .sdlc/LAWS.md (for law configuration), all modified files</required_reading>
4
+ <loop_context>
5
+ expected_phase: REVIEW (active)
6
+ prior_phase: VERIFY ✓
7
+ next_phase: CLOSE
8
+ </loop_context>
9
+ <process>
10
+
11
+ <step name="validate_state" priority="first">
12
+ Read .sdlc/STATE.md.
13
+
14
+ CHECK: loop_position must be "VERIFY ✓"
15
+ CHECK: next_required_action must be "/sdlc:review"
16
+
17
+ IF EITHER CHECK FAILS: STOP. Display: "Cannot review. State requires: {next_required_action}. Run that first."
18
+
19
+ WHY: Reviewing before verification means reviewing code that might not even work. Fix it first, then review it.
20
+ </step>
21
+
22
+ <step name="load_review_context" priority="second">
23
+ Read .sdlc/LAWS.md. Build a lookup of law to severity:
24
+ ```
25
+ SOLID: ERROR
26
+ DRY: ERROR
27
+ YAGNI: ERROR
28
+ Clean Code: ERROR
29
+ Security: ERROR
30
+ Testing: ERROR
31
+ Error Handling: ERROR
32
+ Null Safety: WARN
33
+ Type Safety: WARN
34
+ File Size: WARN
35
+ ```
36
+
37
+ Read the SPEC.md. Extract:
38
+ - files_modified (list of all files changed during implementation)
39
+ - files_created (list of all new files)
40
+ - boundaries (what was NOT supposed to change)
41
+ - acceptance criteria (to verify YAGNI — is all code justified by an AC?)
42
+
43
+ Combine files_modified and files_created into a single review list.
44
+
45
+ IF the review list is empty: STOP. Display: "No files to review. The spec lists no modified files. Re-run /sdlc:impl to update the file list."
46
+
47
+ WHY: The review is only as good as the file list. Missing files means missing violations.
48
+ </step>
49
+
50
+ <step name="read_all_modified_files" priority="third">
51
+ Read every file in the review list.
52
+
53
+ For each file, note:
54
+ - Total line count
55
+ - Language (infer from extension)
56
+ - Module/directory it belongs to
57
+
58
+ IF a file in the list does not exist: Flag as WARNING — "File listed in spec but not found: {path}. It may have been renamed or deleted during implementation."
59
+
60
+ WHY: You must read the code to review it. Reading all files upfront provides full context — a violation in file A might be caused by a pattern in file B.
61
+ </step>
62
+
63
+ <step name="check_solid" priority="fourth">
64
+ FOR EACH FILE, check SOLID principles. Record findings at the severity configured for SOLID in LAWS.md.
65
+
66
+ SINGLE RESPONSIBILITY:
67
+ - Does the file/class/module do ONE thing?
68
+ - Red flags: class name contains "And" (e.g., "UserAndPermissionService"), file has multiple unrelated exports, service method that does CRUD + notification + logging
69
+ - Check: count the number of "reasons to change." If more than one domain concept would cause changes, SRP is violated.
70
+ - Finding format: "{file}:{line} — SRP violation: {class/function} handles both {responsibility-1} and {responsibility-2}"
71
+
72
+ OPEN/CLOSED:
73
+ - Can the code be extended without modifying existing code?
74
+ - Red flags: switch/case on type strings that must grow, if/else chains for new variants, hardcoded lists of handlers
75
+ - Check: look for switch statements or if/else chains that dispatch based on a type or category. These should use polymorphism or strategy pattern.
76
+ - Finding format: "{file}:{line} — OCP violation: Adding a new {type} requires modifying this {switch/if-chain}"
77
+
78
+ LISKOV SUBSTITUTION:
79
+ - If subtypes exist, are they substitutable for their parent?
80
+ - Red flags: overridden methods that throw "not implemented", subclass that ignores parent contract
81
+ - Check: look for class inheritance where child behavior contradicts parent interface
82
+
83
+ INTERFACE SEGREGATION:
84
+ - Are interfaces minimal and focused?
85
+ - Red flags: interface with 10+ methods, classes that implement interface methods as no-ops
86
+ - Check: look for large interfaces. If implementors leave methods empty, the interface is too fat.
87
+
88
+ DEPENDENCY INVERSION:
89
+ - Do high-level modules depend on abstractions, not concretions?
90
+ - Red flags: service directly instantiating another service with `new`, importing concrete database driver in business logic
91
+ - Check: constructor parameters should be interfaces/abstract classes, not concrete implementations
92
+
93
+ WHY: SOLID violations create rigid, fragile code that resists change. Catching them now prevents expensive refactors later.
94
+ </step>
95
+
96
+ <step name="check_dry" priority="fifth">
97
+ Search for duplicate logic across ALL modified files AND the broader codebase.
98
+
99
+ WITHIN MODIFIED FILES:
100
+ - Look for 3+ lines of identical or near-identical logic appearing in multiple places
101
+ - Look for copy-pasted code blocks with only variable names changed
102
+ - Look for repeated patterns (same sequence of operations)
103
+
104
+ ACROSS THE CODEBASE:
105
+ - For each new function/method created, search the codebase for existing functions that do the same thing
106
+ - For each utility created, search for existing utilities with similar names or signatures
107
+ - For each pattern implemented, search for the same pattern elsewhere
108
+
109
+ HOW TO SEARCH:
110
+ - Use Grep to search for key function names, variable names, and distinctive code patterns
111
+ - Search for imports — if a utility exists but was not imported, DRY is violated
112
+
113
+ Finding format: "{file}:{line} — DRY violation: This logic duplicates {other-file}:{line}. Extract to shared utility or reuse existing {function-name}."
114
+
115
+ WHY: Duplicate logic means duplicate bugs. Fix one copy, forget the other, ship a regression. DRY is the most common violation and the easiest to prevent.
116
+ </step>
117
+
118
+ <step name="check_yagni" priority="sixth">
119
+ Compare every piece of new code against the SPEC acceptance criteria.
120
+
121
+ FOR EACH NEW FUNCTION/METHOD/CLASS:
122
+ - Is it required by at least one AC?
123
+ - Is it required as infrastructure for an AC (e.g., a utility function used by AC-related code)?
124
+ - Or is it speculative — "we might need this later"?
125
+
126
+ Red flags:
127
+ - Functions with zero callers (dead code)
128
+ - Parameters that are always passed the same value (unused flexibility)
129
+ - Abstract base classes with only one implementation
130
+ - Configuration options that no AC exercises
131
+ - "TODO: use this later" comments
132
+
133
+ Finding format: "{file}:{line} — YAGNI violation: {function/class} is not required by any AC. Remove or justify."
134
+
135
+ WHY: Speculative code has maintenance cost but zero current value. It rots, breaks, and confuses future developers who think it is used.
136
+ </step>
137
+
138
+ <step name="check_clean_code" priority="seventh">
139
+ FOR EACH FUNCTION/METHOD in modified files:
140
+
141
+ FUNCTION LENGTH:
142
+ - Count lines (excluding blank lines and comments)
143
+ - If > 40 lines: BLOCKER (at configured severity)
144
+ - Finding: "{file}:{line} — Function '{name}' is {N} lines (max 40). Extract helper functions."
145
+
146
+ PARAMETER COUNT:
147
+ - Count parameters in signature
148
+ - If > 3 parameters: BLOCKER
149
+ - Finding: "{file}:{line} — Function '{name}' has {N} parameters (max 3). Group into an options/config interface."
150
+
151
+ NESTING DEPTH:
152
+ - Count maximum indentation levels within function body
153
+ - If > 3 levels: BLOCKER
154
+ - Finding: "{file}:{line} — Nesting depth {N} (max 3). Use guard clauses and early returns."
155
+
156
+ NAMING QUALITY:
157
+ - Single-letter variables (except loop counters i, j, k): WARNING
158
+ - Generic names (data, info, result, temp, stuff, thing): WARNING
159
+ - Abbreviations that are not universally understood: WARNING
160
+ - Boolean variables not prefixed with is/has/can/should: INFO
161
+ - Finding: "{file}:{line} — Name '{name}' is unclear. Rename to describe what it does, not what it is."
162
+
163
+ CONDITIONAL STYLE:
164
+ - Nested if/else > 2 levels: recommend guard clauses
165
+ - Ternary chains (a ? b : c ? d : e): BLOCKER
166
+ - Nested ternaries: BLOCKER
167
+ - Finding: "{file}:{line} — Nested conditional. Convert to guard clause with early return."
168
+
169
+ WHY: Clean code is readable code. Readable code has fewer bugs, is easier to maintain, and is faster to onboard new developers.
170
+ </step>
171
+
172
+ <step name="check_security" priority="eighth">
173
+ FOR EACH FILE in the review list:
174
+
175
+ HARDCODED SECRETS:
176
+ - Search for patterns: API_KEY, SECRET, PASSWORD, TOKEN, PRIVATE_KEY followed by = and a string literal
177
+ - Search for base64-encoded strings that look like keys (long alphanumeric strings)
178
+ - Search for URLs with embedded credentials (protocol://user:pass@host)
179
+ - Finding: "{file}:{line} — SECURITY: Hardcoded secret detected. Move to environment variable."
180
+
181
+ SQL INJECTION:
182
+ - Search for string concatenation or template literals in SQL queries
183
+ - Patterns: "SELECT ... " + variable, template literal SELECT with interpolated variable
184
+ - Finding: "{file}:{line} — SECURITY: SQL injection risk. Use parameterized query."
185
+
186
+ XSS (Cross-Site Scripting):
187
+ - Search for user input rendered in HTML without sanitization
188
+ - Patterns: innerHTML assignment with user data, unsafe HTML rendering with unsanitized data
189
+ - All user-provided content MUST be sanitized using a dedicated HTML sanitizer library (such as DOMPurify) before rendering
190
+ - Finding: "{file}:{line} — SECURITY: XSS risk. Sanitize user input with a dedicated sanitizer library before rendering."
191
+
192
+ DIRECTORY TRAVERSAL:
193
+ - Search for file path construction using user input without sanitization
194
+ - Patterns: path.join(userInput), fs.readFile(userInput)
195
+ - Finding: "{file}:{line} — SECURITY: Directory traversal risk. Validate and sanitize file path."
196
+
197
+ INPUT VALIDATION:
198
+ - Check system boundary functions (controllers, API handlers, CLI parsers)
199
+ - Are all inputs validated before processing?
200
+ - Finding: "{file}:{line} — SECURITY: No input validation at system boundary."
201
+
202
+ WHY: Security vulnerabilities are the highest-cost bugs. A single SQL injection or leaked secret can compromise an entire system. Catching these in review is the last line of defense.
203
+ </step>
204
+
205
+ <step name="check_testing" priority="ninth">
206
+ FOR EACH NEW BEHAVIOR introduced in modified files:
207
+
208
+ CHECK: Does a corresponding test exist?
209
+ - Search for test files: {filename}.test.{ext}, {filename}.spec.{ext}
210
+ - Search within test files for test cases that exercise the new behavior
211
+
212
+ IF NEW BEHAVIOR HAS NO TEST:
213
+ - Finding: "{file}:{line} — TESTING: New {function/method/endpoint} has no test. Add test to {expected-test-file}."
214
+
215
+ IF TESTS EXIST, check quality:
216
+ - Are assertions meaningful? (not just "expect(result).toBeDefined()" — that passes for any non-undefined value)
217
+ - Are edge cases covered? (empty input, null, boundary values)
218
+ - Are error cases tested? (what happens when it fails)
219
+ - Finding: "{test-file}:{line} — TESTING: Assertion is too weak. Test the specific expected value, not just existence."
220
+
221
+ WHY: Untested code is unverified code. It might work today and break tomorrow with no warning. Tests are the safety net.
222
+ </step>
223
+
224
+ <step name="check_error_handling" priority="tenth">
225
+ FOR EACH TRY/CATCH block in modified files:
226
+
227
+ EMPTY CATCH BLOCKS:
228
+ - Pattern: catch block with empty body
229
+ - This is ALWAYS a BLOCKER regardless of severity config
230
+ - Finding: "{file}:{line} — ERROR HANDLING: Empty catch block. Log the error or rethrow."
231
+
232
+ GENERIC ERROR THROWS:
233
+ - Pattern: throw new Error("something went wrong")
234
+ - Should use domain-specific exceptions
235
+ - Finding: "{file}:{line} — ERROR HANDLING: Generic Error. Use a domain-specific exception class."
236
+
237
+ SWALLOWED EXCEPTIONS:
238
+ - Pattern: catch block that does not log, rethrow, or return an error indicator
239
+ - Finding: "{file}:{line} — ERROR HANDLING: Exception caught but not logged or rethrown. This hides failures."
240
+
241
+ MISSING ERROR HANDLING:
242
+ - Async operations without try/catch or .catch()
243
+ - File operations without error handling
244
+ - Network requests without timeout or error handling
245
+ - Finding: "{file}:{line} — ERROR HANDLING: No error handling for {operation}. Add try/catch or .catch()."
246
+
247
+ WHY: Swallowed exceptions are invisible bugs. The system fails silently, data corrupts quietly, and debugging becomes archaeology.
248
+ </step>
249
+
250
+ <step name="generate_review_report" priority="eleventh">
251
+ Compile all findings into REVIEW.md at .sdlc/phases/{current_phase}/{current_plan}-REVIEW.md.
252
+
253
+ Format:
254
+ ```markdown
255
+ # Review: Plan {plan-number}
256
+
257
+ ## Summary
258
+ - **Blockers**: {count}
259
+ - **Warnings**: {count}
260
+ - **Info**: {count}
261
+ - **Files reviewed**: {count}
262
+
263
+ ## Findings by File
264
+
265
+ ### {file-path}
266
+ | # | Law | Severity | Line | Finding |
267
+ |---|-----|----------|------|---------|
268
+ | 1 | DRY | ERROR | 42 | Duplicates logic from utils/format.ts:15 |
269
+ | 2 | Clean Code | ERROR | 78 | Function 'processData' is 67 lines (max 40) |
270
+ | 3 | Naming | WARN | 12 | Variable 'x' is unclear |
271
+
272
+ ### {next-file-path}
273
+ ...
274
+
275
+ ## Blocker Details
276
+ For each blocker, explain:
277
+ - What the violation is
278
+ - Where it is (file:line)
279
+ - How to fix it (specific, actionable guidance)
280
+ - What pattern to follow (reference existing code)
281
+
282
+ ## Clean Files
283
+ {List files with zero findings — positive reinforcement}
284
+ ```
285
+
286
+ Map law severity: use the severity from LAWS.md.
287
+ - ERROR severity law violation maps to BLOCKER
288
+ - WARN severity law violation maps to WARNING
289
+ - INFO severity law violation maps to INFO
290
+
291
+ WHY: The report is structured for action. Blockers are at the top with fix instructions. The developer knows exactly what to do without re-analyzing the code.
292
+ </step>
293
+
294
+ <step name="handle_results" priority="twelfth">
295
+ IF BLOCKERS EXIST (count > 0):
296
+ Do NOT update loop_position. Keep at "VERIFY ✓".
297
+ Set next_required_action to "/sdlc:review" (stay in review after fixes).
298
+
299
+ Display:
300
+ ```
301
+ Review FAILED: {blocker_count} blockers found.
302
+
303
+ Blockers:
304
+ 1. {file}:{line} — {finding} — Fix: {how to fix}
305
+ 2. {file}:{line} — {finding} — Fix: {how to fix}
306
+
307
+ Warnings: {count} (non-blocking, but should fix)
308
+ Info: {count}
309
+
310
+ Run /sdlc:fix to systematically fix all blockers, then re-review automatically.
311
+ Report: .sdlc/phases/{phase}/{plan}-REVIEW.md
312
+ ```
313
+
314
+ IF NO BLOCKERS (only warnings and info, or clean):
315
+ Update .sdlc/STATE.md:
316
+ - loop_position: REVIEW ✓
317
+ - next_required_action: /sdlc:close
318
+ - Add history entry: "{timestamp} | review | Passed. {warn_count} warnings, {info_count} info."
319
+
320
+ Display:
321
+ ```
322
+ Review PASSED: 0 blockers.
323
+
324
+ Warnings: {count} (consider fixing)
325
+ Info: {count}
326
+ Files reviewed: {count}
327
+
328
+ Report: .sdlc/phases/{phase}/{plan}-REVIEW.md
329
+
330
+ NEXT ACTION REQUIRED: /sdlc:close
331
+ Run /sdlc:close to close this loop.
332
+ ```
333
+
334
+ WHY: Blockers are the gate. They enforce engineering standards. Warnings are advisory — the team can choose to address them. The gate prevents shipping code that violates critical laws.
335
+ </step>
336
+
337
+ </process>