@eskoubar95/spec 0.1.3 → 0.1.4

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eskoubar95/spec",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "private": false,
5
5
  "bin": {
6
6
  "spec": "dist/index.js"
@@ -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,130 @@ 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
+ **Question 3: Technical Requirements**
136
+ - Are there any technical requirements or constraints?
137
+ - Any specific technologies, frameworks, or platforms required?
138
+ - Any performance, security, or scalability requirements?
139
+ - **If existing project detected (mode: feature_adoption):**
140
+ - How does this feature integrate with existing architecture?
141
+ - Are there constraints from the current codebase?
142
+ - What existing patterns or conventions should be followed?
143
+ - Does this feature depend on existing infrastructure or services?
144
+ - **Follow-up (if needed):** Ask 1-2 clarifying questions about technical requirements, then proceed to Question 4
145
+
146
+ **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.
147
+
148
+ **Question 4: Explicitly Out of Scope**
149
+ - What is explicitly out of scope for this project?
150
+ - What will this project NOT do?
151
+ - What features or capabilities are explicitly excluded?
152
+ - **Follow-up (if needed):** Ask 1-2 clarifying questions about scope boundaries, then proceed to Question 5
153
+
154
+ **Question 5: Additional Context**
155
+ - Is there anything else I should know about this project?
156
+ - Any constraints, assumptions, or context not yet covered?
157
+ - Any specific concerns or considerations?
158
+ - **Follow-up (if needed):** Ask 1-2 clarifying questions about additional context
159
+
160
+ **After the 5 questions, ask context-specific follow-ups:**
161
+
162
+ **Infrastructure questions (if applicable and not already covered):**
163
+ - Hosting preferences: Do you have existing hosting setup or preferences?
164
+ - Database preferences: Managed service vs. self-hosted? Budget constraints?
165
+ - External services: Newsletter platform, payment processing, analytics, etc.?
166
+ - CI/CD requirements: Automatic deployments, manual approval?
167
+
168
+ **Design questions (if applicable and not already covered):**
169
+ - Design direction: Do you have existing brand guidelines, design system, or should it be defined?
170
+ - Visual style: Modern/minimalist/professional? Examples or references?
171
+ - Design constraints: Colors, typography preferences, accessibility requirements?
172
+
173
+ **Principles:**
174
+ - Ask the 5 structured questions first
175
+ - Allow 1-2 follow-up questions per structured question if clarification needed
176
+ - Then ask context-specific questions (infrastructure, design) if applicable
177
+ - Keep total questions focused and high-impact
178
+ - Avoid exhaustive checklists
27
179
 
28
180
  Step 4 — Write the initial specification
181
+
182
+ ## Verification Checkpoint (Before File Creation)
183
+
184
+ **Before creating spec/00-root-spec.md, verify:**
185
+
186
+ 1. **File doesn't exist:**
187
+ - Check if `spec/00-root-spec.md` exists
188
+ - If exists → ask: "File exists. Overwrite, append, or skip?"
189
+ - Wait for user decision
190
+
191
+ 2. **File path is correct:**
192
+ - Verify `spec/` directory exists (create if needed)
193
+ - Verify file naming: `00-root-spec.md`
194
+
195
+ 3. **Content aligns with command purpose:**
196
+ - Verify content matches /spec/init purpose: Create initial root specification
197
+ - Verify no conflicting information
198
+
199
+ 4. **User confirmation:**
200
+ - Ask: "Ready to create spec/00-root-spec.md?"
201
+ - Wait for confirmation before proceeding
202
+
29
203
  Create or update the following files:
30
- - `spec/00-root-spec.md`
31
- - `spec/03-risks.md`
32
- - `spec/04-open-questions.md`
204
+ - `spec/00-root-spec.md` - Root specification (always create)
205
+ - `spec/03-risks.md` - Project risks (always create)
206
+ - `spec/04-open-questions.md` - Open questions (always create)
207
+ - `spec/01-prd.md` - Product Requirements Document (optional, create if detailed PRD is needed)
208
+
209
+ **Populate files as follows:**
210
+
211
+ **spec/00-root-spec.md:**
212
+ - Idea overview (from Question 1: Problem and Goal)
213
+ - Motivation (why this project exists)
214
+ - Target users (from Question 1)
215
+ - Core value (from Question 1)
216
+ - Initial scope (from Question 2: Must-Have Features and Question 4: Out of Scope)
217
+ - Reference to PRD if created
218
+
219
+ **spec/01-prd.md (optional, create if detailed PRD needed):**
220
+ - Problem statement (from Question 1)
221
+ - Goal and objectives
222
+ - Must-have features (from Question 2)
223
+ - Technical requirements (from Question 3)
224
+ - Out of scope (from Question 4)
225
+ - Additional context (from Question 5)
226
+ - Success metrics
227
+
228
+ **spec/03-risks.md:**
229
+ - Only risks that are already visible at this early stage
230
+ - Technical risks (from Question 3)
231
+ - Scope risks (from Question 4)
232
+ - Other early risks
33
233
 
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
234
+ **spec/04-open-questions.md:**
235
+ - Unresolved assumptions or decisions that require input
236
+ - Questions that emerged during the 5 structured questions
237
+ - Context-specific questions not yet answered
38
238
 
39
- Rules:
239
+ **Rules:**
40
240
  - Keep all content lightweight and editable
41
- - Do not create additional spec files
241
+ - Root spec should be concise (can reference PRD for details)
242
+ - PRD is optional - only create if detailed PRD is needed
42
243
  - Do not escalate to design or planning modes
43
244
 
44
245
  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,49 @@ 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
+ - Create or update `spec/02-architecture.md` if architecture decisions are made or needed for planning.
71
+
72
+ **When to create architecture.md:**
73
+ - Architecture decisions are made during planning
74
+ - System design is needed to break down tasks
75
+ - Component structure needs to be defined
76
+ - Data flow needs to be documented
77
+ - Multiple systems/components need to interact
78
+
79
+ **If architecture is needed but not yet decided:**
80
+ - Add architecture questions to `spec/04-open-questions.md`
81
+ - Proceed with planning using assumptions
82
+ - Mark architecture as "to be decided" in tasks
20
83
 
21
84
  Rules for spec artifacts:
22
- - Stay high-level. Do not write deep architecture.
85
+ - Stay high-level. Do not write deep architecture unless it's critical for task breakdown.
23
86
  - Do not introduce new features that were not implied by the root spec.
24
87
  - If you suggest a new requirement, mark it as a question or assumption.
25
88
 
26
89
  B) Execution artifacts (always produce these)
90
+
91
+ ## Verification Checkpoint (Before File Creation)
92
+
93
+ **Before creating work/backlog/tasks.local.md, verify:**
94
+
95
+ 1. **File doesn't exist:**
96
+ - Check if `work/backlog/tasks.local.md` exists
97
+ - If exists → ask: "File exists. Overwrite, append, or skip?"
98
+ - Wait for user decision
99
+
100
+ 2. **File path is correct:**
101
+ - Verify `work/backlog/` directory exists (create if needed)
102
+ - Verify file naming: `tasks.local.md`
103
+
104
+ 3. **Content aligns with command purpose:**
105
+ - Verify content matches /spec/plan purpose: Create task definitions
106
+ - Verify tasks are traceable to spec
107
+ - Verify no conflicting information
108
+
109
+ 4. **User confirmation:**
110
+ - Ask: "Ready to create work/backlog/tasks.local.md?"
111
+ - Wait for confirmation before proceeding
112
+
27
113
  Create or update:
28
114
  - `work/backlog/milestones.md`
29
115
  - `work/backlog/tasks.local.md`
@@ -37,16 +123,191 @@ Tasks requirements:
37
123
  - Each task has: description, acceptance signal, dependencies, and rough estimate (S/M/L).
38
124
  - Keep tasks implementation-agnostic unless necessary.
39
125
 
126
+ **Task structure (for tasks.local.md):**
127
+ Each task should include:
128
+ - **Description:** Task description (what needs to be done)
129
+ - **Status:** backlog | in-progress | done | blocked (default: backlog)
130
+ - **Assignee:** [name/email] (optional)
131
+ - **Tags:** [comma-separated tags, e.g., design, frontend, infrastructure] (optional)
132
+ - **Milestone:** [Milestone ID, e.g., M1]
133
+ - **Sprint:** [Sprint ID] (optional)
134
+ - **Acceptance:** Acceptance criteria (how to verify completion)
135
+ - **Dependencies:** [Task IDs that must be completed first] (optional)
136
+ - **Estimate:** S | M | L (Small, Medium, Large)
137
+ - **Notes:** [Additional notes] (optional)
138
+
139
+ **Task quality requirements:**
140
+ - Tasks should be small enough to validate in one session (max 2-3 hours work)
141
+ - If a task covers multiple concerns, consider splitting it
142
+ - Design system tasks should be split: colors, typography, spacing, components
143
+
144
+ **External service selection tasks:**
145
+ - Must include evaluation criteria (pricing, features, integration quality, API quality)
146
+ - Must include comparison matrix (minimum 3 options)
147
+ - Must include decision deadline (before dependent tasks start)
148
+ - Example structure for service selection task:
149
+ - Evaluation criteria: pricing, API quality, webhook support, data export capabilities
150
+ - Comparison: Option A vs. Option B vs. Option C (with pros/cons)
151
+ - Decision deadline: Before [dependent task ID] starts
152
+
153
+ **Infrastructure setup tasks:**
154
+ - Must include prerequisites (accounts, credentials, domain, etc.)
155
+ - Must include provider selection criteria (if not already decided)
156
+ - Must include environment variables required
157
+ - Must include CI/CD setup requirements
158
+
40
159
  C) Risk-driven planning
41
160
  - Update `spec/03-risks.md` with any planning-discovered risks.
42
161
  - For the top 3 risks, add a concrete mitigation task into `tasks.local.md`.
43
162
 
44
163
  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.
164
+
165
+ **ONLY READ IF Linear mode enabled:**
166
+ - Read `.cursor/commands/_shared/linear-automation.md` ONLY IF `work/linear/sync-config.md` exists AND `MODE=linear`
167
+ - Auto-loads: `linear-helpers.md` (dependency)
168
+ - Read sections: "Detection Logic" (lines 9-32), "Projects" (lines 132-180), "Issues" (lines 82-130) from linear-automation.md
169
+ - Read sections from linear-helpers.md (auto-loaded): "Status Mapping" (lines 1-50)
170
+ - Skip if: Linear mode not enabled → skip Linear integration entirely
171
+ - Check condition: Verify Linear mode before reading helpers
172
+
173
+ **D.1) Linear Setup Check:**
174
+
175
+ 1. **Check if Linear mode is enabled:**
176
+ - Check if `work/linear/sync-config.md` exists
177
+ - 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."
178
+ - If exists but `MODE=linear` not set → use local mode only
179
+
180
+ 2. **Verify Linear MCP availability:**
181
+ - Test Linear MCP connection (try `list_teams`)
182
+ - If MCP unavailable → report: "Linear MCP er utilgængelig. Fortsætter med local mode."
183
+ - Continue workflow with local mode only
184
+
185
+ 3. **Check configuration completeness (if Linear mode enabled):**
186
+ - If status mapping is missing → guide user:
187
+ ```
188
+ "Linear mode er aktiveret. Før vi kan synkronisere, skal du:
189
+ 1. Gå ind i Linear og oprette custom statuser (hvis nødvendigt)
190
+ 2. Gå ind i Linear og oprette custom labels (hvis nødvendigt)
191
+ 3. Opdater sync-config.md med status IDs eller names
192
+
193
+ Se work/linear/SETUP.md for detaljerede instruktioner."
194
+ ```
195
+ - Reference `work/linear/SETUP.md` for setup instructions
196
+
197
+ **D.2) Linear Projects Creation (if Linear mode enabled and AUTO_CREATE_PROJECTS=true):**
198
+
199
+ 1. **For each milestone in milestones.md:**
200
+ - Check if Linear project exists (use idempotency check from linear-helpers.md)
201
+ - If exists → skip or update (ask user)
202
+ - If not exists → ask user: "Skal jeg oprette Linear projects for milestones?"
203
+ - If yes → create Linear project:
204
+ - Project name: Milestone objective (first line)
205
+ - Project description: Full milestone details (objective, scope, exit criteria)
206
+ - Project status: Set to "Active" (or default status)
207
+ - Project team: Assign to default team (if DEFAULT_TEAM_ID configured)
208
+ - Link all milestone tasks (issues) to project after creation
209
+
210
+ **D.3) Linear Issues Creation (if Linear mode enabled):**
211
+
212
+ 1. **For each task in tasks.local.md:**
213
+ - Check if Linear issue exists (use idempotency check from linear-helpers.md)
214
+ - If exists → skip or update (ask user)
215
+ - If not exists → ask user: "Skal jeg oprette Linear issues for tasks?"
216
+ - If yes → create Linear issue:
217
+ - Issue title: Task description (first line)
218
+ - Issue description: Full task details (description, acceptance, dependencies, estimate)
219
+ - Issue status: Map to "Backlog" (use status mapping from linear-helpers.md)
220
+ - Issue priority: Map from estimate (S=Low, M=Medium, L=High)
221
+ - Issue labels: Auto-assign based on task type (use label detection from linear-helpers.md)
222
+ - Issue project: Link to milestone project (if created in D.2)
223
+ - Issue team: Assign to default team (if DEFAULT_TEAM_ID configured)
224
+
225
+ **D.4) Linear Documents Creation (if Linear mode enabled and AUTO_CREATE_DOCUMENTS=true):**
226
+
227
+ 1. **If PRD is created (`spec/01-prd.md`):**
228
+ - Check if Linear document exists (use idempotency check)
229
+ - If exists → update with PRD content
230
+ - If not exists → create Linear document:
231
+ - Document title: `[Project Name] - PRD`
232
+ - Document content: Full PRD content from `spec/01-prd.md`
233
+ - Link document to Linear project (if project exists)
234
+
235
+ 2. **If architecture is created (`spec/02-architecture.md`):**
236
+ - Check if Linear document exists (use idempotency check)
237
+ - If exists → update with architecture content
238
+ - If not exists → create Linear document:
239
+ - Document title: `[Project Name] - Architecture`
240
+ - Document content: Full architecture content from `spec/02-architecture.md`
241
+ - Link document to Linear project (if project exists)
242
+
243
+ 3. **If acceptance criteria are created (`spec/06-acceptance.md`):**
244
+ - Check if Linear document exists (use idempotency check)
245
+ - If exists → update with acceptance criteria content
246
+ - If not exists → create Linear document:
247
+ - Document title: `[Project Name] - Acceptance Criteria`
248
+ - Document content: Full acceptance criteria from `spec/06-acceptance.md`
249
+ - Link document to Linear project (if project exists)
250
+
251
+ **Error Handling:**
252
+ - If any Linear operation fails → log error, continue with local mode
253
+ - Never block workflow due to Linear errors
254
+ - Report errors to user clearly
255
+ - Allow user to retry or skip Linear operations
256
+
257
+ E) Optional: GitHub Actions Workflow Generation (if needed)
258
+
259
+ **ONLY READ IF CI/CD needed:**
260
+ - Read `.cursor/commands/_shared/github-workflows.md` ONLY IF CI/CD needed (based on project size/type)
261
+ - Read sections: "Workflow Detection" (lines 1-50), "Workflow Generation" (lines 51-200)
262
+ - Skip if: Small basic website OR CI/CD not needed → skip GitHub Actions generation entirely
263
+ - Check condition: Assess project size/type first, then read helper only if CI/CD needed
264
+
265
+ **E.1) Check if Workflows Needed:**
266
+
267
+ 1. **Read project complexity from detection:**
268
+ - Use detection results (project type, size, phase)
269
+ - Check if workflows are needed based on complexity:
270
+ - **Small + basic website:** Skip workflow generation
271
+ - **Medium+ web-app/api:** Workflows recommended
272
+ - **Large/Enterprise:** Workflows required
273
+
274
+ 2. **Check deployment requirements:**
275
+ - Read `spec/08-infrastructure.md` for deployment configuration
276
+ - If deployment defined → workflows needed
277
+
278
+ **E.2) Generate Workflows (if needed):**
279
+
280
+ 1. **Ask user for confirmation:**
281
+ - Prompt: "GitHub Actions workflows are recommended for this project. Generate workflows? (y/n)"
282
+ - If user declines → skip workflow generation
283
+ - If user confirms → proceed
284
+
285
+ 2. **Generate workflows:**
286
+ - Use `github-workflows.md` helper for generation logic
287
+ - Create `.github/workflows/` directory if needed
288
+ - Generate appropriate workflow files:
289
+ - `ci.yml` (for medium+ projects)
290
+ - `pr-checks.yml` (for large/enterprise projects)
291
+ - `deploy.yml` (for projects with deployment)
292
+
293
+ 3. **Framework-specific adaptations:**
294
+ - Detect framework from tech stack (spec/08-infrastructure.md or spec/02-architecture.md)
295
+ - Adapt workflow commands based on framework
296
+ - Use appropriate package manager (npm, pnpm, yarn)
297
+
298
+ 4. **Document workflows:**
299
+ - Update `spec/08-infrastructure.md` with GitHub Actions section
300
+ - List generated workflow files
301
+ - Document CI checks and deployment strategy
302
+
303
+ **Error Handling:**
304
+ - If workflow generation fails → report to user, continue without workflows
305
+ - If GitHub not available → skip workflow generation, continue workflow
306
+ - Don't block workflow if generation fails
307
+
308
+ **If Linear mode is not enabled or not configured:**
309
+ - Keep everything local (no Linear operations)
310
+ - Workflow continues normally with local files only
50
311
 
51
312
  Step-by-step deliverable
52
313
  1) A short “Planning Summary” in chat: what you planned and what remains uncertain.
@@ -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,37 @@ 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
+ **F) Infrastructure decisions (if infrastructure is critical)**
106
+ - Hosting provider preferences
107
+ - Database provider preferences
108
+ - CI/CD requirements
109
+ - Environment management (dev/staging/prod)
110
+ - External service selection criteria
111
+ - **Technology Stack:** Document chosen frameworks, tools, and libraries in `spec/08-infrastructure.md` or `spec/02-architecture.md` under "Technology Stack" section
112
+ - This becomes the source of truth for framework/tool detection and rule activation
113
+ - Format: "Frontend Framework: [name], CMS: [name], Database: [name], etc."
114
+
115
+ **G) Architecture decisions (if architecture is critical)**
116
+ - System architecture and component design
117
+ - Data flow and component interactions
118
+ - Design patterns and architectural patterns
119
+ - API structure (if applicable)
120
+ - Security architecture (if critical)
121
+
122
+ **If architecture decisions are made:**
123
+ - Create or update `spec/02-architecture.md` (use template from `spec/templates/02-architecture.md`)
124
+ - Document architecture decisions in `spec/05-decisions.md`
125
+
56
126
  File creation rules:
57
127
  - Only create `spec/05-decisions.md` if an explicit decision is identified.
58
- - Do NOT create PRD, architecture, acceptance, or planning files.
128
+ - Only create `spec/02-architecture.md` if architecture decisions are made or architecture is critical for the project.
129
+ - Do NOT create PRD, acceptance, or planning files.
59
130
 
60
131
  After refinement:
61
132
  1) Update the relevant spec files.