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,190 @@
1
+ <purpose>Emergency fix workflow for critical production issues. Skips spec ceremony but enforces full verification and review. Tracked as a decimal sub-phase (e.g., 02.1) to maintain audit trail without disrupting the main phase sequence.</purpose>
2
+ <when_to_use>Use ONLY for critical issues: production down, data corruption, security vulnerability, blocking bug affecting users NOW. For non-critical bugs, use /sdlc:debug instead.</when_to_use>
3
+ <required_reading>.sdlc/STATE.md, .sdlc/PROJECT.md, .sdlc/LAWS.md</required_reading>
4
+ <loop_context>
5
+ expected_phase: HOTFIX (emergency, interrupts main loop)
6
+ prior_phase: any (hotfix can interrupt at any point)
7
+ next_phase: VERIFY (hotfix still goes through verify and review)
8
+ </loop_context>
9
+ <process>
10
+
11
+ <step name="accept_critical_issue" priority="first">
12
+ Receive the critical issue description.
13
+
14
+ Ask the user:
15
+ Question 1: "What is broken? (specific symptom)"
16
+ Question 2: "What is the impact? (who is affected, how badly)"
17
+ Question 3: "When did it start? (recent deploy, config change, external event)"
18
+
19
+ CLASSIFY SEVERITY:
20
+ - P0 (system down): entire service or critical path is unavailable
21
+ - P1 (data risk): data corruption, security breach, or data loss occurring
22
+ - P2 (major feature broken): core feature broken but system is up
23
+
24
+ IF severity is not P0 or P1: Display: "This does not appear critical. Consider using /sdlc:debug for structured debugging or /sdlc:fast for a quick fix."
25
+ Let the user override if they insist.
26
+
27
+ Save the current STATE.md position — hotfix must restore it when done.
28
+
29
+ WHY: Hotfix workflow trades ceremony for speed. That trade-off is only justified for critical issues. Overusing hotfix leads to unreviewed, untested changes accumulating.
30
+ </step>
31
+
32
+ <step name="create_inline_spec" priority="second">
33
+ Create a lightweight inline spec (no file — kept in memory for speed).
34
+
35
+ Inline spec:
36
+ ```
37
+ Hotfix: {title}
38
+ Severity: {P0|P1|P2}
39
+ Symptom: {what is broken}
40
+ Expected: {what should happen}
41
+ Files likely affected: {from initial analysis}
42
+ Acceptance criteria:
43
+ AC-1: GIVEN the fix is deployed WHEN {trigger action} THEN {correct behavior}
44
+ AC-2: GIVEN the fix is deployed WHEN regression tests run THEN all pass
45
+ Boundary: fix ONLY the critical issue. No refactoring. No cleanup. No "while I am here" changes.
46
+ ```
47
+
48
+ Display the inline spec to the user. Do NOT wait for approval — in an emergency, speed matters. But DO display it so the user can object if the scope is wrong.
49
+
50
+ WHY: Even emergencies get a spec — just a minimal one. Without it, the fix scope creeps and the hotfix becomes a feature.
51
+ </step>
52
+
53
+ <step name="fix_directly" priority="third">
54
+ Fix the issue directly. No sub-agents — hotfix is single-threaded for speed and control.
55
+
56
+ PROCESS:
57
+ 1. Read the relevant files identified in the inline spec
58
+ 2. If root cause is not immediately obvious, use binary search isolation (same as debug-flow)
59
+ 3. Apply the MINIMAL fix — change as few lines as possible
60
+ 4. Do NOT refactor. Do NOT clean up. Do NOT improve. Fix the bug ONLY.
61
+ 5. Add a regression test for the specific failure scenario
62
+ 6. Run the regression test — it must pass
63
+
64
+ RULES FOR HOTFIX CODE:
65
+ - Engineering laws still apply (no empty catch blocks, no hardcoded secrets)
66
+ - But scope is strictly limited to the fix
67
+ - Mark any technical debt created by the minimal fix with a TODO comment:
68
+ "TODO(hotfix-{date}): Clean up in next regular loop"
69
+ - These TODOs become tasks in the next spec
70
+
71
+ Record:
72
+ ```
73
+ Files modified: {list}
74
+ Lines changed: {count}
75
+ Root cause: {brief explanation}
76
+ Technical debt introduced: {yes/no — if yes, describe}
77
+ ```
78
+
79
+ WHY: Hotfixes are surgical. Minimal changes minimize risk of introducing new bugs. The TODO ensures debt is tracked and addressed, not forgotten.
80
+ </step>
81
+
82
+ <step name="full_verification" priority="fourth">
83
+ Run the SAME verification as verify-phase. No shortcuts.
84
+
85
+ FOR EACH AC in the inline spec:
86
+ 1. Execute the verification (Playwright for UI, curl for API, test suite for logic)
87
+ 2. Record PASS or FAIL with evidence
88
+
89
+ Additionally:
90
+ - Run the FULL test suite (not just related tests)
91
+ - A hotfix that breaks something else is worse than the original bug
92
+
93
+ IF ANY VERIFICATION FAILS:
94
+ Display: "Hotfix verification failed: {details}. The fix is incomplete or introduced a regression."
95
+ Return to fix step.
96
+
97
+ IF ALL PASS:
98
+ Proceed to review.
99
+
100
+ WHY: Hotfixes are the riskiest changes — rushed, minimal context, high pressure. Full verification is non-negotiable precisely because the process is compressed.
101
+ </step>
102
+
103
+ <step name="full_review" priority="fifth">
104
+ Run the SAME review as review-phase. No shortcuts.
105
+
106
+ Check all modified files against engineering laws.
107
+
108
+ The review is likely to find:
109
+ - WARN: minimal fix may not follow ideal patterns (acceptable for hotfix)
110
+ - INFO: TODO comments for technical debt (expected)
111
+
112
+ BUT BLOCKERS STILL BLOCK:
113
+ - Hardcoded secrets: BLOCKER (no exceptions, not even in emergencies)
114
+ - Empty catch blocks: BLOCKER
115
+ - SQL injection: BLOCKER
116
+
117
+ IF BLOCKERS: Fix them. Even in an emergency, security and error handling are non-negotiable.
118
+ IF CLEAN or WARNINGS ONLY: Proceed.
119
+
120
+ WHY: Security violations in hotfixes are especially dangerous because hotfixes often get deployed without the usual deployment review.
121
+ </step>
122
+
123
+ <step name="record_and_update_state" priority="sixth">
124
+ Create the hotfix record.
125
+
126
+ Determine the hotfix number:
127
+ - Read current phase number (e.g., "02")
128
+ - Count existing hotfixes: look for HOTFIX-*.md in the phase directory
129
+ - Hotfix number = {phase}.{hotfix-count + 1} (e.g., "02.1", "02.2")
130
+
131
+ Create .sdlc/phases/{current_phase}/HOTFIX-{number}-SUMMARY.md:
132
+ ```markdown
133
+ # Hotfix {number}: {title}
134
+
135
+ ## Issue
136
+ - **Severity**: {P0|P1|P2}
137
+ - **Symptom**: {what was broken}
138
+ - **Impact**: {who was affected}
139
+ - **Duration**: {how long the issue lasted, if known}
140
+
141
+ ## Root Cause
142
+ {Brief explanation}
143
+
144
+ ## Fix
145
+ - **Files modified**: {list}
146
+ - **Approach**: {what was changed}
147
+ - **Lines changed**: {count}
148
+
149
+ ## Verification
150
+ | AC | Status | Evidence |
151
+ |----|--------|----------|
152
+ | AC-1 | PASS | {evidence} |
153
+ | AC-2 | PASS | {evidence} |
154
+
155
+ ## Technical Debt
156
+ - {TODO items introduced by the minimal fix}
157
+ - These should be addressed in the next regular /sdlc:spec loop
158
+
159
+ ## Review
160
+ - Blockers: 0
161
+ - Warnings: {count}
162
+ ```
163
+
164
+ Update .sdlc/STATE.md:
165
+ - RESTORE the prior state (hotfix does not advance the main loop)
166
+ - Add history entry: "{timestamp} | hotfix | {severity}: {title}. {N} files modified. Debt: {yes/no}."
167
+
168
+ Update .sdlc/ROADMAP.md:
169
+ - Add a note under the current phase: "Hotfix {number}: {title} ({date})"
170
+
171
+ Display:
172
+ ```
173
+ Hotfix applied and verified.
174
+
175
+ Hotfix: {number}
176
+ Severity: {severity}
177
+ Files modified: {N}
178
+ Verification: PASSED
179
+ Review: PASSED ({N} warnings)
180
+ Technical debt: {description or "none"}
181
+
182
+ Record: .sdlc/phases/{phase}/HOTFIX-{number}-SUMMARY.md
183
+
184
+ State restored. Continue with: {prior next_required_action}
185
+ ```
186
+
187
+ WHY: Hotfixes are recorded separately from regular plans so they do not disrupt the plan numbering. The decimal notation (02.1) makes it clear this was an emergency intervention, not planned work.
188
+ </step>
189
+
190
+ </process>
@@ -0,0 +1,229 @@
1
+ <purpose>Execute the specification through sub-agent driven parallel implementation. Each task from the spec becomes an independent agent with full context, engineering laws, and boundaries. Tasks run in dependency-ordered waves.</purpose>
2
+ <when_to_use>Run after /sdlc:spec completes. STATE.md must show loop_position = SPEC ✓ and next_required_action = /sdlc:impl.</when_to_use>
3
+ <required_reading>.sdlc/STATE.md, the current SPEC.md, .sdlc/LAWS.md, .sdlc/PROJECT.md</required_reading>
4
+ <loop_context>
5
+ expected_phase: IMPL (active)
6
+ prior_phase: SPEC ✓
7
+ next_phase: VERIFY
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 "SPEC ✓"
15
+ CHECK: next_required_action must be "/sdlc:impl"
16
+
17
+ IF EITHER CHECK FAILS: STOP. Display: "Cannot start implementation. State requires: {next_required_action}. Run that first."
18
+
19
+ Extract from STATE.md:
20
+ - current_phase (e.g., "01-setup")
21
+ - current_plan (e.g., "01")
22
+
23
+ WHY: Running impl without a spec means building without a blueprint. The code will not match requirements, verification will fail, and the loop breaks.
24
+ </step>
25
+
26
+ <step name="load_spec" priority="second">
27
+ Construct the spec path: .sdlc/phases/{current_phase}/{current_plan}-SPEC.md
28
+
29
+ Read the SPEC.md file. Parse:
30
+
31
+ FROM YAML FRONTMATTER:
32
+ - task_graph.parallel_groups → array of arrays (wave structure)
33
+ - task_graph.dependencies → map of task → [dependency tasks]
34
+ - files_modified → list (may be empty, will be populated during impl)
35
+ - files_created → list (may be empty, will be populated during impl)
36
+
37
+ FROM MARKDOWN BODY:
38
+ - Each task: name, action, files, verification, done criteria, complexity
39
+ - Acceptance criteria (for context — verify phase handles these)
40
+ - Boundaries (CRITICAL — pass to every agent)
41
+ - Required patterns (CRITICAL — pass to every agent)
42
+
43
+ IF THE SPEC IS MISSING OR MALFORMED: STOP. Display: "Spec file not found or invalid: {path}. Run /sdlc:spec to create it."
44
+
45
+ WHY: The spec is the contract. Every agent works from this contract. If the contract is wrong, all work is wrong.
46
+ </step>
47
+
48
+ <step name="load_engineering_laws" priority="third">
49
+ Read .sdlc/LAWS.md. Extract all laws with severity ERROR or WARN.
50
+
51
+ Build a compact law summary string to pass to each agent. Format:
52
+
53
+ ```
54
+ ENGINEERING LAWS (violations will be caught in review):
55
+ [ERROR] DRY: Search for existing patterns before creating new ones. No duplicate logic.
56
+ [ERROR] Clean Code: Max 40 lines/function, max 3 params, max 3 nesting levels.
57
+ [ERROR] Security: No hardcoded secrets. Validate all input. Parameterized queries only.
58
+ [ERROR] Testing: New behavior requires new tests.
59
+ [ERROR] Error Handling: No empty catch blocks. No swallowed exceptions.
60
+ [WARN] Null Safety: No non-null assertions. Handle null/undefined explicitly.
61
+ [WARN] Type Safety: Named types for complex shapes.
62
+ ```
63
+
64
+ Only include laws at ERROR and WARN severity. Skip INFO — those are review-only.
65
+
66
+ WHY: Agents that do not know the laws will violate them. Passing laws upfront prevents rework during review.
67
+ </step>
68
+
69
+ <step name="build_execution_plan" priority="fourth">
70
+ From the parsed task_graph, build the wave execution plan:
71
+
72
+ Wave 1: tasks from parallel_groups[0] — these have NO dependencies
73
+ Wave 2: tasks from parallel_groups[1] — these depend on Wave 1 completion
74
+ Wave N: tasks from parallel_groups[N-1]
75
+
76
+ VALIDATE the dependency graph:
77
+ - Every task referenced in dependencies must exist in the task list
78
+ - No circular dependencies (A depends on B, B depends on A)
79
+ - Every task must appear in exactly one parallel_group
80
+
81
+ IF VALIDATION FAILS: STOP. Display: "Spec has invalid task graph: {error}. Fix the spec and re-run /sdlc:spec."
82
+
83
+ Display the execution plan:
84
+ ```
85
+ Execution Plan:
86
+ Wave 1 (parallel): {task-1}, {task-2}
87
+ Wave 2 (after wave 1): {task-3}
88
+ Total waves: {N}
89
+ Total tasks: {N}
90
+ ```
91
+
92
+ WHY: Validating before execution prevents wasted agent time. An invalid graph causes agents to block forever or produce conflicting outputs.
93
+ </step>
94
+
95
+ <step name="execute_wave" priority="fifth">
96
+ FOR EACH WAVE (starting with Wave 1):
97
+
98
+ A. SPAWN AGENTS FOR ALL TASKS IN THIS WAVE:
99
+ For each task in the wave, spawn an agent with run_in_background: true.
100
+
101
+ Each agent instruction MUST include ALL of the following (no shortcuts):
102
+
103
+ ```
104
+ You are implementing a single task as part of a larger plan.
105
+
106
+ PROJECT CONTEXT:
107
+ {from PROJECT.md: tech stack, conventions, architecture}
108
+
109
+ YOUR TASK:
110
+ Name: {task-name}
111
+ Action: {detailed action description from spec}
112
+ Files to modify: {file list}
113
+ Files to create: {file list, if any}
114
+ Done criteria: {observable outcome}
115
+
116
+ ENGINEERING LAWS (MUST FOLLOW):
117
+ {compact law summary from step 3}
118
+
119
+ BOUNDARIES (DO NOT VIOLATE):
120
+ - DO NOT modify any file not listed in "Files to modify"
121
+ - DO NOT change behavior outside your task scope
122
+ {boundaries from spec}
123
+
124
+ REQUIRED PATTERNS:
125
+ {patterns from spec}
126
+
127
+ BEFORE WRITING ANY CODE:
128
+ 1. Read every file you plan to modify — understand existing patterns
129
+ 2. Search the codebase for similar implementations — reuse, do not reinvent
130
+ 3. Check for existing utilities, helpers, or base classes that do what you need
131
+
132
+ AFTER WRITING CODE:
133
+ 1. Verify your changes compile/parse (no syntax errors)
134
+ 2. Verify your done criteria is met
135
+ 3. List all files you modified or created
136
+ ```
137
+
138
+ B. WAIT FOR ALL AGENTS IN THIS WAVE TO COMPLETE.
139
+ Do NOT proceed to the next wave until every agent in the current wave has returned.
140
+
141
+ C. REVIEW WAVE RESULTS:
142
+ For each agent result:
143
+ - Did it complete successfully?
144
+ - Did it list modified files?
145
+ - Did it report any issues or blockers?
146
+
147
+ IF ANY AGENT FAILED:
148
+ - Display: "Agent for task '{task-name}' failed: {error}"
149
+ - Display the failure details
150
+ - STOP. Do NOT proceed to next wave.
151
+ - Ask user: "How do you want to proceed? Options:
152
+ A. Fix the issue and re-run /sdlc:impl (recommended — restarts from this wave)
153
+ B. Skip this task and continue (risky — dependent tasks may fail)
154
+ C. Abort implementation and return to spec"
155
+
156
+ IF ALL AGENTS SUCCEEDED:
157
+ - Collect all modified/created file lists
158
+ - Proceed to next wave
159
+
160
+ D. REPEAT for each subsequent wave.
161
+
162
+ WHY: Wave-based execution respects dependencies while maximizing parallelism. Stopping on failure prevents cascading errors where later agents build on broken foundations.
163
+ </step>
164
+
165
+ <step name="collect_modified_files" priority="sixth">
166
+ After all waves complete successfully, collect the union of all files modified or created by all agents.
167
+
168
+ Deduplicate the list. Sort alphabetically.
169
+
170
+ Update the SPEC.md frontmatter:
171
+ - files_modified: {updated list}
172
+ - files_created: {updated list}
173
+
174
+ WHY: The review phase needs to know exactly which files to inspect. Missing a file means the review skips it, and law violations slip through.
175
+ </step>
176
+
177
+ <step name="smoke_test" priority="seventh">
178
+ Run a quick smoke test to verify nothing is fundamentally broken.
179
+
180
+ Based on the tech stack from PROJECT.md:
181
+
182
+ IF package.json exists with "build" script:
183
+ Run: npm run build (or bun run build, etc.)
184
+ CHECK: exit code 0. If non-zero, display build errors.
185
+
186
+ IF package.json exists with "lint" script:
187
+ Run: npm run lint (or bun run lint, etc.)
188
+ CHECK: exit code 0. If non-zero, display lint errors.
189
+
190
+ IF tsconfig.json exists:
191
+ Run: npx tsc --noEmit
192
+ CHECK: exit code 0. If non-zero, display type errors.
193
+
194
+ IF ANY SMOKE TEST FAILS:
195
+ - Display the errors
196
+ - Do NOT update state to IMPL ✓
197
+ - Display: "Smoke test failed. Fix the errors and re-run /sdlc:impl."
198
+ - The user must fix and re-run. Do not auto-fix — the user needs to see what broke.
199
+
200
+ IF ALL SMOKE TESTS PASS:
201
+ - Display: "Smoke tests passed (build, lint, types)."
202
+
203
+ WHY: Catching build/lint/type errors now is cheap. Catching them during verify or review wastes an entire loop iteration.
204
+ </step>
205
+
206
+ <step name="update_state" priority="eighth">
207
+ Update .sdlc/STATE.md:
208
+ - loop_position: IMPL ✓
209
+ - next_required_action: /sdlc:verify
210
+ - Add history entry: "{timestamp} | impl | Plan {N} implemented. {N} tasks across {N} waves. {N} files modified."
211
+
212
+ Display to user:
213
+ ```
214
+ Implementation complete.
215
+
216
+ Tasks completed: {N}/{N}
217
+ Waves executed: {N}
218
+ Files modified: {list}
219
+ Files created: {list}
220
+ Smoke tests: PASSED
221
+
222
+ NEXT ACTION REQUIRED: /sdlc:verify
223
+ Run /sdlc:verify to test acceptance criteria.
224
+ ```
225
+
226
+ WHY: Clear reporting lets the user assess what happened before deciding to proceed. The forcing function moves them to verification.
227
+ </step>
228
+
229
+ </process>
@@ -0,0 +1,249 @@
1
+ <purpose>Initialize the .sdlc/ directory structure and project configuration files. This is the entry point for any new SDLC-managed project — nothing else works until this runs.</purpose>
2
+ <when_to_use>Run this ONCE at the start of a new project, or when adopting SDLC on an existing codebase. If .sdlc/ already exists, this workflow warns before overwriting.</when_to_use>
3
+ <required_reading>None — this is the bootstrap workflow. No prior state exists.</required_reading>
4
+ <loop_context>
5
+ expected_phase: none (pre-loop)
6
+ prior_phase: none
7
+ next_phase: SPEC (the user must run /sdlc:spec after init)
8
+ </loop_context>
9
+ <process>
10
+
11
+ <step name="check_existing_sdlc" priority="first">
12
+ Check if a .sdlc/ directory already exists in the project root.
13
+
14
+ Run: ls -la .sdlc/ 2>/dev/null
15
+
16
+ IF .sdlc/ EXISTS:
17
+ - Display warning: "WARNING: .sdlc/ directory already exists. Re-initializing will overwrite STATE.md and may lose progress."
18
+ - Ask the user: "Do you want to continue? This will reset your SDLC state. (yes/no)"
19
+ - If user says no, STOP. Display: "Init cancelled. Existing .sdlc/ preserved."
20
+ - If user says yes, proceed but PRESERVE existing phases/ directory content (do not delete completed work).
21
+
22
+ IF .sdlc/ DOES NOT EXIST:
23
+ - Proceed without warning.
24
+
25
+ WHY: Preventing accidental data loss is critical. A re-init should never silently destroy completed specs, reviews, or summaries.
26
+ </step>
27
+
28
+ <step name="gather_project_info" priority="second">
29
+ Ask the user these questions. Do NOT guess or assume defaults.
30
+
31
+ Question 1: "What is the project name?"
32
+ - This becomes the title in PROJECT.md
33
+ - Use kebab-case for directory references (e.g., "My App" → "my-app")
34
+
35
+ Question 2: "Describe the project in 1-2 sentences. What does it do?"
36
+ - This becomes the description in PROJECT.md
37
+
38
+ Question 3: "What is the tech stack?"
39
+ - Ask specifically: language, framework, database, testing framework, package manager
40
+ - Example prompt: "Tech stack? (e.g., TypeScript, NestJS, PostgreSQL, Jest, bun)"
41
+
42
+ Question 4: "Is this an existing codebase or greenfield (starting from scratch)?"
43
+ - If EXISTING: proceed to auto-detection step
44
+ - If GREENFIELD: skip auto-detection, use user-provided stack info only
45
+
46
+ WHY: The spec phase needs to know the tech stack to generate appropriate task decompositions. Getting this wrong cascades errors through every subsequent phase.
47
+ </step>
48
+
49
+ <step name="auto_detect_stack" priority="third">
50
+ ONLY run this step if the user said "existing codebase."
51
+
52
+ Scan the project root for these files and extract information:
53
+
54
+ 1. package.json → read "dependencies", "devDependencies", "scripts" keys
55
+ - Detect framework: look for "next", "react", "vue", "angular", "nestjs", "express", "fastify"
56
+ - Detect test runner: look for "jest", "vitest", "mocha", "playwright"
57
+ - Detect package manager: check for bun.lockb (bun), yarn.lock (yarn), pnpm-lock.yaml (pnpm), package-lock.json (npm)
58
+ 2. tsconfig.json → TypeScript project, read "compilerOptions.target" and "compilerOptions.module"
59
+ 3. biome.json or .eslintrc* → linter config
60
+ 4. docker-compose.yml or Dockerfile → containerized
61
+ 5. .env.example → environment variables needed
62
+ 6. prisma/schema.prisma or src/**/*.entity.ts → database/ORM
63
+
64
+ Present findings to user: "I detected: {stack}. Is this accurate? Anything to add or correct?"
65
+
66
+ WHY: Auto-detection prevents the user from having to manually list everything, but we ALWAYS confirm because detection can miss things or misidentify.
67
+ </step>
68
+
69
+ <step name="create_project_md" priority="fourth">
70
+ Create .sdlc/PROJECT.md with this structure:
71
+
72
+ ```markdown
73
+ # {Project Name}
74
+
75
+ ## Description
76
+ {User-provided description}
77
+
78
+ ## Tech Stack
79
+ - **Language**: {language}
80
+ - **Framework**: {framework}
81
+ - **Database**: {database or "None"}
82
+ - **Testing**: {test framework}
83
+ - **Package Manager**: {package manager}
84
+ - **Linter**: {linter}
85
+
86
+ ## Architecture
87
+ {Leave blank for user to fill, or note "To be defined in first spec"}
88
+
89
+ ## Conventions
90
+ - File naming: {detected or ask}
91
+ - Import style: {detected or ask}
92
+ - Test location: {co-located or separate test/ directory}
93
+
94
+ ## Requirements
95
+ {Leave blank — populated during spec phases}
96
+ ```
97
+
98
+ WHY: PROJECT.md is the single source of truth for project context. Every workflow reads it. Incomplete or wrong info here breaks everything downstream.
99
+ </step>
100
+
101
+ <step name="create_state_md" priority="fifth">
102
+ Create .sdlc/STATE.md with this structure:
103
+
104
+ ```markdown
105
+ # SDLC State
106
+
107
+ ## Current Position
108
+ - **milestone**: 01
109
+ - **phase**: none
110
+ - **plan**: none
111
+ - **loop_position**: INIT ✓
112
+ - **status**: ready
113
+
114
+ ## Next Required Action
115
+ /sdlc:spec
116
+
117
+ ## Session
118
+ - **started**: {ISO timestamp}
119
+ - **last_updated**: {ISO timestamp}
120
+
121
+ ## History
122
+ | Timestamp | Action | Result |
123
+ |-----------|--------|--------|
124
+ | {now} | init | Project initialized |
125
+ ```
126
+
127
+ WHY: STATE.md is the state machine. Every workflow reads it first to know where we are. The next_required_action field enforces the SPEC → IMPL → VERIFY → REVIEW → CLOSE loop. Without it, users can skip steps.
128
+ </step>
129
+
130
+ <step name="create_roadmap_md" priority="sixth">
131
+ Ask the user:
132
+
133
+ Question 1: "What is your first milestone? (e.g., 'MVP', 'Auth System', 'v1.0')"
134
+ Question 2: "What phases make up this milestone? List 2-5 phases in order."
135
+ - Provide example: "e.g., Phase 01: Project Setup, Phase 02: Core Models, Phase 03: API Endpoints, Phase 04: UI"
136
+ Question 3: "Any rough timeline? (optional — leave blank if unknown)"
137
+
138
+ Create .sdlc/ROADMAP.md:
139
+
140
+ ```markdown
141
+ # Roadmap
142
+
143
+ ## Milestone 01: {name}
144
+ **Goal**: {user description}
145
+ **Status**: IN PROGRESS
146
+
147
+ ### Phases
148
+ | Phase | Name | Status | Plans |
149
+ |-------|------|--------|-------|
150
+ | 01 | {name} | NOT STARTED | 0 |
151
+ | 02 | {name} | NOT STARTED | 0 |
152
+ | ... | ... | ... | ... |
153
+
154
+ ## Future Milestones
155
+ {Leave blank — added via /sdlc:milestone}
156
+ ```
157
+
158
+ WHY: The roadmap gives structure to the work. Without it, specs are disconnected tasks with no arc. The phase structure ensures work builds on itself in a logical order.
159
+ </step>
160
+
161
+ <step name="create_laws_md" priority="seventh">
162
+ Present the engineering laws to the user with default severities:
163
+
164
+ Display:
165
+ "These engineering laws will be enforced during /sdlc:review. Default severity is ERROR (blocks progress). You can downgrade any to WARN (flagged but non-blocking) or INFO (noted only)."
166
+
167
+ | # | Law | Default | Description |
168
+ |---|-----|---------|-------------|
169
+ | 1 | SOLID | ERROR | Single Responsibility, Open/Closed, Liskov, Interface Segregation, Dependency Inversion |
170
+ | 2 | DRY | ERROR | No duplicate logic. Search before creating |
171
+ | 3 | YAGNI | ERROR | No speculative code. Only what the spec requires |
172
+ | 4 | Clean Code | ERROR | Max 40 lines/function, max 3 params, max 3 nesting levels |
173
+ | 5 | Security | ERROR | No hardcoded secrets, input validation, parameterized queries |
174
+ | 6 | Testing | ERROR | New behavior requires new tests. Edge cases covered |
175
+ | 7 | Error Handling | ERROR | No empty catch blocks, no swallowed exceptions |
176
+ | 8 | Null Safety | WARN | No non-null assertions in production. Explicit null handling |
177
+ | 9 | Type Safety | WARN | Named types for complex shapes. No inline object types with 2+ properties |
178
+ | 10 | File Size | WARN | Max 500 lines per file |
179
+
180
+ Ask: "Keep all defaults, or change any? (e.g., 'set 8 to INFO, set 10 to ERROR')"
181
+
182
+ Create .sdlc/LAWS.md with the configured severities:
183
+
184
+ ```markdown
185
+ # Engineering Laws
186
+
187
+ ## Enforcement Levels
188
+ - **ERROR**: Blocks /sdlc:close. Must fix before proceeding.
189
+ - **WARN**: Flagged in review. Should fix but non-blocking.
190
+ - **INFO**: Noted for awareness. No action required.
191
+
192
+ ## Laws
193
+ | # | Law | Severity | Enforcement |
194
+ |---|-----|----------|-------------|
195
+ | 1 | SOLID | {severity} | {description} |
196
+ ...
197
+ ```
198
+
199
+ WHY: Configurable severity lets teams adopt incrementally. A legacy codebase might start with Clean Code as WARN and tighten later. But the laws EXIST from day one — you cannot skip the review phase.
200
+ </step>
201
+
202
+ <step name="create_directory_structure" priority="eighth">
203
+ Create the phase directories based on the roadmap:
204
+
205
+ ```
206
+ .sdlc/
207
+ PROJECT.md
208
+ STATE.md
209
+ ROADMAP.md
210
+ LAWS.md
211
+ phases/
212
+ 01-{phase-name}/
213
+ 02-{phase-name}/
214
+ ...
215
+ research/
216
+ ```
217
+
218
+ Run: mkdir -p .sdlc/phases/{phase-dir} for each phase
219
+ Run: mkdir -p .sdlc/research
220
+
221
+ WHY: Pre-creating directories prevents "directory not found" errors during spec/impl phases. The research/ directory is used by /sdlc:research to store findings.
222
+ </step>
223
+
224
+ <step name="update_state_and_display" priority="ninth">
225
+ Update STATE.md:
226
+ - loop_position: INIT ✓
227
+ - next_required_action: /sdlc:spec
228
+ - Add history entry: "{timestamp} | init | Project initialized with {N} phases"
229
+
230
+ Display to user:
231
+ ```
232
+ ✅ Project initialized.
233
+
234
+ Created:
235
+ .sdlc/PROJECT.md — project configuration
236
+ .sdlc/STATE.md — state machine
237
+ .sdlc/ROADMAP.md — milestone and phase tracking
238
+ .sdlc/LAWS.md — engineering law configuration
239
+ .sdlc/phases/ — phase directories
240
+ .sdlc/research/ — research storage
241
+
242
+ NEXT ACTION REQUIRED: /sdlc:spec
243
+ Run /sdlc:spec to create your first specification.
244
+ ```
245
+
246
+ WHY: The explicit "NEXT ACTION REQUIRED" message is the forcing function. The user always knows exactly what to do next. No ambiguity, no guessing.
247
+ </step>
248
+
249
+ </process>