spec-mode 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +144 -0
- package/SKILL.md +189 -0
- package/examples/sample-spec.md +263 -0
- package/install.sh +70 -0
- package/package.json +32 -0
- package/prompts/standard.md +30 -0
- package/prompts/workflow.md +58 -0
- package/references/common-mistakes.md +39 -0
- package/references/cross-platform.md +57 -0
- package/references/workflow-details.md +94 -0
- package/templates/checklist-template.md +73 -0
- package/templates/spec-template.md +65 -0
- package/templates/tasks-template.md +86 -0
- package/tests/pressure-scenarios.md +202 -0
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
# Sample Spec - User Export Feature
|
|
2
|
+
|
|
3
|
+
This is a complete example of the three-piece specification output.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## spec.md
|
|
8
|
+
|
|
9
|
+
```markdown
|
|
10
|
+
# User Export Feature Spec
|
|
11
|
+
|
|
12
|
+
## Why
|
|
13
|
+
|
|
14
|
+
Users need to export their data for external analysis and record-keeping. Currently there is no way to export user data, which limits data portability and compliance with data export requirements.
|
|
15
|
+
|
|
16
|
+
## What Changes
|
|
17
|
+
|
|
18
|
+
- Add CSV export endpoint for user data
|
|
19
|
+
- Add export button to user management page
|
|
20
|
+
- Add rate limiting to prevent abuse
|
|
21
|
+
- **BREAKING:** Users without `export` permission cannot access the new endpoint
|
|
22
|
+
|
|
23
|
+
## Impact
|
|
24
|
+
|
|
25
|
+
- **Systems:** User management module, Authentication system
|
|
26
|
+
- **Files:**
|
|
27
|
+
- `src/api/users.ts` (new export endpoint)
|
|
28
|
+
- `src/components/UserTable.tsx` (add export button)
|
|
29
|
+
- `src/permissions.ts` (add export permission)
|
|
30
|
+
- **Users:** Admin users will see new export functionality
|
|
31
|
+
|
|
32
|
+
## ADDED Requirements
|
|
33
|
+
|
|
34
|
+
### Export User Data as CSV
|
|
35
|
+
|
|
36
|
+
**Scenario:** Admin user wants to export all users for external analysis
|
|
37
|
+
|
|
38
|
+
**Acceptance Criteria:**
|
|
39
|
+
- Export includes: id, name, email, created_at, last_login
|
|
40
|
+
- File is downloaded as `users-export-YYYY-MM-DD.csv`
|
|
41
|
+
- Export completes within 30 seconds for up to 10,000 users
|
|
42
|
+
|
|
43
|
+
### Rate Limiting
|
|
44
|
+
|
|
45
|
+
**Scenario:** Prevent abuse of export functionality
|
|
46
|
+
|
|
47
|
+
**Acceptance Criteria:**
|
|
48
|
+
- Maximum 5 exports per user per hour
|
|
49
|
+
- Clear error message when limit exceeded
|
|
50
|
+
- Rate limit reset after 1 hour
|
|
51
|
+
|
|
52
|
+
## MODIFIED Requirements
|
|
53
|
+
|
|
54
|
+
### User List Pagination
|
|
55
|
+
|
|
56
|
+
**Before:** User list shows 50 users per page
|
|
57
|
+
|
|
58
|
+
**After:** User list shows 100 users per page (to reduce export frequency)
|
|
59
|
+
|
|
60
|
+
**Scenario:** Admin viewing user list
|
|
61
|
+
|
|
62
|
+
**Acceptance Criteria:**
|
|
63
|
+
- Default page size changed to 100
|
|
64
|
+
- Existing bookmarks to specific pages still work
|
|
65
|
+
|
|
66
|
+
## REMOVED Requirements
|
|
67
|
+
|
|
68
|
+
### None
|
|
69
|
+
|
|
70
|
+
No requirements are being removed in this change.
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## tasks.md
|
|
76
|
+
|
|
77
|
+
```markdown
|
|
78
|
+
# Implementation Tasks
|
|
79
|
+
|
|
80
|
+
## Task Overview
|
|
81
|
+
|
|
82
|
+
| ID | Task | Dependencies | Estimated |
|
|
83
|
+
|----|------|--------------|-----------|
|
|
84
|
+
| T1 | Add export permission | None | 15 min |
|
|
85
|
+
| T2 | Create CSV export endpoint | T1 | 45 min |
|
|
86
|
+
| T3 | Add rate limiting | T2 | 30 min |
|
|
87
|
+
| T4 | Add export button to UI | T2 | 30 min |
|
|
88
|
+
| T5 | Write integration tests | T2, T3 | 30 min |
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## Tasks
|
|
93
|
+
|
|
94
|
+
### Task T1: Add Export Permission
|
|
95
|
+
|
|
96
|
+
**Files:**
|
|
97
|
+
- Modify: `src/permissions.ts:10-25`
|
|
98
|
+
- Modify: `src/types/permissions.ts:5-10`
|
|
99
|
+
|
|
100
|
+
**Steps:**
|
|
101
|
+
|
|
102
|
+
1. Add `export` to Permission type
|
|
103
|
+
2. Add `EXPORT_DATA` constant
|
|
104
|
+
3. Update permission validation
|
|
105
|
+
|
|
106
|
+
**Verification:**
|
|
107
|
+
- [ ] TypeScript compiles without errors
|
|
108
|
+
- [ ] Permission appears in admin permission list
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
### Task T2: Create CSV Export Endpoint
|
|
113
|
+
|
|
114
|
+
**Files:**
|
|
115
|
+
- Create: `src/api/users/export.ts`
|
|
116
|
+
- Modify: `src/api/users/index.ts:1-20`
|
|
117
|
+
|
|
118
|
+
**Steps:**
|
|
119
|
+
|
|
120
|
+
1. Create export handler function
|
|
121
|
+
2. Generate CSV from user data
|
|
122
|
+
3. Set proper headers for download
|
|
123
|
+
4. Register route in user router
|
|
124
|
+
|
|
125
|
+
**Verification:**
|
|
126
|
+
- [ ] Endpoint returns 200 with CSV data
|
|
127
|
+
- [ ] CSV format is correct
|
|
128
|
+
- [ ] Headers trigger file download
|
|
129
|
+
|
|
130
|
+
---
|
|
131
|
+
|
|
132
|
+
### Task T3: Add Rate Limiting
|
|
133
|
+
|
|
134
|
+
**Files:**
|
|
135
|
+
- Modify: `src/middleware/rateLimit.ts`
|
|
136
|
+
- Modify: `src/api/users/export.ts`
|
|
137
|
+
|
|
138
|
+
**Steps:**
|
|
139
|
+
|
|
140
|
+
1. Add export-specific rate limit rule
|
|
141
|
+
2. Apply middleware to export endpoint
|
|
142
|
+
3. Add error response for limit exceeded
|
|
143
|
+
|
|
144
|
+
**Verification:**
|
|
145
|
+
- [ ] 6th export within 1 hour returns 429
|
|
146
|
+
- [ ] Error message is user-friendly
|
|
147
|
+
|
|
148
|
+
---
|
|
149
|
+
|
|
150
|
+
### Task T4: Add Export Button to UI
|
|
151
|
+
|
|
152
|
+
**Files:**
|
|
153
|
+
- Modify: `src/components/UserTable.tsx:50-100`
|
|
154
|
+
|
|
155
|
+
**Steps:**
|
|
156
|
+
|
|
157
|
+
1. Add export button component
|
|
158
|
+
2. Add click handler to call export endpoint
|
|
159
|
+
3. Add loading state during export
|
|
160
|
+
4. Add error handling
|
|
161
|
+
|
|
162
|
+
**Verification:**
|
|
163
|
+
- [ ] Button visible to admin users
|
|
164
|
+
- [ ] Button hidden for non-admin users
|
|
165
|
+
- [ ] Download starts on click
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
### Task T5: Write Integration Tests
|
|
170
|
+
|
|
171
|
+
**Files:**
|
|
172
|
+
- Create: `tests/api/users/export.test.ts`
|
|
173
|
+
|
|
174
|
+
**Steps:**
|
|
175
|
+
|
|
176
|
+
1. Test successful export
|
|
177
|
+
2. Test rate limiting
|
|
178
|
+
3. Test permission denied
|
|
179
|
+
4. Test large dataset
|
|
180
|
+
|
|
181
|
+
**Verification:**
|
|
182
|
+
- [ ] All tests pass
|
|
183
|
+
- [ ] Code coverage > 80%
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
---
|
|
187
|
+
|
|
188
|
+
## checklist.md
|
|
189
|
+
|
|
190
|
+
```markdown
|
|
191
|
+
# Verification Checklist
|
|
192
|
+
|
|
193
|
+
## Pre-Implementation
|
|
194
|
+
|
|
195
|
+
- [ ] spec.md is complete and approved
|
|
196
|
+
- [ ] tasks.md is complete with clear verification steps
|
|
197
|
+
- [ ] All stakeholders have reviewed the specification
|
|
198
|
+
- [ ] Change ID is assigned: `add-user-export`
|
|
199
|
+
|
|
200
|
+
## Implementation
|
|
201
|
+
|
|
202
|
+
### Code Quality
|
|
203
|
+
|
|
204
|
+
- [ ] All new code follows project conventions
|
|
205
|
+
- [ ] All tests pass (existing and new)
|
|
206
|
+
- [ ] No linting errors introduced
|
|
207
|
+
- [ ] Code is properly commented where necessary
|
|
208
|
+
|
|
209
|
+
### Functionality
|
|
210
|
+
|
|
211
|
+
- [ ] Export endpoint returns CSV data
|
|
212
|
+
- [ ] Export includes all required fields
|
|
213
|
+
- [ ] Rate limiting works correctly (5/hour)
|
|
214
|
+
- [ ] Export button visible to admins only
|
|
215
|
+
- [ ] Permission check works correctly
|
|
216
|
+
|
|
217
|
+
### Testing
|
|
218
|
+
|
|
219
|
+
- [ ] Unit tests for export function
|
|
220
|
+
- [ ] Integration tests for endpoint
|
|
221
|
+
- [ ] Rate limit tests
|
|
222
|
+
- [ ] Permission tests
|
|
223
|
+
- [ ] Error handling tests
|
|
224
|
+
|
|
225
|
+
### Documentation
|
|
226
|
+
|
|
227
|
+
- [ ] API documentation updated
|
|
228
|
+
- [ ] Component documentation added
|
|
229
|
+
- [ ] CHANGELOG updated
|
|
230
|
+
|
|
231
|
+
## Post-Implementation
|
|
232
|
+
|
|
233
|
+
### Verification
|
|
234
|
+
|
|
235
|
+
- [ ] All checklist items from tasks.md are complete
|
|
236
|
+
- [ ] Manual testing completed
|
|
237
|
+
- [ ] Performance tested with 10,000 users
|
|
238
|
+
|
|
239
|
+
### Cleanup
|
|
240
|
+
|
|
241
|
+
- [ ] Temporary files removed
|
|
242
|
+
- [ ] Debug code removed
|
|
243
|
+
- [ ] Unused imports removed
|
|
244
|
+
- [ ] Code formatted with prettier
|
|
245
|
+
|
|
246
|
+
### Deployment
|
|
247
|
+
|
|
248
|
+
- [ ] Changes committed with clear messages
|
|
249
|
+
- [ ] Pull request created
|
|
250
|
+
- [ ] Deployment plan documented
|
|
251
|
+
|
|
252
|
+
## Sign-off
|
|
253
|
+
|
|
254
|
+
- [ ] Developer sign-off
|
|
255
|
+
- [ ] Reviewer sign-off
|
|
256
|
+
- [ ] Product owner approval
|
|
257
|
+
|
|
258
|
+
---
|
|
259
|
+
|
|
260
|
+
**Change ID:** add-user-export
|
|
261
|
+
**Date Completed:** 2024-01-15
|
|
262
|
+
**Status:** Complete
|
|
263
|
+
```
|
package/install.sh
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# Spec Mode Skill Installer
|
|
4
|
+
# Compatible with OpenCode, Cursor, Windsurf, Copilot
|
|
5
|
+
|
|
6
|
+
set -e
|
|
7
|
+
|
|
8
|
+
echo "🚀 Installing Spec Mode Skill..."
|
|
9
|
+
|
|
10
|
+
# Determine the skills directory based on the AI assistant
|
|
11
|
+
SKILLS_DIR=""
|
|
12
|
+
|
|
13
|
+
if [ -n "$OPENCODE_CONFIG" ]; then
|
|
14
|
+
SKILLS_DIR="$HOME/.config/opencode/skills"
|
|
15
|
+
elif [ -n "$CURSOR_CONFIG" ]; then
|
|
16
|
+
SKILLS_DIR="$HOME/.cursor/skills"
|
|
17
|
+
elif [ -n "$WINDSURF_CONFIG" ]; then
|
|
18
|
+
SKILLS_DIR="$HOME/.windsurf/skills"
|
|
19
|
+
elif [ -n "$COPILOT_CONFIG" ]; then
|
|
20
|
+
SKILLS_DIR="$HOME/.copilot/skills"
|
|
21
|
+
else
|
|
22
|
+
# Default to OpenCode
|
|
23
|
+
SKILLS_DIR="$HOME/.config/opencode/skills"
|
|
24
|
+
fi
|
|
25
|
+
|
|
26
|
+
# Create skills directory if it doesn't exist
|
|
27
|
+
mkdir -p "$SKILLS_DIR"
|
|
28
|
+
|
|
29
|
+
# Get the script's directory
|
|
30
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
31
|
+
|
|
32
|
+
# Destination directory
|
|
33
|
+
DEST_DIR="$SKILLS_DIR/spec-mode"
|
|
34
|
+
|
|
35
|
+
# Remove existing installation if present
|
|
36
|
+
if [ -d "$DEST_DIR" ]; then
|
|
37
|
+
echo "⚠️ Removing existing installation..."
|
|
38
|
+
rm -rf "$DEST_DIR"
|
|
39
|
+
fi
|
|
40
|
+
|
|
41
|
+
# Create destination directory
|
|
42
|
+
mkdir -p "$DEST_DIR"
|
|
43
|
+
|
|
44
|
+
# Copy skill files (excluding .git and other unnecessary files)
|
|
45
|
+
echo "📁 Copying skill files to $DEST_DIR/"
|
|
46
|
+
|
|
47
|
+
# Copy core files
|
|
48
|
+
cp "$SCRIPT_DIR/SKILL.md" "$DEST_DIR/"
|
|
49
|
+
cp "$SCRIPT_DIR/README.md" "$DEST_DIR/" 2>/dev/null || true
|
|
50
|
+
cp "$SCRIPT_DIR/LICENSE" "$DEST_DIR/" 2>/dev/null || true
|
|
51
|
+
|
|
52
|
+
# Copy directories
|
|
53
|
+
for dir in examples prompts references templates tests; do
|
|
54
|
+
if [ -d "$SCRIPT_DIR/$dir" ]; then
|
|
55
|
+
cp -r "$SCRIPT_DIR/$dir" "$DEST_DIR/"
|
|
56
|
+
fi
|
|
57
|
+
done
|
|
58
|
+
|
|
59
|
+
# Verify installation
|
|
60
|
+
if [ -f "$SKILLS_DIR/spec-mode/SKILL.md" ]; then
|
|
61
|
+
echo "✅ Spec Mode Skill installed successfully!"
|
|
62
|
+
echo ""
|
|
63
|
+
echo "📖 Usage:"
|
|
64
|
+
echo ' Say "spec", "specification", "spec-mode", "写规范", or "写 specs"'
|
|
65
|
+
echo ""
|
|
66
|
+
echo "📁 Installed to: $SKILLS_DIR/spec-mode/"
|
|
67
|
+
else
|
|
68
|
+
echo "❌ Installation failed. Please check the error messages above."
|
|
69
|
+
exit 1
|
|
70
|
+
fi
|
package/package.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "spec-mode",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "An AI skill that creates standardized specification documents before implementation. Specs first, code second.",
|
|
5
|
+
"main": "SKILL.md",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"skill",
|
|
8
|
+
"ai",
|
|
9
|
+
"opencode",
|
|
10
|
+
"cursor",
|
|
11
|
+
"windsurf",
|
|
12
|
+
"copilot",
|
|
13
|
+
"specification",
|
|
14
|
+
"spec",
|
|
15
|
+
"documentation",
|
|
16
|
+
"development"
|
|
17
|
+
],
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "https://github.com/GlacierXiaowei/spec-mode.git"
|
|
21
|
+
},
|
|
22
|
+
"author": {
|
|
23
|
+
"name": "Glacier Xiaowei",
|
|
24
|
+
"email": "glacier_xiaowei@163.com",
|
|
25
|
+
"url": "https://github.com/GlacierXiaowei"
|
|
26
|
+
},
|
|
27
|
+
"license": "Apache-2.0",
|
|
28
|
+
"bugs": {
|
|
29
|
+
"url": "https://github.com/GlacierXiaowei/spec-mode/issues"
|
|
30
|
+
},
|
|
31
|
+
"homepage": "https://github.com/GlacierXiaowei/spec-mode#readme"
|
|
32
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Spec Mode - Standard Prompt
|
|
2
|
+
|
|
3
|
+
You are in Spec Mode. Your task is to write and output three files: `spec.md`, `tasks.md`, and `checklist.md`.
|
|
4
|
+
|
|
5
|
+
## Requirements
|
|
6
|
+
|
|
7
|
+
1. **Only produce these three documents** - No code changes, no other files
|
|
8
|
+
2. **Language must match user's language** (currently Chinese)
|
|
9
|
+
3. **Output directory:** `<project-root>/.specs/<change-id>/`
|
|
10
|
+
- `<change-id>` must be verb-first, hyphen-separated (e.g., `add-user-export`, `refactor-auth-middleware`)
|
|
11
|
+
4. **spec.md structure:**
|
|
12
|
+
- `Why` - 1-2 sentences explaining the purpose
|
|
13
|
+
- `What Changes` - Bullet list of changes (mark **BREAKING** changes where applicable)
|
|
14
|
+
- `Impact` - Affected systems and key files
|
|
15
|
+
- `ADDED Requirements` - New requirements with scenarios
|
|
16
|
+
- `MODIFIED Requirements` - Changed requirements with scenarios
|
|
17
|
+
- `REMOVED Requirements` - Removed requirements with scenarios
|
|
18
|
+
5. **tasks.md:** Map changes to small, verifiable work items
|
|
19
|
+
- Break into subtasks when necessary
|
|
20
|
+
- Mark dependencies and parallelizable items
|
|
21
|
+
- Include verification method (test/tool/run)
|
|
22
|
+
6. **checklist.md:** List must-pass checkpoints
|
|
23
|
+
- Itemized and checkable
|
|
24
|
+
- Aligned with tasks.md
|
|
25
|
+
|
|
26
|
+
## After Completion
|
|
27
|
+
|
|
28
|
+
**Prompt user for review. Do NOT proceed to implementation.**
|
|
29
|
+
|
|
30
|
+
Wait for user approval before moving to implementation phase.
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# Spec Mode - Workflow Prompt
|
|
2
|
+
|
|
3
|
+
You are now in Spec Mode. Your goal is to produce the standardized three-piece specification for the user's change request: `spec.md`, `tasks.md`, and `checklist.md`.
|
|
4
|
+
|
|
5
|
+
## Rules to Follow
|
|
6
|
+
|
|
7
|
+
### 1. Scope and Language
|
|
8
|
+
- Only create the three documents above
|
|
9
|
+
- Do NOT modify code or create other files
|
|
10
|
+
- Document language must match the user's current language (Chinese)
|
|
11
|
+
|
|
12
|
+
### 2. Path and Naming
|
|
13
|
+
- Target directory: `<project-root>/.specs/<change-id>/`
|
|
14
|
+
- Alternative: `<project-root>/docs/specs/<change-id>/`
|
|
15
|
+
- `<change-id>` uses verb-first, hyphen-separated format (e.g., `refactor-auth-middleware`, `add-user-export`)
|
|
16
|
+
|
|
17
|
+
### 3. Document Structure
|
|
18
|
+
|
|
19
|
+
**spec.md:**
|
|
20
|
+
- Fixed structure: Why / What Changes / Impact / ADDED / MODIFIED / REMOVED
|
|
21
|
+
- Include scenarios for each requirement
|
|
22
|
+
- Mark **BREAKING** changes where applicable
|
|
23
|
+
|
|
24
|
+
**tasks.md:**
|
|
25
|
+
- Small, verifiable work items
|
|
26
|
+
- Mark dependencies and parallelizable tasks
|
|
27
|
+
- Include verification method (test/tool/run)
|
|
28
|
+
|
|
29
|
+
**checklist.md:**
|
|
30
|
+
- List all must-pass checkpoints
|
|
31
|
+
- Itemized and checkable
|
|
32
|
+
- Aligned with tasks.md
|
|
33
|
+
|
|
34
|
+
### 4. Process and Rules
|
|
35
|
+
- Only output documents during spec phase
|
|
36
|
+
- After completion, prompt user for review and approval
|
|
37
|
+
- Only proceed to implementation after user approval
|
|
38
|
+
- During implementation, reference the above documents as the single source of truth
|
|
39
|
+
|
|
40
|
+
### 5. Exploration and Research
|
|
41
|
+
- Start with high-level investigation: goals, scope, constraints, key modules
|
|
42
|
+
- Drill down gradually: interfaces, data flow, boundary conditions, security and compatibility
|
|
43
|
+
- Converge to the three-piece documents after covering key points
|
|
44
|
+
|
|
45
|
+
### 6. Subagent/Parallel (Optional)
|
|
46
|
+
- If platform supports: Execute independent tasks in parallel (e.g., document generation and link summary); merge and verify together
|
|
47
|
+
- If platform doesn't support: Execute same expectations and verification sequentially
|
|
48
|
+
|
|
49
|
+
### 7. Content Quality
|
|
50
|
+
- Focus on verifiability and user-visible progress
|
|
51
|
+
- Prioritize minimum viable implementation (MVP), avoid over-engineering
|
|
52
|
+
- Ensure each work item is independently verifiable and progress is observable
|
|
53
|
+
|
|
54
|
+
## After Completion
|
|
55
|
+
|
|
56
|
+
**Prompt user for review. Do NOT proceed to implementation.**
|
|
57
|
+
|
|
58
|
+
Wait for user confirmation before moving to implementation phase. During implementation, use the specification documents as the single source of truth.
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Common Mistakes in Spec Mode
|
|
2
|
+
|
|
3
|
+
## Rationalizations to Resist
|
|
4
|
+
|
|
5
|
+
| Excuse | Reality |
|
|
6
|
+
|--------|---------|
|
|
7
|
+
| "This is too urgent for specs" | Specs save time by preventing rework. Even 5-minute specs help. |
|
|
8
|
+
| "I already wrote half the code" | Stop. Write specs for what remains. Fix mismatches before continuing. |
|
|
9
|
+
| "The user/manager said skip docs" | Specs are for you too. They prevent mistakes. Offer simplified version, not skip. |
|
|
10
|
+
| "This project is too small" | Small projects break too. Specs scale to project size. |
|
|
11
|
+
| "I'm experienced, I don't need specs" | Experience prevents bugs. Specs prevent miscommunication. Both matter. |
|
|
12
|
+
| "I'll write specs after, same thing" | Specs-after = "what did I do?" Specs-before = "what should I do?" Different purposes. |
|
|
13
|
+
| "The user just asked to implement, I should add specs" | NO! User must explicitly request specs. Don't add specs uninvited. |
|
|
14
|
+
|
|
15
|
+
## Red Flags - STOP and Start Over
|
|
16
|
+
|
|
17
|
+
If you catch yourself doing any of these, **stop immediately** and return to Spec Mode:
|
|
18
|
+
|
|
19
|
+
- ❌ Writing code before specs are approved
|
|
20
|
+
- ❌ "I already manually tested it"
|
|
21
|
+
- ❌ "The user wants code now, specs later"
|
|
22
|
+
- ❌ "This is different because..."
|
|
23
|
+
- ❌ "It's about spirit not ritual"
|
|
24
|
+
|
|
25
|
+
**All of these mean: Stop. Return to Spec Mode. Write specs first.**
|
|
26
|
+
|
|
27
|
+
## Why These Mistakes Happen
|
|
28
|
+
|
|
29
|
+
1. **Urgency bias** - Feeling pressured to deliver quickly
|
|
30
|
+
2. **Overconfidence** - Assuming you know what the user wants
|
|
31
|
+
3. **Sunk cost** - Already started coding, don't want to stop
|
|
32
|
+
4. **Rationalization** - Finding excuses to skip discipline
|
|
33
|
+
|
|
34
|
+
## How to Avoid
|
|
35
|
+
|
|
36
|
+
1. **Pause** - When you feel the urge to skip specs, pause
|
|
37
|
+
2. **Ask** - Remember: specs save time by preventing rework
|
|
38
|
+
3. **Start small** - Even a 5-minute spec is better than none
|
|
39
|
+
4. **Trust the process** - The workflow exists for a reason
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# Cross-Platform Notes
|
|
2
|
+
|
|
3
|
+
## Directory Flexibility
|
|
4
|
+
|
|
5
|
+
Spec Mode works with any directory structure. Choose what fits your project:
|
|
6
|
+
|
|
7
|
+
| Option | Path | Use Case |
|
|
8
|
+
|--------|------|----------|
|
|
9
|
+
| **Default** | `<project-root>/.specs/<change-id>/` | Standard location |
|
|
10
|
+
| **Alternative** | `<project-root>/docs/specs/<change-id>/` | Projects with docs folder |
|
|
11
|
+
| **Custom** | Any directory | Keep three-file structure |
|
|
12
|
+
|
|
13
|
+
## Naming Convention
|
|
14
|
+
|
|
15
|
+
`<change-id>` uses:
|
|
16
|
+
- **Verb-first** format
|
|
17
|
+
- **Hyphen-separated** words
|
|
18
|
+
- **Lowercase** letters
|
|
19
|
+
|
|
20
|
+
**Examples:**
|
|
21
|
+
- `add-user-export`
|
|
22
|
+
- `refactor-auth-middleware`
|
|
23
|
+
- `fix-login-bug`
|
|
24
|
+
- `update-homepage-ui`
|
|
25
|
+
|
|
26
|
+
## Editor Support
|
|
27
|
+
|
|
28
|
+
Spec Mode works in any AI environment:
|
|
29
|
+
|
|
30
|
+
- ✅ Claude Code
|
|
31
|
+
- ✅ Cursor
|
|
32
|
+
- ✅ VS Code extensions
|
|
33
|
+
- ✅ Any SKILL.md-compatible agent
|
|
34
|
+
|
|
35
|
+
**No tool-specific dependencies** - The skill is pure markdown instructions.
|
|
36
|
+
|
|
37
|
+
## Subagent Support
|
|
38
|
+
|
|
39
|
+
| Scenario | Behavior |
|
|
40
|
+
|----------|----------|
|
|
41
|
+
| **Parallel tasks available** | Use subagents for independent tasks |
|
|
42
|
+
| **Sequential only** | Execute tasks one by one |
|
|
43
|
+
|
|
44
|
+
Subagent support is **optional** - the skill works without it.
|
|
45
|
+
|
|
46
|
+
## Three-File Structure
|
|
47
|
+
|
|
48
|
+
Regardless of directory, always maintain:
|
|
49
|
+
|
|
50
|
+
```
|
|
51
|
+
<change-id>/
|
|
52
|
+
├── spec.md # What & Why
|
|
53
|
+
├── tasks.md # How to implement
|
|
54
|
+
└── checklist.md # Verification checkpoints
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
This structure is the **core invariant** of Spec Mode.
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# Workflow Details
|
|
2
|
+
|
|
3
|
+
## Complete Step-by-Step Flow
|
|
4
|
+
|
|
5
|
+
### Phase 1: Understand & Scan
|
|
6
|
+
|
|
7
|
+
1. **Understand user goal** - Analyze the user's request
|
|
8
|
+
2. **Scan context** - Read relevant files, code structure, existing conventions
|
|
9
|
+
3. **Make inferences** - If you can reasonably infer details, proceed with assumptions
|
|
10
|
+
|
|
11
|
+
### Phase 2: Ask Questions (Only If Necessary)
|
|
12
|
+
|
|
13
|
+
**Ask ONLY when:**
|
|
14
|
+
- Cannot reliably infer after scanning context
|
|
15
|
+
- AND the uncertainty affects spec/implementation direction/scope/result
|
|
16
|
+
|
|
17
|
+
**Typical cases (only 3 types):**
|
|
18
|
+
1. **Vague requirements** - e.g., "optimize homepage" without specifying visual/performance/interaction
|
|
19
|
+
2. **Multiple valid approaches** - e.g., permission system design (role-based vs resource-level)
|
|
20
|
+
3. **Unclear scope** - e.g., frontend only / backend only / both
|
|
21
|
+
|
|
22
|
+
**Do NOT ask about:**
|
|
23
|
+
- Minor details (e.g., button color) → Make reasonable assumptions
|
|
24
|
+
- Implementation technical choices → Decide yourself
|
|
25
|
+
|
|
26
|
+
### Phase 3: Create Spec Documents
|
|
27
|
+
|
|
28
|
+
1. **spec.md** - Define why, what changes, impact, requirements
|
|
29
|
+
2. **tasks.md** - Break down into small, verifiable work items
|
|
30
|
+
3. **checklist.md** - List must-pass checkpoints
|
|
31
|
+
|
|
32
|
+
### Phase 4: User Confirmation
|
|
33
|
+
|
|
34
|
+
**After creating all three documents:**
|
|
35
|
+
|
|
36
|
+
```
|
|
37
|
+
✅ 已完成规范文档:
|
|
38
|
+
- .specs/<change-id>/spec.md
|
|
39
|
+
- .specs/<change-id>/tasks.md
|
|
40
|
+
- .specs/<change-id>/checklist.md
|
|
41
|
+
|
|
42
|
+
[简要总结关键内容]
|
|
43
|
+
|
|
44
|
+
请审阅。确认后我开始实现。
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
**Then STOP** - Wait for user confirmation before proceeding.
|
|
48
|
+
|
|
49
|
+
### Phase 5: Implementation
|
|
50
|
+
|
|
51
|
+
**After user confirms:**
|
|
52
|
+
|
|
53
|
+
1. **Start implementation directly** - No more questions
|
|
54
|
+
2. **Make judgments on uncertainties** - Decide yourself
|
|
55
|
+
3. **Report after completion** - Unified summary at the end
|
|
56
|
+
4. **Only interrupt for major deviations** - Critical issues only
|
|
57
|
+
|
|
58
|
+
**WRONG:** Asking about every small decision during implementation
|
|
59
|
+
**RIGHT:** Execute completely after confirmation → Report when done
|
|
60
|
+
|
|
61
|
+
## Workflow Diagram
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
User Request
|
|
65
|
+
↓
|
|
66
|
+
Scan Context
|
|
67
|
+
↓
|
|
68
|
+
Can Infer? ──no,critical──→ Ask Questions ──┐
|
|
69
|
+
│ ↓
|
|
70
|
+
│yes/minor Create spec.md
|
|
71
|
+
↓ ↓
|
|
72
|
+
Make Assumption ────────────────────────────┘
|
|
73
|
+
↓
|
|
74
|
+
Create tasks.md
|
|
75
|
+
↓
|
|
76
|
+
Create checklist.md
|
|
77
|
+
↓
|
|
78
|
+
Notify User
|
|
79
|
+
↓
|
|
80
|
+
User Review ──changes needed──→ Revise Specs ──┐
|
|
81
|
+
│ ↓
|
|
82
|
+
│approved └──→ (back to User Review)
|
|
83
|
+
↓
|
|
84
|
+
Implementation
|
|
85
|
+
↓
|
|
86
|
+
Complete & Report
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Key Principles
|
|
90
|
+
|
|
91
|
+
1. **Scan before asking** - Never ask before scanning context
|
|
92
|
+
2. **Assume when reasonable** - Don't ask about minor details
|
|
93
|
+
3. **Notify, don't question** - Use notification format for confirmation
|
|
94
|
+
4. **Execute without interruption** - After confirmation, no more questions
|