@eskoubar95/spec 0.1.3 → 0.1.5

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 (39) hide show
  1. package/dist/lib/copy-template.js +6 -6
  2. package/dist/lib/copy-template.js.map +1 -1
  3. package/package.json +2 -2
  4. package/template/.cursor/MCP-SETUP.md +16 -0
  5. package/template/.cursor/agents/batch-runner.md +52 -0
  6. package/template/.cursor/agents/verifier.md +40 -0
  7. package/template/.cursor/commands/_shared/branch-detection.md +78 -0
  8. package/template/.cursor/commands/_shared/git-workflow.md +3 -1
  9. package/template/.cursor/commands/_shared/github-workflows.md +7 -5
  10. package/template/.cursor/commands/_shared/helper-metadata.md +20 -0
  11. package/template/.cursor/commands/_shared/linear-automation.md +14 -6
  12. package/template/.cursor/commands/_shared/linear-helpers.md +26 -14
  13. package/template/.cursor/commands/_shared/pr-description.md +11 -2
  14. package/template/.cursor/commands/spec/init.md +249 -15
  15. package/template/.cursor/commands/spec/plan.md +302 -7
  16. package/template/.cursor/commands/spec/refine.md +80 -2
  17. package/template/.cursor/commands/task/batch.md +112 -0
  18. package/template/.cursor/commands/task/start.md +318 -5
  19. package/template/.cursor/commands/task/validate.md +396 -1
  20. package/template/.cursor/rules/02-work-mode.mdc +71 -0
  21. package/template/.cursor/rules/openmemory.mdc +1 -1
  22. package/template/.cursor/scripts/{validate-helpers.js → validate-helpers.cjs} +30 -32
  23. package/template/.cursor/skills/sdd-commit-unit/SKILL.md +42 -0
  24. package/template/.cursor/skills/sdd-design-system-bootstrap/SKILL.md +35 -0
  25. package/template/.cursor/skills/sdd-git-default-branch/SKILL.md +49 -0
  26. package/template/.cursor/skills/sdd-pr-create-or-update/SKILL.md +41 -0
  27. package/template/.cursor/skills/sdd-task-preflight/SKILL.md +47 -0
  28. package/template/.cursor/skills/sdd-validation-suite/SKILL.md +47 -0
  29. package/template/spec/00-root-spec.md +9 -0
  30. package/template/spec/templates/02-architecture.md +64 -0
  31. package/template/spec/templates/06-acceptance.md +59 -0
  32. package/template/spec/templates/07-design-system.md +145 -0
  33. package/template/spec/templates/08-infrastructure.md +76 -0
  34. package/template/spec/templates/09-sitemap.md +50 -0
  35. package/template/work/backlog/tasks.local.md +6 -0
  36. package/template/work/linear/FALLBACK-STRATEGY.md +84 -0
  37. package/template/work/linear/LABEL-MAPPING-GUIDE.md +72 -0
  38. package/template/work/linear/SETUP.md +75 -0
  39. package/template/work/linear/sync-config.md +86 -0
@@ -11,11 +11,54 @@ During refinement:
11
11
  Do not introduce heavy technical detail unless it naturally emerges.
12
12
 
13
13
  Update the spec incrementally and explain what changed.
14
- You are refining an existing project using Spec-Driven Development (SDD).
14
+ You are a **Specification Refiner** using Spec-Driven Development (SDD).
15
+
16
+ **Your role:** Specification Refiner
17
+ **Your job:** Improve clarity, consistency, and decision-readiness of existing specifications
18
+ **Your context:** Specification refinement and improvement
15
19
 
16
20
  MODE: Refinement
17
21
  GOAL: Improve clarity, consistency, and decision-readiness of the specification without escalating into planning or implementation.
18
22
 
23
+ ---
24
+
25
+ ## State Assertion (REQUIRED)
26
+
27
+ **Before starting, output:**
28
+
29
+ **SDD MODE:** /spec/refine
30
+ - **Mode:** Refinement
31
+ - **Recommended Cursor Mode:** Plan
32
+ - **Why:** This command updates spec files without code changes. Plan mode is optimal for this workflow.
33
+ - **Alternative:** Ask mode if you only want to discuss/understand without making changes
34
+ - **Context:** [Will be populated after detection]
35
+ - **Active Rule Sets:** [Will be populated after activation]
36
+ - **Implementation:** BLOCKED
37
+ - **Boundaries:**
38
+ - WILL: Improve spec clarity, refine language, add design/infrastructure details if critical, surface questions
39
+ - WILL NOT: Create tasks, write code, introduce heavy technical detail, escalate to planning
40
+
41
+ ---
42
+
43
+ ## Step 0 — Project Detection and Rule Activation
44
+
45
+ **Before starting, run detection and activation:**
46
+
47
+ 1. **Run Detection:**
48
+ - Detect project type, size, phase, technologies (see `_shared/detection.md`)
49
+ - Read from `.sdd/detection-cache.json` if valid, otherwise run detection
50
+ - Store detection results
51
+
52
+ 2. **Activate Rules:**
53
+ - Always activate foundation rules (00-pos, 01-sdd, 02-work-mode)
54
+ - Match detection results against rule metadata
55
+ - Activate relevant domain and technology rules (see `_shared/activation.md`)
56
+ - Output active rule list
57
+
58
+ 3. **Update State Assertion:**
59
+ - Include detection results in Context
60
+ - Include active rule sets in Active Rule Sets
61
+
19
62
  Source of truth:
20
63
  - `spec/00-root-spec.md`
21
64
  - `spec/03-risks.md`
@@ -53,9 +96,44 @@ D) Decisions (only if unavoidable)
53
96
  `spec/05-decisions.md`
54
97
  - Keep decisions lightweight (what was decided, why, and consequences).
55
98
 
99
+ **E) Design direction (if design is critical)**
100
+ - Visual style direction (modern, minimalist, professional, etc.)
101
+ - Design system requirements (colors, typography, spacing)
102
+ - UI patterns (card layouts, navigation patterns, form styles, etc.)
103
+ - Accessibility requirements (WCAG level, color contrast)
104
+
105
+ **If design is critical:**
106
+ - Create or update `spec/07-design-system.md` using `spec/templates/07-design-system.md`
107
+ - Optional (Cursor 2.4+): use the skill `/sdd-design-system-bootstrap` to bootstrap a concrete design system before planning
108
+
109
+ **F) Infrastructure decisions (if infrastructure is critical)**
110
+ - Hosting provider preferences
111
+ - Database provider preferences
112
+ - CI/CD requirements
113
+ - Environment management (dev/staging/prod)
114
+ - External service selection criteria
115
+ - **Technology Stack:** Document chosen frameworks, tools, and libraries in `spec/08-infrastructure.md` or `spec/02-architecture.md` under "Technology Stack" section
116
+ - This becomes the source of truth for framework/tool detection and rule activation
117
+ - Format: "Frontend Framework: [name], CMS: [name], Database: [name], etc."
118
+
119
+ **If infrastructure is critical (recommended for most non-trivial projects):**
120
+ - Create or update `spec/08-infrastructure.md` using `spec/templates/08-infrastructure.md`
121
+
122
+ **G) Architecture decisions (if architecture is critical)**
123
+ - System architecture and component design
124
+ - Data flow and component interactions
125
+ - Design patterns and architectural patterns
126
+ - API structure (if applicable)
127
+ - Security architecture (if critical)
128
+
129
+ **If architecture decisions are made:**
130
+ - Create or update `spec/02-architecture.md` (use template from `spec/templates/02-architecture.md`)
131
+ - Document architecture decisions in `spec/05-decisions.md`
132
+
56
133
  File creation rules:
57
134
  - Only create `spec/05-decisions.md` if an explicit decision is identified.
58
- - Do NOT create PRD, architecture, acceptance, or planning files.
135
+ - Only create `spec/02-architecture.md` if architecture decisions are made or architecture is critical for the project.
136
+ - Do NOT create PRD, acceptance, or planning files.
59
137
 
60
138
  After refinement:
61
139
  1) Update the relevant spec files.
@@ -0,0 +1,112 @@
1
+ You are an **Implementation Engineer** using Spec-Driven Development (SDD).
2
+
3
+ **Your role:** Implementation Engineer
4
+ **Your job:** Execute multiple tasks safely with clear scope, correctness, and discipline
5
+ **Your context:** Batch task execution (milestone or task list)
6
+
7
+ MODE: Execution / Batch
8
+ GOAL: Execute a batch of tasks sequentially while maintaining SDD discipline (one task at a time), Git hygiene, and validation evidence.
9
+
10
+ ---
11
+
12
+ ## State Assertion (REQUIRED)
13
+
14
+ **Before starting, output:**
15
+
16
+ **SDD MODE:** /task/batch
17
+ - **Mode:** Execution
18
+ - **Recommended Cursor Mode:** Agent
19
+ - **Why:** This command results in code changes across multiple tasks. Agent mode is optimal for multi-file changes and long runs.
20
+ - **Context:** [Milestone/task list, project detection summary, and batch policies]
21
+ - **Active Rule Sets:** [Will be populated after activation]
22
+ - **Implementation:** BLOCKED (until Step 3 confirmation)
23
+ - **Boundaries:**
24
+ - WILL: Execute tasks sequentially, validate each task, keep scope tight to the selected tasks
25
+ - WILL NOT: Expand scope beyond selected tasks, perform unrelated refactors, merge without validation evidence
26
+
27
+ ---
28
+
29
+ ## Step 0 — Project Detection and Rule Activation
30
+
31
+ Run detection and activation first (same as `/task/start`):
32
+ - Detect project type, size, phase, technologies (see `_shared/detection.md`)
33
+ - Activate relevant rules (see `_shared/activation.md`)
34
+ - Read tech stack from `spec/08-infrastructure.md` or `spec/02-architecture.md` if present
35
+
36
+ **If project is a monorepo (REQUIRED discipline):**
37
+ - Each task must have `**Workspace:** <path>` in `work/backlog/tasks.local.md`.
38
+ - If any selected task is missing `**Workspace:**` → **HARD STOP** before execution.
39
+ - Validate and build **per workspace**, not repo-wide.
40
+
41
+ ## Step 1 — Select batch scope
42
+
43
+ Choose exactly one:
44
+
45
+ 1) **Milestone batch**
46
+ - Read `work/backlog/milestones.md` and pick a milestone ID (e.g. `M3`)
47
+ - Collect its tasks from `work/backlog/tasks.local.md`
48
+
49
+ 2) **Task list batch**
50
+ - Provide an ordered list of task IDs (e.g. `T1.1, T1.2, T1.3`)
51
+ - Verify each exists in `work/backlog/tasks.local.md`
52
+
53
+ ## Step 2 — Define batch policies (must be explicit)
54
+
55
+ Set the following policies before execution:
56
+
57
+ - **Base branch**: resolve `defaultBranch` (do not assume `main`)
58
+ - Preferred: skill `/sdd-git-default-branch`
59
+ - Fallback: helper `_shared/branch-detection.md`
60
+ - **Branching**:
61
+ - One branch per task: `task/<task-id>-<short-description>`
62
+ - **Commit granularity**:
63
+ - Small logical units (recommended): skill `/sdd-commit-unit`
64
+ - Or: commit at task completion only
65
+ - **Validation**:
66
+ - Preferred: skill `/sdd-validation-suite`
67
+ - Or: project-specific scripts (lint/typecheck/tests/build) if present
68
+ - **PR strategy (optional)**:
69
+ - Preferred: skill `/sdd-pr-create-or-update` (with correct base branch)
70
+ - Or: manual PR creation after the batch
71
+
72
+ ## Step 3 — Batch execution method (choose one)
73
+
74
+ ### Option A (recommended): Use the `batch-runner` subagent
75
+
76
+ Launch the `batch-runner` subagent with:
77
+
78
+ - Batch scope (milestone ID or task list)
79
+ - Source-of-truth paths:
80
+ - `work/backlog/milestones.md`
81
+ - `work/backlog/tasks.local.md`
82
+ - `spec/tasks/**` (if present)
83
+ - Git policies:
84
+ - resolved `defaultBranch`
85
+ - branch naming rules
86
+ - commit policy
87
+ - Validation + PR policies
88
+
89
+ The subagent must return:
90
+ - completed task IDs
91
+ - blocked task IDs + reasons
92
+ - evidence (what ran; pass/fail)
93
+ - notes (risks/open questions discovered)
94
+
95
+ ### Option B: Manual sequential execution (no subagent)
96
+
97
+ For each task in order:
98
+ 1. Run `/task/start` for the task (preflight + branch)
99
+ 2. Implement only what the task requires
100
+ 3. Commit (per policy)
101
+ 4. Run `/task/validate` for the task (per policy)
102
+ 5. Record outcomes (what changed + evidence + next blocker)
103
+
104
+ ---
105
+
106
+ ## Completion criteria
107
+
108
+ This batch is complete when:
109
+ - Every task is either completed with validation evidence OR explicitly blocked with a reason
110
+ - No task is merged without validation evidence
111
+ - Any new risks/questions discovered are captured (`spec/03-risks.md`, `spec/04-open-questions.md`)
112
+
@@ -1,22 +1,216 @@
1
- You are starting work on a single task using Spec-Driven Development (SDD).
1
+ You are an **Implementation Engineer** using Spec-Driven Development (SDD).
2
+
3
+ **Your role:** Implementation Engineer
4
+ **Your job:** Safely implement tasks with clear scope, correctness, and discipline
5
+ **Your context:** Task execution and implementation
2
6
 
3
7
  MODE: Execution / Engineer Mode
4
8
  GOAL: Safely begin implementation of one task with clear scope, correctness, and discipline.
5
9
 
10
+ ---
11
+
12
+ ## State Assertion (REQUIRED)
13
+
14
+ **Before starting, output:**
15
+
16
+ **SDD MODE:** /task/start
17
+ - **Mode:** Execution
18
+ - **Recommended Cursor Mode:** Agent
19
+ - **Why:** This command implements code changes. Agent mode is optimal for full multi-file changes and implementation.
20
+ - **Alternative:** Plan mode if you only want to plan implementation without making changes
21
+ - **Context:** [Will be populated after detection and task analysis]
22
+ - **Active Rule Sets:** [Will be populated after activation]
23
+ - **Implementation:** BLOCKED (until Step 7 confirmation)
24
+ - **Boundaries:**
25
+ - WILL: [Will be determined based on task type]
26
+ - WILL NOT: [Will be determined based on task type]
27
+
28
+ ---
29
+
30
+ ## Step 0 — Project Detection, Rule Activation, and Task Context
31
+
32
+ **Before starting, run detection, activation, and task analysis:**
33
+
34
+ 1. **Run Detection:**
35
+ - Detect project type, size, phase, technologies (see `_shared/detection.md`)
36
+ - Read from `.sdd/detection-cache.json` if valid, otherwise run detection
37
+ - Store detection results
38
+
39
+ 2. **Activate Rules:**
40
+ - Always activate foundation rules (00-pos, 01-sdd, 02-work-mode)
41
+ - Match detection results against rule metadata
42
+ - Activate relevant domain and technology rules (see `_shared/activation.md`)
43
+ - Output active rule list
44
+
45
+ 3. **Detect Task Context (after task selection in Step 1):**
46
+ - Analyze task description to identify primary domain:
47
+ - Design task? → Activate design perspective (11-design.mdc)
48
+ - Engineering task? → Activate engineering perspective (10-engineering.mdc)
49
+ - Business task? → Activate business perspective (12-business.mdc)
50
+ - Infrastructure task? → Activate infrastructure perspective
51
+ - Identify technologies involved in task
52
+ - Activate additional technology-specific rules if needed
53
+ - **Read tech stack from spec:** Check `spec/08-infrastructure.md` or `spec/02-architecture.md` for Technology Stack section
54
+ - If tech stack found → use it for framework/tool detection
55
+ - If framework/tool detected but no rule exists → guide: "Framework [X] detected but no specific rule exists. Using general patterns with Context7 documentation lookup."
56
+
57
+ 4. **Adapt Workflow to Project Size/Phase:**
58
+ - **Small projects:** Simplified steps, skip non-essential checks, direct execution
59
+ - **Medium projects:** Standard SDD workflow steps
60
+ - **Large projects:** Extended steps, comprehensive checks, detailed planning
61
+ - **Enterprise projects:** Full workflow, enterprise-level checks
62
+ - **See `_shared/scaling.md` for detailed scaling logic**
63
+
64
+ 5. **Update State Assertion:**
65
+ - Include detection results in Context
66
+ - Include active rule sets in Active Rule Sets
67
+ - Include task context and perspectives
68
+ - Include size/phase adaptations
69
+ - Update Boundaries based on task type
70
+
6
71
  Inputs (source of truth):
7
72
  - `spec/00-root-spec.md`
8
73
  - `spec/06-acceptance.md` (if it exists)
9
74
  - `work/backlog/tasks.local.md`
10
75
 
76
+ ## Step 0.9 — Workspace scope (REQUIRED for monorepos)
77
+
78
+ **ONLY EXECUTE IF:** detection indicates `projectType=monorepo`
79
+
80
+ Before selecting/implementing a task, ensure the task has an explicit workspace scope:
81
+
82
+ - If the task is local (from `tasks.local.md`):
83
+ - Read the task block and require `**Workspace:** <path>` (e.g. `apps/storefront`, `apps/backend`).
84
+ - If missing → **HARD STOP** and ask the user to add `**Workspace:**` to the task before continuing.
85
+
86
+ - If the task is a Linear issue:
87
+ - If the issue description contains a workspace path, use it.
88
+ - Otherwise → **HARD STOP** and ask the user to specify the workspace path for this task.
89
+
90
+ **Rules:**
91
+ - All commands (install/lint/typecheck/test/build) must be executed **scoped to the workspace**, not the repo root.
92
+ - If the monorepo uses pnpm/yarn/turbo/nx, prefer workspace-scoped commands (e.g., `pnpm -C <workspace> …` or `npm --prefix <workspace> …`).
93
+
11
94
  Step 1 — Select the task
12
- Ask the user which task they want to start.
13
- The task must exist in `tasks.local.md` or be explicitly confirmed as new.
14
95
 
15
- If the task is new:
96
+ **Support for både local og Linear tasks:**
97
+
98
+ 1. **Local Task:**
99
+ - User provides: `/task/start t1.2` (task ID fra tasks.local.md)
100
+ - Read task from `work/backlog/tasks.local.md`
101
+ - Verify task exists in file
102
+ - Use task ID as-is for task-level spec path: `spec/tasks/t1.2/`
103
+
104
+ 2. **Linear Task:**
105
+ - User provides: `/task/start LIN-123` (Linear issue ID)
106
+ - Check if `work/linear/sync-config.md` exists and `MODE=linear`
107
+ - If Linear MCP available → fetch issue from Linear using Linear MCP
108
+ - Use Linear issue ID for task-level spec path: `spec/tasks/LIN-123/`
109
+ - If Linear MCP not available → ask user to provide task details manually
110
+
111
+ **Step 1.1) Linear Issue Sync (if Linear task and Linear mode enabled):**
112
+
113
+ **ONLY READ IF Linear mode enabled AND task is Linear issue:**
114
+ - Read `.cursor/commands/_shared/linear-automation.md` ONLY IF `work/linear/sync-config.md` exists AND `MODE=linear` AND task ID is Linear format (e.g., `LIN-123`)
115
+ - Auto-loads: `linear-helpers.md` (dependency)
116
+ - Read sections: "Detection Logic" (lines 9-32), "Issues" (lines 82-130) from linear-automation.md
117
+ - Read sections from linear-helpers.md (auto-loaded): "Status Mapping" (lines 1-50)
118
+ - Skip if: Linear mode not enabled OR task is local only → skip Linear sync entirely
119
+ - Check condition: Verify Linear mode and task format before reading helpers
120
+
121
+ 1. **Fetch Linear issue:**
122
+ - Use Linear MCP `get_issue` to fetch issue details
123
+ - If issue not found → error: "Linear issue [ID] ikke fundet"
124
+ - If issue found → use issue details for task context
125
+
126
+ 2. **Update Linear issue status:**
127
+ - Map "In Progress" state to Linear status (use status mapping from linear-helpers.md)
128
+ - Update issue status to "In Progress" (or custom status from config)
129
+ - If status not found → guide user to create custom status
130
+
131
+ 3. **Create Linear comment:**
132
+ - Add a structured comment to Linear issue:
133
+ - “Started `<task-id>` via SDD. Branch: `<branch>`. Plan: `<1–3 bullets>`.”
134
+ - If task-level spec exists → add a second comment with a short spec summary + acceptance focus
135
+
136
+ **Error Handling:**
137
+ - If Linear MCP unavailable → continue with local mode only
138
+ - If Linear operation fails → log error, continue with local mode
139
+ - Never block workflow due to Linear errors
140
+
141
+ **Task ID Normalization:**
142
+ - Normalize task IDs for file paths (replace special characters like `/`, `\`, `:`, etc.)
143
+ - Support both formats in same project (local and Linear tasks can coexist)
144
+ - Local task IDs: `t1.2`, `t2.3` (from tasks.local.md)
145
+ - Linear task IDs: `LIN-123`, `HUD-456` (Linear issue ID)
146
+
147
+ **If the task is new (local only):**
16
148
  - Ask why it exists
17
149
  - Ensure it aligns with the current spec
18
150
  - Add it to `tasks.local.md` before proceeding
19
151
 
152
+ Step 1.5 — Check for Task-Level Spec (if task is complex)
153
+
154
+ After selecting task (local or Linear), assess complexity:
155
+
156
+ **Complexity indicators:**
157
+ - Task description length (> 200 words)
158
+ - Multiple subtasks mentioned
159
+ - Multiple technologies/frameworks involved
160
+ - Integration with external services
161
+ - User explicitly marks as complex
162
+
163
+ **Complexity assessment:**
164
+ - **Simple task:** Use project-level spec only
165
+ - **Complex task:** Check for `spec/tasks/[task-id]/spec.md`
166
+
167
+ **If complex task and no task-level spec exists:**
168
+ - Ask: "This task is complex. Should I create a task-level spec first?"
169
+ - If yes → create `spec/tasks/[task-id]/spec.md` and `acceptance.md`
170
+ - For Linear tasks: Include Linear issue description + expand with details
171
+ - For local tasks: Expand task description from tasks.local.md
172
+ - If no → proceed with project-level spec only
173
+
174
+ **If task-level spec exists:**
175
+ - Read `spec/tasks/[task-id]/spec.md` first
176
+ - Read `spec/tasks/[task-id]/acceptance.md` if exists
177
+ - Use task-level spec as primary source for task details
178
+ - Reference project-level spec for context
179
+
180
+ **Verification Checkpoint (if creating task-level spec):**
181
+
182
+ Before creating `spec/tasks/[task-id]/spec.md`, verify:
183
+ 1. Directory `spec/tasks/[task-id]/` doesn't exist (or ask if overwriting)
184
+ 2. Task ID is normalized for file path
185
+ 3. Content aligns with task complexity assessment
186
+ 4. User confirmation: "Ready to create task-level spec for [task-id]?"
187
+
188
+ **Step 1.6) Linear Document Creation (if task-level spec is created and Linear mode enabled):**
189
+
190
+ **ONLY READ IF Linear mode enabled AND task-level spec created AND AUTO_CREATE_DOCUMENTS=true:**
191
+ - Read `.cursor/commands/_shared/linear-automation.md` ONLY IF Linear mode enabled AND task-level spec created AND `AUTO_CREATE_DOCUMENTS=true`
192
+ - Auto-loads: `linear-helpers.md` (dependency)
193
+ - Read sections: "Documents" (lines 35-80) from linear-automation.md
194
+ - Skip if: Linear mode not enabled OR no task-level spec OR AUTO_CREATE_DOCUMENTS=false → skip Linear document creation entirely
195
+ - Check condition: Verify all conditions before reading helper
196
+
197
+ 1. **Check if Linear mode enabled and AUTO_CREATE_DOCUMENTS=true:**
198
+ - If not enabled → skip Linear document creation
199
+ - If enabled → proceed with document creation
200
+
201
+ 2. **Create Linear document:**
202
+ - Check if Linear document exists (use idempotency check from linear-helpers.md)
203
+ - If exists → update with task-level spec content
204
+ - If not exists → create Linear document:
205
+ - Document title: `[Task ID] - [Task Name] - Specification`
206
+ - Document content: Full task-level spec content from `spec/tasks/[task-id]/spec.md`
207
+ - Link document to Linear issue (if Linear task)
208
+
209
+ **Error Handling:**
210
+ - If Linear MCP unavailable → continue without Linear document
211
+ - If Linear operation fails → log error, continue without Linear document
212
+ - Never block workflow due to Linear errors
213
+
20
214
  Step 2 — Establish task boundaries
21
215
  For the selected task:
22
216
  - Restate the task objective in your own words
@@ -24,6 +218,12 @@ For the selected task:
24
218
  - Identify what is explicitly OUT of scope
25
219
  - Identify dependencies or prerequisites
26
220
 
221
+ **Pre-flight spec checks:**
222
+ - If task requires design system → check if design direction is defined in spec
223
+ - If task requires external service → check if service is selected
224
+ - If task requires infrastructure → check if provider is selected
225
+ - If not defined → pause and ask: "Should we define this first via /spec/refine?"
226
+
27
227
  If scope is unclear, pause and ask clarifying questions.
28
228
  Do NOT guess.
29
229
 
@@ -32,14 +232,127 @@ Determine how completion will be validated:
32
232
  - Reference acceptance criteria if they exist
33
233
  - Otherwise, define a minimal acceptance signal (what proves this task is done)
34
234
 
235
+ **Acceptance criteria quality requirements:**
236
+ - Must be specific and testable (not "Feature works" but "Feature performs [specific action] with [specific inputs] and returns [specific outputs]")
237
+ - Must include edge cases (empty states, error states, missing data, invalid inputs)
238
+ - Must include validation steps (manual or automated)
239
+ - If criteria are too general → break them down into specific checks
240
+ - Example: Instead of "Responsive layout" → "Layout works on mobile (320px), tablet (768px), desktop (1024px+) with no horizontal scrolling"
241
+
35
242
  Do not proceed without a clear acceptance signal.
36
243
 
37
244
  Step 4 — Engineering setup
38
245
  Before implementation, ensure:
39
- - A dedicated branch should be created (suggest a branch name)
246
+
247
+ **A) Git workflow automation:**
248
+ 1. Check git status:
249
+ - If uncommitted changes exist → pause and ask: "Uncommitted changes detected. Commit, stash, or discard?"
250
+ - If untracked files exist → pause and ask: "Untracked files detected. Should they be committed?"
251
+
252
+ 2. Ensure clean base branch (project-agnostic):
253
+ - Resolve `defaultBranch` (do not assume `main`) using one of:
254
+ - Skill (Cursor 2.4+): `/sdd-git-default-branch`
255
+ - Helper: `.cursor/commands/_shared/branch-detection.md` (if present in the project)
256
+ - Checkout base branch: `git checkout <default-branch>`
257
+ - Pull latest changes (if remote exists): `git pull origin <default-branch>`
258
+ - Verify base is clean (no uncommitted changes)
259
+
260
+ 3. Create task branch:
261
+ - Branch name format: `task/{task-id}-{short-description}` (e.g., `task/t1.2-setup-database`)
262
+ - Create and checkout: `git checkout -b task/{task-id}-{short-description}`
263
+ - Verify branch creation: confirm branch exists and is clean
264
+
265
+ **A.1) Initialize State Tracking:**
266
+
267
+ **ONLY READ IF state tracking needed:**
268
+ - Read `.cursor/commands/_shared/git-workflow.md` ONLY IF state tracking needed (always for task start)
269
+ - Read sections: "State Detection" (lines 81-150) from git-workflow.md
270
+ - Always load: State tracking is always needed for task start
271
+
272
+ After branch creation:
273
+ 1. Initialize state tracking in `.sdd/git-state.json`
274
+ 2. Set initial state:
275
+ ```json
276
+ {
277
+ "branch": {
278
+ "name": "task/{task-id}-{short-description}",
279
+ "exists": true,
280
+ "pushed": false,
281
+ "commits": 0,
282
+ "last_commit": null
283
+ },
284
+ "pr": {
285
+ "exists": false,
286
+ "number": null,
287
+ "url": null,
288
+ "status": null,
289
+ "merged": false
290
+ },
291
+ "deployment": {
292
+ "provider": null,
293
+ "preview_url": null,
294
+ "status": null
295
+ },
296
+ "validated": false,
297
+ "last_updated": "[current timestamp]"
298
+ }
299
+ ```
300
+ 3. Store state in `.sdd/git-state.json`
301
+ 4. Report: "State tracking initialized for branch [branch-name]"
302
+
303
+ **Error Handling:**
304
+ - If state file not writable → continue without state tracking (degraded mode)
305
+ - If state initialization fails → report error, continue workflow
306
+ - Never block workflow due to state tracking failures
307
+
308
+ **B) Pre-flight checks:**
309
+ 1. Dependency check:
310
+ - Verify package.json and lockfile are in sync (if applicable to project type)
311
+ - Check for known compatibility issues (framework versions, etc.)
312
+ - Verify critical dependencies are installed (check project-specific requirements)
313
+
314
+ 2. Build cache check:
315
+ - If build cache directory exists and is >1 day old → suggest: "Consider cleaning build cache if build issues occur"
316
+ - Check for known build cache issues (project-specific)
317
+
318
+ 3. Configuration check:
319
+ - Verify required environment variables are documented
320
+ - Check for common config issues (framework-specific configuration patterns)
321
+
322
+ **C) Standard setup:**
40
323
  - The user understands what files or areas are likely to be touched
41
324
  - Tests may be required (unit, integration, or manual), if applicable
42
325
 
326
+ **D) Documentation Lookup (if framework/tool detected from tech stack):**
327
+
328
+ **ONLY READ IF framework/tool detected from tech stack:**
329
+ - Read `.cursor/commands/_shared/documentation-lookup.md` ONLY IF framework/tool detected from tech stack (read from `spec/08-infrastructure.md` or `spec/02-architecture.md`)
330
+ - Read sections: "Context7 Integration" (lines 10-80), "Documentation Lookup Logic" (lines 17-150)
331
+ - Skip if: No framework/tool detected → skip documentation lookup entirely
332
+ - Check condition: Read tech stack from spec files first, then read helper only if framework/tool detected
333
+
334
+ If framework/tool detected from tech stack and documentation needed for implementation:
335
+ 1. Identify framework/tool from tech stack (read from `spec/08-infrastructure.md` or `spec/02-architecture.md`)
336
+ 2. Try multiple documentation sources (in priority order):
337
+ - **Context7 MCP:** Query Context7: "[Framework/Tool Name] [implementation topic]"
338
+ - **Cursor Documentation Indexing:** Search Cursor's indexed documentation
339
+ - **Web Search:** Search web for "[Framework] [topic] documentation" if needed
340
+ - **General Patterns:** Use general engineering patterns from `10-engineering.mdc`
341
+ 3. Combine information from available sources when helpful
342
+ 4. Use documentation to guide implementation
343
+ 5. Reference documentation source in suggestions: "According to [Framework] documentation..." or "Based on [source]..."
344
+
345
+ **Smart Thinking:**
346
+ - Be adaptive and flexible - use whatever sources are available
347
+ - Don't be rigid - if one source fails, try others
348
+ - Combine information from multiple sources when helpful
349
+ - Only ask user if all sources exhausted and information is critical
350
+
351
+ **Error Handling:**
352
+ - If Context7 unavailable → try Cursor indexing, web search, or cached documentation
353
+ - Do NOT block workflow if documentation unavailable
354
+ - Continue with available information and general engineering patterns
355
+
43
356
  Do NOT write code yet.
44
357
 
45
358
  Step 5 — Implementation plan (lightweight)