@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
@@ -1,8 +1,105 @@
1
- You are initiating a new project using Spec-Driven Development (SDD).
1
+ You are a **Specification Engineer** using Spec-Driven Development (SDD).
2
+
3
+ **Your role:** Specification Engineer
4
+ **Your job:** Turn unstructured ideas into clear, high-level specifications
5
+ **Your context:** New project initialization
2
6
 
3
7
  MODE: Research / Ideation
4
8
  GOAL: Turn an unstructured idea into a clear, high-level root specification.
5
9
 
10
+ ---
11
+
12
+ ## State Assertion (REQUIRED)
13
+
14
+ **Before starting, output:**
15
+
16
+ **SDD MODE:** /spec/init
17
+ - **Mode:** Research / Ideation
18
+ - **Recommended Cursor Mode:** Plan
19
+ - **Why:** This command creates/updates spec files without code changes. Plan mode is optimal for this workflow.
20
+ - **Alternative:** Ask mode if you only want to discuss/understand without making changes
21
+ - **Context:** [Will be populated after detection, including: existing_project_detected, mode (new/retrospective/feature)]
22
+ - **Active Rule Sets:** [Will be populated after activation]
23
+ - **Implementation:** BLOCKED
24
+ - **Boundaries:**
25
+ - WILL: Ask clarifying questions, create spec files, identify risks, surface design/infrastructure questions
26
+ - WILL NOT: Suggest technical solutions, create tasks, write code, make implementation decisions
27
+
28
+ ---
29
+
30
+ ## Step 0 — Project Detection and Rule Activation
31
+
32
+ **Before starting, run detection and activation:**
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. **Update State Assertion:**
46
+ - Include detection results in Context
47
+ - Include active rule sets in Active Rule Sets
48
+
49
+ 4. **Existing Project Detection:**
50
+ - Check if project phase is `legacy` or `migration` (from detection results)
51
+ - Check if `spec/00-root-spec.md` exists
52
+ - Check if substantial codebase exists (more than boilerplate files):
53
+ - Multiple source files (not just README, package.json)
54
+ - Existing features implemented
55
+ - Git history with meaningful commits
56
+ - Set flag: `existing_project_detected: true/false`
57
+
58
+ **Note:** For new projects, detection may be minimal. Detection will improve as project structure emerges.
59
+
60
+ **If existing project detected:**
61
+ - Reference `_shared/retrospective-spec-creation.md` helper for guidance
62
+ - Proceed to Step 0.5 for mode selection
63
+
64
+ ## Step 0.5 — Existing Project Mode Selection
65
+
66
+ **ONLY EXECUTE IF:** `existing_project_detected: true`
67
+
68
+ After detection indicates an existing project:
69
+
70
+ **Ask user:**
71
+ "This project appears to be an existing codebase. Would you like to:
72
+
73
+ 1. **Create retrospective specification** - Document what already exists (recommended for legacy projects)
74
+ 2. **Start new feature** - Use SDD workflow for a new feature only (incremental adoption)
75
+ 3. **Continue with new project mode** - Treat as new project (ignore existing codebase)
76
+
77
+ For existing projects, we recommend starting with `/spec/audit` to understand the current state, then `/spec/sync` to create a retrospective specification. See `_shared/retrospective-spec-creation.md` for best practices."
78
+
79
+ **Wait for user decision.**
80
+
81
+ **If user chooses retrospective mode:**
82
+ - Reference `_shared/retrospective-spec-creation.md` helper
83
+ - Load helper sections: "Overview" and "Audit Strategy"
84
+ - Suggest command stack: `/spec/audit → /spec/sync → /spec/refine`
85
+ - Output: "For retrospective spec creation, start with `/spec/audit` to analyze the existing codebase, then `/spec/sync` to create the specification. I can guide you through this process if needed."
86
+ - Exit `/spec/init` and guide user to start with `/spec/audit`
87
+
88
+ **If user chooses new feature mode:**
89
+ - Set context flag: `mode: feature_adoption`
90
+ - Continue with `/spec/init` but add context about existing project
91
+ - Modify questions in Step 3 to include: "How does this feature integrate with existing architecture?"
92
+ - Reference existing tech stack from detection results
93
+ - Proceed to Step 1 with context
94
+
95
+ **If user chooses new project mode:**
96
+ - Set context flag: `mode: new_project`
97
+ - Continue with normal `/spec/init` workflow
98
+ - Proceed to Step 1
99
+
100
+ **Update State Assertion:**
101
+ - Set Context: "Existing project detected: [yes/no], Mode: [new/retrospective/feature]"
102
+
6
103
  Step 1 — Prompt the user
7
104
  Ask the user to pitch the idea freely in their own words.
8
105
  Explicitly state that the idea can be incomplete, messy, or uncertain.
@@ -19,26 +116,163 @@ Constraints:
19
116
  - Do NOT expand into execution, tasks, or implementation
20
117
  - If information is missing, mark it as uncertainty instead of guessing
21
118
 
22
- Step 3 — Clarify only what truly matters
23
- After the pitch:
24
- - Ask a small number of high-impact clarifying questions
25
- - Prioritize questions that affect scope, value, or feasibility
26
- - Avoid exhaustive checklists or domain deep dives
119
+ Step 3 — Structured Clarification (Socratic Questioning)
120
+
121
+ After the pitch, ask these 5 strategic questions in sequence. After each answer, you may ask 1-2 follow-up questions if clarification is needed, then move to the next question.
122
+
123
+ **Question 1: Problem and Goal**
124
+ - What problem does this project solve?
125
+ - What is the primary goal?
126
+ - Who experiences this problem?
127
+ - **Follow-up (if needed):** Ask 1-2 clarifying questions about the problem or goal, then proceed to Question 2
128
+
129
+ **Question 2: Must-Have Features**
130
+ - What are the must-have features for this project?
131
+ - What features are essential for the core value proposition?
132
+ - What can users not do without?
133
+ - **Follow-up (if needed):** Ask 1-2 clarifying questions about features, then proceed to Question 3
134
+
135
+ **Scope locking (important if the initial pitch includes “future vision”):**
136
+ - What is the smallest **MVP scope** we can ship first?
137
+ - Which items mentioned are explicitly **future ideas** (out of MVP scope) and should be parked for later?
138
+
139
+ **Question 3: Technical Requirements**
140
+ - Are there any technical requirements or constraints?
141
+ - Any specific technologies, frameworks, or platforms required?
142
+ - Any performance, security, or scalability requirements?
143
+ - **If existing project detected (mode: feature_adoption):**
144
+ - How does this feature integrate with existing architecture?
145
+ - Are there constraints from the current codebase?
146
+ - What existing patterns or conventions should be followed?
147
+ - Does this feature depend on existing infrastructure or services?
148
+ - **Follow-up (if needed):** Ask 1-2 clarifying questions about technical requirements, then proceed to Question 4
149
+
150
+ **Important:** When technical requirements are discussed, ensure tech stack is documented in `spec/08-infrastructure.md` or `spec/02-architecture.md` (if architecture is created) under "Technology Stack" section. This becomes the source of truth for framework/tool detection and rule activation.
151
+
152
+ **Question 4: Explicitly Out of Scope**
153
+ - What is explicitly out of scope for this project?
154
+ - What will this project NOT do?
155
+ - What features or capabilities are explicitly excluded?
156
+ - **Follow-up (if needed):** Ask 1-2 clarifying questions about scope boundaries, then proceed to Question 5
157
+
158
+ **Question 5: Additional Context**
159
+ - Is there anything else I should know about this project?
160
+ - Any constraints, assumptions, or context not yet covered?
161
+ - Any specific concerns or considerations?
162
+ - **Follow-up (if needed):** Ask 1-2 clarifying questions about additional context
163
+
164
+ **After the 5 questions, ask context-specific follow-ups:**
165
+
166
+ **Infrastructure questions (if applicable and not already covered):**
167
+ - Hosting preferences: Do you have existing hosting setup or preferences?
168
+ - Database preferences: Managed service vs. self-hosted? Budget constraints?
169
+ - External services: Newsletter platform, payment processing, analytics, etc.?
170
+ - CI/CD requirements: Automatic deployments, manual approval?
171
+
172
+ **Task management / Linear (if the team wants Linear sync):**
173
+ - Will this project use **Linear** for task tracking, or **local mode** only?
174
+ - If Linear:
175
+ - Can you provide (or will you set up) the Linear MCP connection in Cursor?
176
+ - Do you want SDD to auto-create: **milestone projects**, **task issues**, and **spec documents** in Linear?
177
+ - Do you use any non-standard statuses or labels in Linear (or should we use defaults)?
178
+ - If you have multiple Linear connections in Cursor: what is the `MCP_CONNECTION_NAME`?
179
+
180
+ **Design questions (if applicable and not already covered):**
181
+ - Design direction: Do you have existing brand guidelines, design system, or should it be defined?
182
+ - Visual style: Modern/minimalist/professional? Examples or references?
183
+ - Design constraints: Colors, typography preferences, accessibility requirements?
184
+
185
+ **Design system bootstrap (if design is critical):**
186
+ - If the project will ship UI and design choices will affect implementation quality, create `spec/07-design-system.md`.
187
+ - Use template: `spec/templates/07-design-system.md`
188
+ - Optional (Cursor 2.4+): use the skill `/sdd-design-system-bootstrap` to produce a concrete, non-placeholder design system early.
189
+
190
+ **Principles:**
191
+ - Ask the 5 structured questions first
192
+ - Allow 1-2 follow-up questions per structured question if clarification needed
193
+ - Then ask context-specific questions (infrastructure, design) if applicable
194
+ - Keep total questions focused and high-impact
195
+ - Avoid exhaustive checklists
27
196
 
28
197
  Step 4 — Write the initial specification
198
+
199
+ ## Verification Checkpoint (Before File Creation)
200
+
201
+ **Before creating spec/00-root-spec.md, verify:**
202
+
203
+ 1. **File doesn't exist:**
204
+ - Check if `spec/00-root-spec.md` exists
205
+ - If exists → ask: "File exists. Overwrite, append, or skip?"
206
+ - Wait for user decision
207
+
208
+ 2. **File path is correct:**
209
+ - Verify `spec/` directory exists (create if needed)
210
+ - Verify file naming: `00-root-spec.md`
211
+
212
+ 3. **Content aligns with command purpose:**
213
+ - Verify content matches /spec/init purpose: Create initial root specification
214
+ - Verify no conflicting information
215
+
216
+ 4. **User confirmation:**
217
+ - Ask: "Ready to create spec/00-root-spec.md?"
218
+ - Wait for confirmation before proceeding
219
+
29
220
  Create or update the following files:
30
- - `spec/00-root-spec.md`
31
- - `spec/03-risks.md`
32
- - `spec/04-open-questions.md`
221
+ - `spec/00-root-spec.md` - Root specification (always create)
222
+ - `spec/03-risks.md` - Project risks (always create)
223
+ - `spec/04-open-questions.md` - Open questions (always create)
224
+ - `spec/01-prd.md` - Product Requirements Document (optional, create if detailed PRD is needed)
225
+
226
+ Create or update the following files ONLY IF relevant and confirmed:
227
+ - `spec/08-infrastructure.md` - Technology stack and infrastructure (use template: `spec/templates/08-infrastructure.md`)
228
+ - **Note:** This file is the source of truth for framework/tool detection and rule activation.
229
+ - `spec/07-design-system.md` - Design system (use template: `spec/templates/07-design-system.md`)
230
+
231
+ **If Linear is desired (recommendation before `/spec/plan`):**
232
+ - Create `work/linear/sync-config.md` and set `MODE=linear` (see `work/linear/SETUP.md`)
233
+ - **Required (hard requirement for Linear sync in `/spec/plan`)**: provide status mapping keys:
234
+ - `STATUS_BACKLOG`, `STATUS_IN_PROGRESS`, `STATUS_DONE`, `STATUS_BLOCKED`
235
+ - Optional:
236
+ - `MCP_CONNECTION_NAME` (if multiple Linear MCP connections)
237
+ - `DEFAULT_TEAM_ID`
238
+ - `AUTO_ASSIGN_LABELS=true` (recommended; uses task tags → labels)
239
+ - `AUTO_CREATE_PROJECTS=true` (milestones → projects)
240
+ - `AUTO_CREATE_DOCUMENTS=true` (specs → documents)
241
+
242
+ **Populate files as follows:**
243
+
244
+ **spec/00-root-spec.md:**
245
+ - Idea overview (from Question 1: Problem and Goal)
246
+ - Motivation (why this project exists)
247
+ - Target users (from Question 1)
248
+ - Core value (from Question 1)
249
+ - Initial scope (from Question 2: Must-Have Features and Question 4: Out of Scope)
250
+ - Reference to PRD if created
251
+
252
+ **spec/01-prd.md (optional, create if detailed PRD needed):**
253
+ - Problem statement (from Question 1)
254
+ - Goal and objectives
255
+ - Must-have features (from Question 2)
256
+ - Technical requirements (from Question 3)
257
+ - Out of scope (from Question 4)
258
+ - Additional context (from Question 5)
259
+ - Success metrics
260
+
261
+ **spec/03-risks.md:**
262
+ - Only risks that are already visible at this early stage
263
+ - Technical risks (from Question 3)
264
+ - Scope risks (from Question 4)
265
+ - Other early risks
33
266
 
34
- Populate them as follows:
35
- - Root spec: concise summary of the idea, problem, users, value, and tentative scope
36
- - Risks: only risks that are already visible at this early stage
37
- - Open questions: unresolved assumptions or decisions that require input
267
+ **spec/04-open-questions.md:**
268
+ - Unresolved assumptions or decisions that require input
269
+ - Questions that emerged during the 5 structured questions
270
+ - Context-specific questions not yet answered
38
271
 
39
- Rules:
272
+ **Rules:**
40
273
  - Keep all content lightweight and editable
41
- - Do not create additional spec files
274
+ - Root spec should be concise (can reference PRD for details)
275
+ - PRD is optional - only create if detailed PRD is needed
42
276
  - Do not escalate to design or planning modes
43
277
 
44
278
  Step 5 — Report back
@@ -1,8 +1,58 @@
1
- You are moving the project from “Research / Ideation” into “Planning”.
1
+ You are a **Planning Architect** using Spec-Driven Development (SDD).
2
+
3
+ **Your role:** Planning Architect
4
+ **Your job:** Turn specifications into executable plans (milestones and tasks)
5
+ **Your context:** Project planning and task breakdown
2
6
 
3
7
  MODE: Planning
4
8
  GOAL: Turn the current specification into an executable plan (milestones + tasks) while keeping the spec consistent.
5
9
 
10
+ ---
11
+
12
+ ## State Assertion (REQUIRED)
13
+
14
+ **Before starting, output:**
15
+
16
+ **SDD MODE:** /spec/plan
17
+ - **Mode:** Planning
18
+ - **Recommended Cursor Mode:** Plan
19
+ - **Why:** This command creates execution plans (milestones, tasks) without code changes. Plan mode is optimal for this workflow.
20
+ - **Context:** [Will be populated after detection]
21
+ - **Active Rule Sets:** [Will be populated after activation]
22
+ - **Implementation:** BLOCKED
23
+ - **Boundaries:**
24
+ - WILL: Create milestones and tasks, define acceptance criteria, plan risk mitigation, adapt to project size/phase
25
+ - WILL NOT: Write code, implement features, skip spec validation
26
+
27
+ ---
28
+
29
+ ## Step 0 — Project Detection and Rule Activation
30
+
31
+ **Before starting, run detection and activation:**
32
+
33
+ 1. **Run Detection:**
34
+ - Detect project type, size, phase, technologies (see `_shared/detection.md`)
35
+ - Read from `.sdd/detection-cache.json` if valid, otherwise run detection
36
+ - Store detection results
37
+
38
+ 2. **Activate Rules:**
39
+ - Always activate foundation rules (00-pos, 01-sdd, 02-work-mode)
40
+ - Match detection results against rule metadata
41
+ - Activate relevant domain and technology rules (see `_shared/activation.md`)
42
+ - Output active rule list
43
+
44
+ 3. **Adapt Planning to Project Size/Phase:**
45
+ - **Small projects:** Simplified planning (2-3 milestones max, minimal task breakdown, lightweight acceptance criteria)
46
+ - **Medium projects:** Standard SDD workflow (3-5 milestones, standard task breakdown, standard acceptance criteria)
47
+ - **Large projects:** Extended planning (5-7 milestones, detailed task breakdown, comprehensive acceptance criteria)
48
+ - **Enterprise projects:** Complex planning (7+ milestones, very detailed task breakdown, enterprise acceptance criteria)
49
+ - **See `_shared/scaling.md` for detailed scaling logic**
50
+
51
+ 4. **Update State Assertion:**
52
+ - Include detection results in Context
53
+ - Include active rule sets in Active Rule Sets
54
+ - Include size/phase adaptations
55
+
6
56
  Inputs (source of truth):
7
57
  - `spec/00-root-spec.md`
8
58
  - `spec/03-risks.md`
@@ -17,13 +67,63 @@ Planning outputs
17
67
  A) Spec artifacts (create only if needed by planning)
18
68
  - Create or update `spec/01-prd.md` if the feature set needs to be made explicit.
19
69
  - Create or update `spec/06-acceptance.md` with high-level acceptance criteria / definition of done.
70
+ - Use template: `spec/templates/06-acceptance.md` (MVP ship checklist + quality gates)
71
+ - Create or update `spec/02-architecture.md` if architecture decisions are made or needed for planning.
72
+ - Use template: `spec/templates/02-architecture.md`
73
+
74
+ - Create or update `spec/08-infrastructure.md` if technology, environments, CI/CD, or hosting choices will affect the task breakdown.
75
+ - Use template: `spec/templates/08-infrastructure.md`
76
+ - **Note:** This file is the source of truth for framework/tool detection and rule activation.
77
+
78
+ - Create or update `spec/07-design-system.md` if UI/design decisions will materially affect planning or acceptance criteria.
79
+ - Use template: `spec/templates/07-design-system.md`
80
+ - Optional (Cursor 2.4+): use the skill `/sdd-design-system-bootstrap` before splitting design tasks
81
+
82
+ - Create or update `spec/09-sitemap.md` if the project ships UI (recommended for `projectType=web-app`).
83
+ - Use template: `spec/templates/09-sitemap.md`
84
+ - This is the source of truth for required pages, so tasks don’t “miss a screen” mid-implementation.
85
+
86
+ **When to create architecture.md:**
87
+ - Architecture decisions are made during planning
88
+ - System design is needed to break down tasks
89
+ - Component structure needs to be defined
90
+ - Data flow needs to be documented
91
+ - Multiple systems/components need to interact
92
+
93
+ **If architecture is needed but not yet decided:**
94
+ - Add architecture questions to `spec/04-open-questions.md`
95
+ - Proceed with planning using assumptions
96
+ - Mark architecture as "to be decided" in tasks
20
97
 
21
98
  Rules for spec artifacts:
22
- - Stay high-level. Do not write deep architecture.
99
+ - Stay high-level. Do not write deep architecture unless it's critical for task breakdown.
23
100
  - Do not introduce new features that were not implied by the root spec.
24
101
  - If you suggest a new requirement, mark it as a question or assumption.
25
102
 
26
103
  B) Execution artifacts (always produce these)
104
+
105
+ ## Verification Checkpoint (Before File Creation)
106
+
107
+ **Before creating work/backlog/tasks.local.md, verify:**
108
+
109
+ 1. **File doesn't exist:**
110
+ - Check if `work/backlog/tasks.local.md` exists
111
+ - If exists → ask: "File exists. Overwrite, append, or skip?"
112
+ - Wait for user decision
113
+
114
+ 2. **File path is correct:**
115
+ - Verify `work/backlog/` directory exists (create if needed)
116
+ - Verify file naming: `tasks.local.md`
117
+
118
+ 3. **Content aligns with command purpose:**
119
+ - Verify content matches /spec/plan purpose: Create task definitions
120
+ - Verify tasks are traceable to spec
121
+ - Verify no conflicting information
122
+
123
+ 4. **User confirmation:**
124
+ - Ask: "Ready to create work/backlog/tasks.local.md?"
125
+ - Wait for confirmation before proceeding
126
+
27
127
  Create or update:
28
128
  - `work/backlog/milestones.md`
29
129
  - `work/backlog/tasks.local.md`
@@ -37,16 +137,211 @@ Tasks requirements:
37
137
  - Each task has: description, acceptance signal, dependencies, and rough estimate (S/M/L).
38
138
  - Keep tasks implementation-agnostic unless necessary.
39
139
 
140
+ **Task structure (for tasks.local.md):**
141
+ Each task should include:
142
+ - **Description:** Task description (what needs to be done)
143
+ - **Status:** backlog | in-progress | done | blocked (default: backlog)
144
+ - **Assignee:** [name/email] (optional)
145
+ - **Tags:** [comma-separated tags, e.g., design, frontend, infrastructure] (optional)
146
+ - **Milestone:** [Milestone ID, e.g., M1]
147
+ - **Sprint:** [Sprint ID] (optional)
148
+ - **Acceptance:** Acceptance criteria (how to verify completion)
149
+ - **Dependencies:** [Task IDs that must be completed first] (optional)
150
+ - **Estimate:** S | M | L (Small, Medium, Large)
151
+ - **Notes:** [Additional notes] (optional)
152
+
153
+ **Task quality requirements:**
154
+ - Tasks should be small enough to validate in one session (max 2-3 hours work)
155
+ - If a task covers multiple concerns, consider splitting it
156
+ - Design system tasks should be split: colors, typography, spacing, components
157
+
158
+ **External service selection tasks:**
159
+ - Must include evaluation criteria (pricing, features, integration quality, API quality)
160
+ - Must include comparison matrix (minimum 3 options)
161
+ - Must include decision deadline (before dependent tasks start)
162
+ - Example structure for service selection task:
163
+ - Evaluation criteria: pricing, API quality, webhook support, data export capabilities
164
+ - Comparison: Option A vs. Option B vs. Option C (with pros/cons)
165
+ - Decision deadline: Before [dependent task ID] starts
166
+
167
+ **Infrastructure setup tasks:**
168
+ - Must include prerequisites (accounts, credentials, domain, etc.)
169
+ - Must include provider selection criteria (if not already decided)
170
+ - Must include environment variables required
171
+ - Must include CI/CD setup requirements
172
+
40
173
  C) Risk-driven planning
41
174
  - Update `spec/03-risks.md` with any planning-discovered risks.
42
175
  - For the top 3 risks, add a concrete mitigation task into `tasks.local.md`.
43
176
 
44
177
  D) Optional: Linear integration (ONLY if configured)
45
- - Check if `work/linear/sync-config.md` exists.
46
- - If it exists and declares `MODE=linear`, then in addition to local files:
47
- - Propose a Linear structure (Project + Epics + Issues) that mirrors the milestones.
48
- - Ask for confirmation before creating/updating anything in Linear.
49
- - If it does not exist or is not set to linear: keep everything local.
178
+
179
+ **ONLY READ IF Linear mode enabled:**
180
+ - Read `.cursor/commands/_shared/linear-automation.md` ONLY IF `work/linear/sync-config.md` exists AND `MODE=linear`
181
+ - Auto-loads: `linear-helpers.md` (dependency)
182
+ - Read sections: "Detection Logic" (lines 9-32), "Projects" (lines 132-180), "Issues" (lines 82-130) from linear-automation.md
183
+ - Read sections from linear-helpers.md (auto-loaded): "Status Mapping" (lines 1-50)
184
+ - Skip if: Linear mode not enabled → skip Linear integration entirely
185
+ - Check condition: Verify Linear mode before reading helpers
186
+
187
+ **D.1) Linear Setup Check:**
188
+
189
+ 1. **Check if Linear mode is enabled:**
190
+ - Check if `work/linear/sync-config.md` exists
191
+ - If not exists → guide user: "Linear mode er ikke aktiveret. For at aktivere Linear integration, opret `work/linear/sync-config.md` med `MODE=linear`. Se `work/linear/SETUP.md` for setup instruktioner."
192
+ - If exists but `MODE=linear` not set → use local mode only
193
+
194
+ 2. **Verify Linear MCP availability:**
195
+ - Test Linear MCP connection (try `list_teams`)
196
+ - If MCP unavailable → report: "Linear MCP er utilgængelig. Fortsætter med local mode."
197
+ - Continue workflow with local mode only
198
+
199
+ 3. **Check configuration completeness (if Linear mode enabled):**
200
+ - **HARD STOP (planning) if config is incomplete.** If `MODE=linear` is enabled but any of the required keys are missing, stop and require the user to fix `work/linear/sync-config.md` before continuing Linear sync:
201
+ - Required keys:
202
+ - `STATUS_BACKLOG`
203
+ - `STATUS_IN_PROGRESS`
204
+ - `STATUS_DONE`
205
+ - `STATUS_BLOCKED`
206
+ - Provide a recommended minimal snippet (names are fine; IDs optional):
207
+ ```
208
+ MODE=linear
209
+ STATUS_BACKLOG=Backlog
210
+ STATUS_IN_PROGRESS=In Progress
211
+ STATUS_DONE=Done
212
+ STATUS_BLOCKED=Blocked
213
+ AUTO_ASSIGN_LABELS=true
214
+ AUTO_CREATE_PROJECTS=true
215
+ AUTO_CREATE_DOCUMENTS=true
216
+ ```
217
+ - Explain what the system can do automatically once config is complete:
218
+ - Create milestone projects (if `AUTO_CREATE_PROJECTS=true`)
219
+ - Create/update task issues (status + labels + project linkage)
220
+ - Create/update spec documents (if `AUTO_CREATE_DOCUMENTS=true`)
221
+ - Add structured comments on task start/validate
222
+ - Ask the user what they need to provide manually (if not known):
223
+ - `MCP_CONNECTION_NAME` (if multiple Linear MCP connections)
224
+ - `DEFAULT_TEAM_ID` (optional)
225
+ - Whether they use custom status names (otherwise defaults)
226
+ - Reference:
227
+ - `work/linear/SETUP.md` (setup)
228
+ - `work/linear/LABEL-MAPPING-GUIDE.md` (tags → labels; avoid “feature everywhere”)
229
+ - `work/linear/FALLBACK-STRATEGY.md` (failures fallback; do not block)
230
+
231
+ **D.2) Linear Projects Creation (if Linear mode enabled and AUTO_CREATE_PROJECTS=true):**
232
+
233
+ 1. **For each milestone in milestones.md:**
234
+ - Check if Linear project exists (use idempotency check from linear-helpers.md)
235
+ - If exists → skip or update (ask user)
236
+ - If not exists → ask user: "Skal jeg oprette Linear projects for milestones?"
237
+ - If yes → create Linear project:
238
+ - Project name: Milestone objective (first line)
239
+ - Project description: Full milestone details (objective, scope, exit criteria)
240
+ - Project status: Set to "Active" (or default status)
241
+ - Project team: Assign to default team (if DEFAULT_TEAM_ID configured)
242
+ - Link all milestone tasks (issues) to project after creation
243
+
244
+ **D.3) Linear Issues Creation (if Linear mode enabled):**
245
+
246
+ 1. **For each task in tasks.local.md:**
247
+ - Check if Linear issue exists (use idempotency check from linear-helpers.md)
248
+ - If exists → skip or update (ask user)
249
+ - If not exists → ask user: "Skal jeg oprette Linear issues for tasks?"
250
+ - If yes → create Linear issue:
251
+ - Issue title: `[task-id] – [task description]` (include task ID for stable idempotency)
252
+ - Issue description: Full task details (description, acceptance, dependencies, estimate)
253
+ - Issue status: Map to "Backlog" (use status mapping from linear-helpers.md)
254
+ - Issue priority: Map from estimate (S=Low, M=Medium, L=High)
255
+ - Issue labels: Auto-assign based on task type (use label detection from linear-helpers.md)
256
+ - Issue project: Link to milestone project (if created in D.2)
257
+ - Issue team: Assign to default team (if DEFAULT_TEAM_ID configured)
258
+
259
+ **D.4) Linear Documents Creation (if Linear mode enabled and AUTO_CREATE_DOCUMENTS=true):**
260
+
261
+ 1. **If PRD is created (`spec/01-prd.md`):**
262
+ - Check if Linear document exists (use idempotency check)
263
+ - If exists → update with PRD content
264
+ - If not exists → create Linear document:
265
+ - Document title: `[Project Name] - PRD`
266
+ - Document content: Full PRD content from `spec/01-prd.md`
267
+ - Link document to Linear project (if project exists)
268
+
269
+ 2. **If architecture is created (`spec/02-architecture.md`):**
270
+ - Check if Linear document exists (use idempotency check)
271
+ - If exists → update with architecture content
272
+ - If not exists → create Linear document:
273
+ - Document title: `[Project Name] - Architecture`
274
+ - Document content: Full architecture content from `spec/02-architecture.md`
275
+ - Link document to Linear project (if project exists)
276
+
277
+ 3. **If acceptance criteria are created (`spec/06-acceptance.md`):**
278
+ - Check if Linear document exists (use idempotency check)
279
+ - If exists → update with acceptance criteria content
280
+ - If not exists → create Linear document:
281
+ - Document title: `[Project Name] - Acceptance Criteria`
282
+ - Document content: Full acceptance criteria from `spec/06-acceptance.md`
283
+ - Link document to Linear project (if project exists)
284
+
285
+ **Error Handling:**
286
+ - If any Linear operation fails → log error, continue with local mode
287
+ - Never block workflow due to Linear errors
288
+ - Report errors to user clearly
289
+ - Allow user to retry or skip Linear operations
290
+
291
+ E) Optional: GitHub Actions Workflow Generation (if needed)
292
+
293
+ **ONLY READ IF CI/CD needed:**
294
+ - Read `.cursor/commands/_shared/github-workflows.md` ONLY IF CI/CD needed (based on project size/type)
295
+ - Read sections: "Workflow Detection" (lines 1-50), "Workflow Generation" (lines 51-200)
296
+ - Skip if: Small basic website OR CI/CD not needed → skip GitHub Actions generation entirely
297
+ - Check condition: Assess project size/type first, then read helper only if CI/CD needed
298
+
299
+ **E.1) Check if Workflows Needed:**
300
+
301
+ 1. **Read project complexity from detection:**
302
+ - Use detection results (project type, size, phase)
303
+ - Check if workflows are needed based on complexity:
304
+ - **Small + basic website:** Skip workflow generation
305
+ - **Medium+ web-app/api:** Workflows recommended
306
+ - **Large/Enterprise:** Workflows required
307
+
308
+ 2. **Check deployment requirements:**
309
+ - Read `spec/08-infrastructure.md` for deployment configuration
310
+ - If deployment defined → workflows needed
311
+
312
+ **E.2) Generate Workflows (if needed):**
313
+
314
+ 1. **Ask user for confirmation:**
315
+ - Prompt: "GitHub Actions workflows are recommended for this project. Generate workflows? (y/n)"
316
+ - If user declines → skip workflow generation
317
+ - If user confirms → proceed
318
+
319
+ 2. **Generate workflows:**
320
+ - Use `github-workflows.md` helper for generation logic
321
+ - Create `.github/workflows/` directory if needed
322
+ - Generate appropriate workflow files:
323
+ - `ci.yml` (for medium+ projects)
324
+ - `pr-checks.yml` (for large/enterprise projects)
325
+ - `deploy.yml` (for projects with deployment)
326
+
327
+ 3. **Framework-specific adaptations:**
328
+ - Detect framework from tech stack (spec/08-infrastructure.md or spec/02-architecture.md)
329
+ - Adapt workflow commands based on framework
330
+ - Use appropriate package manager (npm, pnpm, yarn)
331
+
332
+ 4. **Document workflows:**
333
+ - Update `spec/08-infrastructure.md` with GitHub Actions section
334
+ - List generated workflow files
335
+ - Document CI checks and deployment strategy
336
+
337
+ **Error Handling:**
338
+ - If workflow generation fails → report to user, continue without workflows
339
+ - If GitHub not available → skip workflow generation, continue workflow
340
+ - Don't block workflow if generation fails
341
+
342
+ **If Linear mode is not enabled or not configured:**
343
+ - Keep everything local (no Linear operations)
344
+ - Workflow continues normally with local files only
50
345
 
51
346
  Step-by-step deliverable
52
347
  1) A short “Planning Summary” in chat: what you planned and what remains uncertain.