@eskoubar95/spec 0.1.2 → 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 +1 -1
- package/template/.cursor/commands/spec/init.md +216 -15
- package/template/.cursor/commands/spec/plan.md +268 -7
- package/template/.cursor/commands/spec/refine.md +73 -2
- package/template/.cursor/commands/task/start.md +296 -5
- package/template/.cursor/commands/task/validate.md +392 -1
- package/template/.cursor/rules/02-work-mode.mdc +71 -0
- package/template/.cursor/rules/openmemory.mdc +1 -1
|
@@ -1,22 +1,197 @@
|
|
|
1
|
-
You are
|
|
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
|
|
|
11
76
|
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
77
|
|
|
15
|
-
|
|
78
|
+
**Support for både local og Linear tasks:**
|
|
79
|
+
|
|
80
|
+
1. **Local Task:**
|
|
81
|
+
- User provides: `/task/start t1.2` (task ID fra tasks.local.md)
|
|
82
|
+
- Read task from `work/backlog/tasks.local.md`
|
|
83
|
+
- Verify task exists in file
|
|
84
|
+
- Use task ID as-is for task-level spec path: `spec/tasks/t1.2/`
|
|
85
|
+
|
|
86
|
+
2. **Linear Task:**
|
|
87
|
+
- User provides: `/task/start LIN-123` (Linear issue ID)
|
|
88
|
+
- Check if `work/linear/sync-config.md` exists and `MODE=linear`
|
|
89
|
+
- If Linear MCP available → fetch issue from Linear using Linear MCP
|
|
90
|
+
- Use Linear issue ID for task-level spec path: `spec/tasks/LIN-123/`
|
|
91
|
+
- If Linear MCP not available → ask user to provide task details manually
|
|
92
|
+
|
|
93
|
+
**Step 1.1) Linear Issue Sync (if Linear task and Linear mode enabled):**
|
|
94
|
+
|
|
95
|
+
**ONLY READ IF Linear mode enabled AND task is Linear issue:**
|
|
96
|
+
- 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`)
|
|
97
|
+
- Auto-loads: `linear-helpers.md` (dependency)
|
|
98
|
+
- Read sections: "Detection Logic" (lines 9-32), "Issues" (lines 82-130) from linear-automation.md
|
|
99
|
+
- Read sections from linear-helpers.md (auto-loaded): "Status Mapping" (lines 1-50)
|
|
100
|
+
- Skip if: Linear mode not enabled OR task is local only → skip Linear sync entirely
|
|
101
|
+
- Check condition: Verify Linear mode and task format before reading helpers
|
|
102
|
+
|
|
103
|
+
1. **Fetch Linear issue:**
|
|
104
|
+
- Use Linear MCP `get_issue` to fetch issue details
|
|
105
|
+
- If issue not found → error: "Linear issue [ID] ikke fundet"
|
|
106
|
+
- If issue found → use issue details for task context
|
|
107
|
+
|
|
108
|
+
2. **Update Linear issue status:**
|
|
109
|
+
- Map "In Progress" state to Linear status (use status mapping from linear-helpers.md)
|
|
110
|
+
- Update issue status to "In Progress" (or custom status from config)
|
|
111
|
+
- If status not found → guide user to create custom status
|
|
112
|
+
|
|
113
|
+
3. **Create Linear comment:**
|
|
114
|
+
- Add comment to Linear issue: "Task started via SDD workflow at [timestamp]"
|
|
115
|
+
- If task-level spec exists → add comment with spec summary
|
|
116
|
+
|
|
117
|
+
**Error Handling:**
|
|
118
|
+
- If Linear MCP unavailable → continue with local mode only
|
|
119
|
+
- If Linear operation fails → log error, continue with local mode
|
|
120
|
+
- Never block workflow due to Linear errors
|
|
121
|
+
|
|
122
|
+
**Task ID Normalization:**
|
|
123
|
+
- Normalize task IDs for file paths (replace special characters like `/`, `\`, `:`, etc.)
|
|
124
|
+
- Support both formats in same project (local and Linear tasks can coexist)
|
|
125
|
+
- Local task IDs: `t1.2`, `t2.3` (from tasks.local.md)
|
|
126
|
+
- Linear task IDs: `LIN-123`, `HUD-456` (Linear issue ID)
|
|
127
|
+
|
|
128
|
+
**If the task is new (local only):**
|
|
16
129
|
- Ask why it exists
|
|
17
130
|
- Ensure it aligns with the current spec
|
|
18
131
|
- Add it to `tasks.local.md` before proceeding
|
|
19
132
|
|
|
133
|
+
Step 1.5 — Check for Task-Level Spec (if task is complex)
|
|
134
|
+
|
|
135
|
+
After selecting task (local or Linear), assess complexity:
|
|
136
|
+
|
|
137
|
+
**Complexity indicators:**
|
|
138
|
+
- Task description length (> 200 words)
|
|
139
|
+
- Multiple subtasks mentioned
|
|
140
|
+
- Multiple technologies/frameworks involved
|
|
141
|
+
- Integration with external services
|
|
142
|
+
- User explicitly marks as complex
|
|
143
|
+
|
|
144
|
+
**Complexity assessment:**
|
|
145
|
+
- **Simple task:** Use project-level spec only
|
|
146
|
+
- **Complex task:** Check for `spec/tasks/[task-id]/spec.md`
|
|
147
|
+
|
|
148
|
+
**If complex task and no task-level spec exists:**
|
|
149
|
+
- Ask: "This task is complex. Should I create a task-level spec first?"
|
|
150
|
+
- If yes → create `spec/tasks/[task-id]/spec.md` and `acceptance.md`
|
|
151
|
+
- For Linear tasks: Include Linear issue description + expand with details
|
|
152
|
+
- For local tasks: Expand task description from tasks.local.md
|
|
153
|
+
- If no → proceed with project-level spec only
|
|
154
|
+
|
|
155
|
+
**If task-level spec exists:**
|
|
156
|
+
- Read `spec/tasks/[task-id]/spec.md` first
|
|
157
|
+
- Read `spec/tasks/[task-id]/acceptance.md` if exists
|
|
158
|
+
- Use task-level spec as primary source for task details
|
|
159
|
+
- Reference project-level spec for context
|
|
160
|
+
|
|
161
|
+
**Verification Checkpoint (if creating task-level spec):**
|
|
162
|
+
|
|
163
|
+
Before creating `spec/tasks/[task-id]/spec.md`, verify:
|
|
164
|
+
1. Directory `spec/tasks/[task-id]/` doesn't exist (or ask if overwriting)
|
|
165
|
+
2. Task ID is normalized for file path
|
|
166
|
+
3. Content aligns with task complexity assessment
|
|
167
|
+
4. User confirmation: "Ready to create task-level spec for [task-id]?"
|
|
168
|
+
|
|
169
|
+
**Step 1.6) Linear Document Creation (if task-level spec is created and Linear mode enabled):**
|
|
170
|
+
|
|
171
|
+
**ONLY READ IF Linear mode enabled AND task-level spec created AND AUTO_CREATE_DOCUMENTS=true:**
|
|
172
|
+
- Read `.cursor/commands/_shared/linear-automation.md` ONLY IF Linear mode enabled AND task-level spec created AND `AUTO_CREATE_DOCUMENTS=true`
|
|
173
|
+
- Auto-loads: `linear-helpers.md` (dependency)
|
|
174
|
+
- Read sections: "Documents" (lines 35-80) from linear-automation.md
|
|
175
|
+
- Skip if: Linear mode not enabled OR no task-level spec OR AUTO_CREATE_DOCUMENTS=false → skip Linear document creation entirely
|
|
176
|
+
- Check condition: Verify all conditions before reading helper
|
|
177
|
+
|
|
178
|
+
1. **Check if Linear mode enabled and AUTO_CREATE_DOCUMENTS=true:**
|
|
179
|
+
- If not enabled → skip Linear document creation
|
|
180
|
+
- If enabled → proceed with document creation
|
|
181
|
+
|
|
182
|
+
2. **Create Linear document:**
|
|
183
|
+
- Check if Linear document exists (use idempotency check from linear-helpers.md)
|
|
184
|
+
- If exists → update with task-level spec content
|
|
185
|
+
- If not exists → create Linear document:
|
|
186
|
+
- Document title: `[Task ID] - [Task Name] - Specification`
|
|
187
|
+
- Document content: Full task-level spec content from `spec/tasks/[task-id]/spec.md`
|
|
188
|
+
- Link document to Linear issue (if Linear task)
|
|
189
|
+
|
|
190
|
+
**Error Handling:**
|
|
191
|
+
- If Linear MCP unavailable → continue without Linear document
|
|
192
|
+
- If Linear operation fails → log error, continue without Linear document
|
|
193
|
+
- Never block workflow due to Linear errors
|
|
194
|
+
|
|
20
195
|
Step 2 — Establish task boundaries
|
|
21
196
|
For the selected task:
|
|
22
197
|
- Restate the task objective in your own words
|
|
@@ -24,6 +199,12 @@ For the selected task:
|
|
|
24
199
|
- Identify what is explicitly OUT of scope
|
|
25
200
|
- Identify dependencies or prerequisites
|
|
26
201
|
|
|
202
|
+
**Pre-flight spec checks:**
|
|
203
|
+
- If task requires design system → check if design direction is defined in spec
|
|
204
|
+
- If task requires external service → check if service is selected
|
|
205
|
+
- If task requires infrastructure → check if provider is selected
|
|
206
|
+
- If not defined → pause and ask: "Should we define this first via /spec/refine?"
|
|
207
|
+
|
|
27
208
|
If scope is unclear, pause and ask clarifying questions.
|
|
28
209
|
Do NOT guess.
|
|
29
210
|
|
|
@@ -32,14 +213,124 @@ Determine how completion will be validated:
|
|
|
32
213
|
- Reference acceptance criteria if they exist
|
|
33
214
|
- Otherwise, define a minimal acceptance signal (what proves this task is done)
|
|
34
215
|
|
|
216
|
+
**Acceptance criteria quality requirements:**
|
|
217
|
+
- Must be specific and testable (not "Feature works" but "Feature performs [specific action] with [specific inputs] and returns [specific outputs]")
|
|
218
|
+
- Must include edge cases (empty states, error states, missing data, invalid inputs)
|
|
219
|
+
- Must include validation steps (manual or automated)
|
|
220
|
+
- If criteria are too general → break them down into specific checks
|
|
221
|
+
- Example: Instead of "Responsive layout" → "Layout works on mobile (320px), tablet (768px), desktop (1024px+) with no horizontal scrolling"
|
|
222
|
+
|
|
35
223
|
Do not proceed without a clear acceptance signal.
|
|
36
224
|
|
|
37
225
|
Step 4 — Engineering setup
|
|
38
226
|
Before implementation, ensure:
|
|
39
|
-
|
|
227
|
+
|
|
228
|
+
**A) Git workflow automation:**
|
|
229
|
+
1. Check git status:
|
|
230
|
+
- If uncommitted changes exist → pause and ask: "Uncommitted changes detected. Commit, stash, or discard?"
|
|
231
|
+
- If untracked files exist → pause and ask: "Untracked files detected. Should they be committed?"
|
|
232
|
+
|
|
233
|
+
2. Ensure clean main branch:
|
|
234
|
+
- Checkout main branch (or default branch)
|
|
235
|
+
- Pull latest changes (if remote exists): `git pull origin main` (or default branch name)
|
|
236
|
+
- Verify main is clean (no uncommitted changes)
|
|
237
|
+
|
|
238
|
+
3. Create task branch:
|
|
239
|
+
- Branch name format: `task/{task-id}-{short-description}` (e.g., `task/t1.2-setup-database`)
|
|
240
|
+
- Create and checkout: `git checkout -b task/{task-id}-{short-description}`
|
|
241
|
+
- Verify branch creation: confirm branch exists and is clean
|
|
242
|
+
|
|
243
|
+
**A.1) Initialize State Tracking:**
|
|
244
|
+
|
|
245
|
+
**ONLY READ IF state tracking needed:**
|
|
246
|
+
- Read `.cursor/commands/_shared/git-workflow.md` ONLY IF state tracking needed (always for task start)
|
|
247
|
+
- Read sections: "State Detection" (lines 81-150) from git-workflow.md
|
|
248
|
+
- Always load: State tracking is always needed for task start
|
|
249
|
+
|
|
250
|
+
After branch creation:
|
|
251
|
+
1. Initialize state tracking in `.sdd/git-state.json`
|
|
252
|
+
2. Set initial state:
|
|
253
|
+
```json
|
|
254
|
+
{
|
|
255
|
+
"branch": {
|
|
256
|
+
"name": "task/{task-id}-{short-description}",
|
|
257
|
+
"exists": true,
|
|
258
|
+
"pushed": false,
|
|
259
|
+
"commits": 0,
|
|
260
|
+
"last_commit": null
|
|
261
|
+
},
|
|
262
|
+
"pr": {
|
|
263
|
+
"exists": false,
|
|
264
|
+
"number": null,
|
|
265
|
+
"url": null,
|
|
266
|
+
"status": null,
|
|
267
|
+
"merged": false
|
|
268
|
+
},
|
|
269
|
+
"deployment": {
|
|
270
|
+
"provider": null,
|
|
271
|
+
"preview_url": null,
|
|
272
|
+
"status": null
|
|
273
|
+
},
|
|
274
|
+
"validated": false,
|
|
275
|
+
"last_updated": "[current timestamp]"
|
|
276
|
+
}
|
|
277
|
+
```
|
|
278
|
+
3. Store state in `.sdd/git-state.json`
|
|
279
|
+
4. Report: "State tracking initialized for branch [branch-name]"
|
|
280
|
+
|
|
281
|
+
**Error Handling:**
|
|
282
|
+
- If state file not writable → continue without state tracking (degraded mode)
|
|
283
|
+
- If state initialization fails → report error, continue workflow
|
|
284
|
+
- Never block workflow due to state tracking failures
|
|
285
|
+
|
|
286
|
+
**B) Pre-flight checks:**
|
|
287
|
+
1. Dependency check:
|
|
288
|
+
- Verify package.json and lockfile are in sync (if applicable to project type)
|
|
289
|
+
- Check for known compatibility issues (framework versions, etc.)
|
|
290
|
+
- Verify critical dependencies are installed (check project-specific requirements)
|
|
291
|
+
|
|
292
|
+
2. Build cache check:
|
|
293
|
+
- If build cache directory exists and is >1 day old → suggest: "Consider cleaning build cache if build issues occur"
|
|
294
|
+
- Check for known build cache issues (project-specific)
|
|
295
|
+
|
|
296
|
+
3. Configuration check:
|
|
297
|
+
- Verify required environment variables are documented
|
|
298
|
+
- Check for common config issues (framework-specific configuration patterns)
|
|
299
|
+
|
|
300
|
+
**C) Standard setup:**
|
|
40
301
|
- The user understands what files or areas are likely to be touched
|
|
41
302
|
- Tests may be required (unit, integration, or manual), if applicable
|
|
42
303
|
|
|
304
|
+
**D) Documentation Lookup (if framework/tool detected from tech stack):**
|
|
305
|
+
|
|
306
|
+
**ONLY READ IF framework/tool detected from tech stack:**
|
|
307
|
+
- 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`)
|
|
308
|
+
- Read sections: "Context7 Integration" (lines 10-80), "Documentation Lookup Logic" (lines 17-150)
|
|
309
|
+
- Skip if: No framework/tool detected → skip documentation lookup entirely
|
|
310
|
+
- Check condition: Read tech stack from spec files first, then read helper only if framework/tool detected
|
|
311
|
+
|
|
312
|
+
If framework/tool detected from tech stack and documentation needed for implementation:
|
|
313
|
+
1. Identify framework/tool from tech stack (read from `spec/08-infrastructure.md` or `spec/02-architecture.md`)
|
|
314
|
+
2. Try multiple documentation sources (in priority order):
|
|
315
|
+
- **Context7 MCP:** Query Context7: "[Framework/Tool Name] [implementation topic]"
|
|
316
|
+
- **Cursor Documentation Indexing:** Search Cursor's indexed documentation
|
|
317
|
+
- **Web Search:** Search web for "[Framework] [topic] documentation" if needed
|
|
318
|
+
- **General Patterns:** Use general engineering patterns from `10-engineering.mdc`
|
|
319
|
+
3. Combine information from available sources when helpful
|
|
320
|
+
4. Use documentation to guide implementation
|
|
321
|
+
5. Reference documentation source in suggestions: "According to [Framework] documentation..." or "Based on [source]..."
|
|
322
|
+
|
|
323
|
+
**Smart Thinking:**
|
|
324
|
+
- Be adaptive and flexible - use whatever sources are available
|
|
325
|
+
- Don't be rigid - if one source fails, try others
|
|
326
|
+
- Combine information from multiple sources when helpful
|
|
327
|
+
- Only ask user if all sources exhausted and information is critical
|
|
328
|
+
|
|
329
|
+
**Error Handling:**
|
|
330
|
+
- If Context7 unavailable → try Cursor indexing, web search, or cached documentation
|
|
331
|
+
- Do NOT block workflow if documentation unavailable
|
|
332
|
+
- Continue with available information and general engineering patterns
|
|
333
|
+
|
|
43
334
|
Do NOT write code yet.
|
|
44
335
|
|
|
45
336
|
Step 5 — Implementation plan (lightweight)
|