@panuwatbas/spec-driven-dev 1.0.2

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.
@@ -0,0 +1,159 @@
1
+ #!/usr/bin/env bash
2
+ # ============================================================================
3
+ # init-spec.sh — Initialize a new spec directory for a feature
4
+ #
5
+ # Usage:
6
+ # bash .specs/scripts/init-spec.sh <feature-name> [--bugfix]
7
+ #
8
+ # Examples:
9
+ # bash .specs/scripts/init-spec.sh user-authentication
10
+ # bash .specs/scripts/init-spec.sh login-crash --bugfix
11
+ # ============================================================================
12
+
13
+ set -euo pipefail
14
+
15
+ # --- Configuration ---
16
+ SPECS_DIR=".specs"
17
+ SKILL_DIR=""
18
+
19
+ # Find the skill templates directory
20
+ # Check common locations
21
+ for dir in \
22
+ ".gemini/skills/spec-driven-dev/templates" \
23
+ "skills/spec-driven-dev/templates" \
24
+ ".cursor/skills/spec-driven-dev/templates" \
25
+ ; do
26
+ if [ -d "$dir" ]; then
27
+ SKILL_DIR="$dir"
28
+ break
29
+ fi
30
+ done
31
+
32
+ # --- Parse Arguments ---
33
+ FEATURE_NAME="${1:-}"
34
+ MODE="feature"
35
+
36
+ if [ -z "$FEATURE_NAME" ]; then
37
+ echo "❌ Error: Feature name is required."
38
+ echo ""
39
+ echo "Usage: bash $0 <feature-name> [--bugfix]"
40
+ echo ""
41
+ echo "Examples:"
42
+ echo " bash $0 user-authentication"
43
+ echo " bash $0 login-crash --bugfix"
44
+ exit 1
45
+ fi
46
+
47
+ if [ "${2:-}" = "--bugfix" ]; then
48
+ MODE="bugfix"
49
+ fi
50
+
51
+ # --- Create Directory ---
52
+ SPEC_PATH="$SPECS_DIR/$FEATURE_NAME"
53
+
54
+ if [ -d "$SPEC_PATH" ]; then
55
+ echo "⚠️ Spec directory already exists: $SPEC_PATH"
56
+ echo " Use the existing spec or choose a different name."
57
+ exit 1
58
+ fi
59
+
60
+ mkdir -p "$SPEC_PATH"
61
+ echo "📁 Created: $SPEC_PATH/"
62
+
63
+ # --- Copy Templates ---
64
+ if [ -n "$SKILL_DIR" ]; then
65
+ cp "$SKILL_DIR/requirements.template.md" "$SPEC_PATH/requirements.md"
66
+ cp "$SKILL_DIR/design.template.md" "$SPEC_PATH/design.md"
67
+ cp "$SKILL_DIR/tasks.template.md" "$SPEC_PATH/tasks.md"
68
+ echo "📄 Copied templates from $SKILL_DIR"
69
+ else
70
+ # Create minimal files if templates not found
71
+ cat > "$SPEC_PATH/requirements.md" << 'EOF'
72
+ # Feature: [Feature Name]
73
+
74
+ > **Status:** 🟡 Draft
75
+
76
+ ## Overview
77
+
78
+ [Describe the feature here.]
79
+
80
+ ## User Stories
81
+
82
+ ### US-1: [Story Title]
83
+
84
+ **As a** [persona],
85
+ **I want to** [action],
86
+ **so that** [benefit].
87
+
88
+ #### Acceptance Criteria
89
+
90
+ ##### AC-1.1: [Scenario]
91
+
92
+ **Given** [precondition]
93
+ **When** [action]
94
+ **Then** [outcome]
95
+ EOF
96
+
97
+ cat > "$SPEC_PATH/design.md" << 'EOF'
98
+ # Technical Design: [Feature Name]
99
+
100
+ > **Status:** 🟡 Draft
101
+
102
+ ## Overview
103
+
104
+ [Describe the technical approach here.]
105
+
106
+ ## Architecture
107
+
108
+ [Define the architecture.]
109
+
110
+ ## Component Design
111
+
112
+ [Define the components.]
113
+ EOF
114
+
115
+ cat > "$SPEC_PATH/tasks.md" << 'EOF'
116
+ # Implementation Tasks: [Feature Name]
117
+
118
+ > **Status:** 🟡 Not Started
119
+
120
+ ## Phase 1: [Foundation]
121
+
122
+ - [ ] **Task 1.1:** [Description]
123
+ - [ ] **Task 1.2 (Verify):** Verification
124
+
125
+ ## Phase 2: [Core Logic]
126
+
127
+ - [ ] **Task 2.1:** [Description]
128
+ - [ ] **Task 2.2 (Verify):** Verification
129
+ EOF
130
+
131
+ echo "📄 Created minimal spec files (templates not found)"
132
+ fi
133
+
134
+ # --- Replace Placeholders ---
135
+ DATE=$(date +%Y-%m-%d)
136
+ TITLE=$(echo "$FEATURE_NAME" | sed 's/-/ /g' | sed 's/\b\w/\u&/g')
137
+
138
+ if [[ "$OSTYPE" == "darwin"* ]]; then
139
+ SED_CMD="sed -i ''"
140
+ else
141
+ SED_CMD="sed -i"
142
+ fi
143
+
144
+ for file in "$SPEC_PATH"/*.md; do
145
+ $SED_CMD "s/\[Feature Name\]/$TITLE/g" "$file" 2>/dev/null || true
146
+ $SED_CMD "s/\[Date\]/$DATE/g" "$file" 2>/dev/null || true
147
+ done
148
+
149
+ # --- Summary ---
150
+ echo ""
151
+ echo "✅ Spec initialized for: $FEATURE_NAME"
152
+ echo ""
153
+ echo "📋 Next steps:"
154
+ echo " 1. Edit $SPEC_PATH/requirements.md — Define WHAT to build"
155
+ echo " 2. Edit $SPEC_PATH/design.md — Define HOW to build it"
156
+ echo " 3. Edit $SPEC_PATH/tasks.md — Define the execution plan"
157
+ echo ""
158
+ echo "💡 Or ask your AI agent:"
159
+ echo " \"Start a spec for $FEATURE_NAME using the spec-driven-dev skill\""
@@ -0,0 +1,248 @@
1
+ # Technical Design: [Feature Name]
2
+
3
+ > **Status:** 🟡 Draft | 🟢 Approved | 🔴 Needs Revision
4
+ >
5
+ > **Requirements:** [Link to requirements.md](../requirements.md)
6
+ >
7
+ > **Author:** [Name / AI Agent]
8
+ >
9
+ > **Created:** [Date]
10
+ >
11
+ > **Last Updated:** [Date]
12
+
13
+ ---
14
+
15
+ ## 1. Overview
16
+
17
+ <!-- 2-3 sentence summary of the technical approach. What is the architectural strategy? -->
18
+
19
+ [Describe the high-level technical approach here.]
20
+
21
+ ---
22
+
23
+ ## 2. Architecture
24
+
25
+ ### 2.1 System Diagram
26
+
27
+ ```mermaid
28
+ graph TD
29
+ A[Client / UI] --> B[API Layer]
30
+ B --> C[Business Logic]
31
+ C --> D[(Database)]
32
+ C --> E[External Service]
33
+ ```
34
+
35
+ ### 2.2 Architectural Pattern
36
+
37
+ <!-- e.g., MVC, Microservices, Event-Driven, Serverless, Monolith -->
38
+
39
+ [Describe the chosen pattern and justify the decision.]
40
+
41
+ ### 2.3 Tech Stack
42
+
43
+ | Layer | Technology | Justification |
44
+ |-------|-----------|---------------|
45
+ | Frontend | [e.g., React, Vue] | [Why this choice] |
46
+ | Backend | [e.g., Node.js, Python] | [Why this choice] |
47
+ | Database | [e.g., PostgreSQL, MongoDB] | [Why this choice] |
48
+ | Hosting | [e.g., Vercel, AWS] | [Why this choice] |
49
+
50
+ ---
51
+
52
+ ## 3. Component Design
53
+
54
+ ### 3.1 [Component Name A]
55
+
56
+ - **Responsibility:** [Single-sentence description of this component's job]
57
+ - **Location:** `src/components/ComponentA/`
58
+ - **Public Interface:**
59
+ ```typescript
60
+ // Example API / function signatures
61
+ interface ComponentAProps {
62
+ data: DataType;
63
+ onAction: (id: string) => void;
64
+ }
65
+ ```
66
+ - **State Management:** [How data flows in/out]
67
+ - **Dependencies:** [What this component depends on]
68
+
69
+ ### 3.2 [Component Name B]
70
+
71
+ - **Responsibility:** [Single-sentence description]
72
+ - **Location:** `src/services/ServiceB/`
73
+ - **Public Interface:**
74
+ ```typescript
75
+ class ServiceB {
76
+ async getData(id: string): Promise<DataType> {}
77
+ async updateData(id: string, payload: UpdatePayload): Promise<void> {}
78
+ }
79
+ ```
80
+ - **Error Handling:** [How errors are managed]
81
+
82
+ <!-- Add more components as needed -->
83
+
84
+ ---
85
+
86
+ ## 4. Data Models
87
+
88
+ ### 4.1 [Entity Name]
89
+
90
+ ```typescript
91
+ interface EntityName {
92
+ id: string; // UUID, primary key
93
+ name: string; // Display name
94
+ status: 'active' | 'inactive';
95
+ createdAt: Date;
96
+ updatedAt: Date;
97
+ }
98
+ ```
99
+
100
+ ### 4.2 Database Schema
101
+
102
+ ```sql
103
+ CREATE TABLE entity_name (
104
+ id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
105
+ name VARCHAR(255) NOT NULL,
106
+ status VARCHAR(20) DEFAULT 'active',
107
+ created_at TIMESTAMP DEFAULT NOW(),
108
+ updated_at TIMESTAMP DEFAULT NOW()
109
+ );
110
+ ```
111
+
112
+ <!-- Add more data models as needed -->
113
+
114
+ ---
115
+
116
+ ## 5. API Contracts
117
+
118
+ ### 5.1 [Endpoint Name]
119
+
120
+ | Property | Value |
121
+ |----------|-------|
122
+ | Method | `POST` |
123
+ | Path | `/api/v1/resource` |
124
+ | Auth | Required (Bearer token) |
125
+
126
+ **Request Body:**
127
+ ```json
128
+ {
129
+ "name": "string",
130
+ "description": "string (optional)"
131
+ }
132
+ ```
133
+
134
+ **Response (200):**
135
+ ```json
136
+ {
137
+ "id": "uuid",
138
+ "name": "string",
139
+ "createdAt": "ISO-8601"
140
+ }
141
+ ```
142
+
143
+ **Error Responses:**
144
+
145
+ | Status | Description |
146
+ |--------|-------------|
147
+ | 400 | Invalid input — missing required fields |
148
+ | 401 | Unauthorized — invalid or missing token |
149
+ | 409 | Conflict — resource already exists |
150
+
151
+ <!-- Add more endpoints as needed -->
152
+
153
+ ---
154
+
155
+ ## 6. Sequence Diagrams
156
+
157
+ ### 6.1 [Flow Name — e.g., User Creates Resource]
158
+
159
+ ```mermaid
160
+ sequenceDiagram
161
+ actor User
162
+ participant UI as Frontend
163
+ participant API as API Server
164
+ participant DB as Database
165
+
166
+ User->>UI: Fills form and clicks Submit
167
+ UI->>API: POST /api/v1/resource
168
+ API->>API: Validate input
169
+ API->>DB: INSERT INTO resource
170
+ DB-->>API: Success
171
+ API-->>UI: 201 Created
172
+ UI-->>User: Show success message
173
+ ```
174
+
175
+ <!-- Add more sequence diagrams as needed -->
176
+
177
+ ---
178
+
179
+ ## 7. Error Handling Strategy
180
+
181
+ | Error Type | Handling Approach |
182
+ |-----------|-------------------|
183
+ | Validation errors | Return 400 with field-level error messages |
184
+ | Auth errors | Return 401/403, redirect to login |
185
+ | Not found | Return 404 with descriptive message |
186
+ | Server errors | Return 500, log to monitoring, show generic message to user |
187
+ | Network errors | Retry with exponential backoff (max 3 attempts) |
188
+
189
+ ---
190
+
191
+ ## 8. Testing Strategy
192
+
193
+ | Level | Tool | Coverage Target |
194
+ |-------|------|----------------|
195
+ | Unit Tests | [e.g., Jest, Vitest] | Core business logic |
196
+ | Integration Tests | [e.g., Supertest] | API endpoints |
197
+ | E2E Tests | [e.g., Playwright, Cypress] | Critical user flows |
198
+
199
+ ---
200
+
201
+ ## 9. Security Considerations
202
+
203
+ - [ ] Input validation and sanitization on all endpoints
204
+ - [ ] Authentication required for protected routes
205
+ - [ ] Rate limiting on public endpoints
206
+ - [ ] Sensitive data encrypted at rest
207
+ - [ ] CORS properly configured
208
+ - [ ] SQL injection prevention (parameterized queries)
209
+ - [ ] XSS prevention (output encoding)
210
+
211
+ ---
212
+
213
+ ## 10. Constraints & Rules
214
+
215
+ ### Forbidden Patterns
216
+ - ❌ No global mutable state
217
+ - ❌ No direct DOM manipulation (use framework reactivity)
218
+ - ❌ No hardcoded secrets or credentials
219
+ - ❌ No `any` type in TypeScript (use proper typing)
220
+
221
+ ### Naming Conventions
222
+ - Files: `kebab-case.ts`
223
+ - Components: `PascalCase`
224
+ - Functions: `camelCase`
225
+ - Constants: `UPPER_SNAKE_CASE`
226
+ - Database tables: `snake_case`
227
+
228
+ ### Code Quality
229
+ - Max function length: 50 lines
230
+ - Max file length: 300 lines
231
+ - All public functions must have JSDoc comments
232
+
233
+ ---
234
+
235
+ ## 11. Open Questions
236
+
237
+ <!-- Technical questions that need resolution before or during implementation. -->
238
+
239
+ - [ ] [Technical question 1]
240
+ - [ ] [Technical question 2]
241
+
242
+ ---
243
+
244
+ ## 12. Revision History
245
+
246
+ | Version | Date | Author | Changes |
247
+ |---------|------|--------|---------|
248
+ | 0.1 | [Date] | [Author] | Initial design |
@@ -0,0 +1,116 @@
1
+ # Feature: [Feature Name]
2
+
3
+ > **Status:** 🟡 Draft | 🟢 Approved | 🔴 Needs Revision
4
+ >
5
+ > **Author:** [Name / AI Agent]
6
+ >
7
+ > **Created:** [Date]
8
+ >
9
+ > **Last Updated:** [Date]
10
+
11
+ ---
12
+
13
+ ## Overview
14
+
15
+ <!-- Brief 2-3 sentence summary of the feature. What problem does it solve? Why is it needed? -->
16
+
17
+ [Describe the feature at a high level here.]
18
+
19
+ ---
20
+
21
+ ## User Stories
22
+
23
+ ### US-1: [Primary User Story Title]
24
+
25
+ **As a** [persona / role],
26
+ **I want to** [action / goal],
27
+ **so that** [benefit / business value].
28
+
29
+ #### Acceptance Criteria
30
+
31
+ ##### AC-1.1: [Scenario Title — Happy Path]
32
+
33
+ **Given** [the initial context or precondition]
34
+ **And** [additional precondition, if any]
35
+ **When** [the action or event occurs]
36
+ **Then** [the expected outcome or result]
37
+ **And** [additional expected outcome, if any]
38
+
39
+ ##### AC-1.2: [Scenario Title — Edge Case]
40
+
41
+ **Given** [the initial context or precondition]
42
+ **When** [the action or event occurs]
43
+ **Then** [the expected outcome or result]
44
+
45
+ ##### AC-1.3: [Scenario Title — Error Case]
46
+
47
+ **Given** [the initial context or precondition]
48
+ **When** [an invalid action or bad input occurs]
49
+ **Then** [the expected error handling behavior]
50
+ **And** [the system remains in a valid state]
51
+
52
+ ---
53
+
54
+ ### US-2: [Secondary User Story Title]
55
+
56
+ **As a** [persona / role],
57
+ **I want to** [action / goal],
58
+ **so that** [benefit / business value].
59
+
60
+ #### Acceptance Criteria
61
+
62
+ ##### AC-2.1: [Scenario Title]
63
+
64
+ **Given** [precondition]
65
+ **When** [action]
66
+ **Then** [outcome]
67
+
68
+ <!-- Add more user stories and acceptance criteria as needed -->
69
+
70
+ ---
71
+
72
+ ## Out of Scope
73
+
74
+ <!-- Explicitly list what this feature does NOT include to prevent scope creep. -->
75
+
76
+ - [Item 1 — explain why it's excluded]
77
+ - [Item 2 — explain why it's excluded]
78
+
79
+ ---
80
+
81
+ ## Dependencies
82
+
83
+ <!-- List any external systems, APIs, services, or other features this depends on. -->
84
+
85
+ | Dependency | Type | Status |
86
+ |-----------|------|--------|
87
+ | [Dependency 1] | [API / Service / Feature] | [Available / Planned] |
88
+ | [Dependency 2] | [API / Service / Feature] | [Available / Planned] |
89
+
90
+ ---
91
+
92
+ ## Non-Functional Requirements
93
+
94
+ <!-- Performance, security, accessibility, or other quality attributes. -->
95
+
96
+ - **Performance:** [e.g., Page must load in < 2 seconds]
97
+ - **Security:** [e.g., All inputs must be sanitized]
98
+ - **Accessibility:** [e.g., Must meet WCAG 2.1 AA standards]
99
+ - **Browser Support:** [e.g., Chrome, Firefox, Safari latest 2 versions]
100
+
101
+ ---
102
+
103
+ ## Open Questions
104
+
105
+ <!-- List any unresolved questions that need stakeholder input. -->
106
+
107
+ - [ ] [Question 1]
108
+ - [ ] [Question 2]
109
+
110
+ ---
111
+
112
+ ## Revision History
113
+
114
+ | Version | Date | Author | Changes |
115
+ |---------|------|--------|---------|
116
+ | 0.1 | [Date] | [Author] | Initial draft |
@@ -0,0 +1,127 @@
1
+ # Implementation Tasks: [Feature Name]
2
+
3
+ > **Status:** 🟡 Not Started | 🔵 In Progress | 🟢 Completed
4
+ >
5
+ > **Requirements:** [Link to requirements.md](../requirements.md)
6
+ >
7
+ > **Design:** [Link to design.md](../design.md)
8
+ >
9
+ > **Created:** [Date]
10
+ >
11
+ > **Last Updated:** [Date]
12
+
13
+ ---
14
+
15
+ ## Progress Overview
16
+
17
+ | Phase | Status | Tasks | Completed |
18
+ |-------|--------|-------|-----------|
19
+ | Phase 1: [Name] | ⬜ Not Started | 0/0 | 0% |
20
+ | Phase 2: [Name] | ⬜ Not Started | 0/0 | 0% |
21
+ | Phase 3: [Name] | ⬜ Not Started | 0/0 | 0% |
22
+ | Phase 4: [Name] | ⬜ Not Started | 0/0 | 0% |
23
+
24
+ ---
25
+
26
+ ## Phase 1: [Foundation / Setup / Database]
27
+
28
+ > **Goal:** [What this phase accomplishes]
29
+ >
30
+ > **Traces to:** [US-1, AC-1.1] from requirements.md
31
+
32
+ - [ ] **Task 1.1:** [Clear, actionable task description]
33
+ - File(s): `path/to/file.ts`
34
+ - Details: [Implementation specifics, if needed]
35
+ - [ ] Sub-task 1.1.1: [Smaller step if task is complex]
36
+ - [ ] Sub-task 1.1.2: [Smaller step if task is complex]
37
+
38
+ - [ ] **Task 1.2:** [Clear, actionable task description]
39
+ - File(s): `path/to/file.ts`
40
+ - Details: [Implementation specifics]
41
+
42
+ - [ ] **Task 1.3 (Verify):** Run verification for Phase 1
43
+ - [ ] All new files compile without errors
44
+ - [ ] Unit tests pass for Phase 1 components
45
+ - [ ] [Any phase-specific verification]
46
+
47
+ ---
48
+
49
+ ## Phase 2: [Core Logic / Backend / API]
50
+
51
+ > **Goal:** [What this phase accomplishes]
52
+ >
53
+ > **Traces to:** [US-1, AC-1.2, AC-1.3] from requirements.md
54
+
55
+ - [ ] **Task 2.1:** [Clear, actionable task description]
56
+ - File(s): `path/to/file.ts`
57
+ - Details: [Implementation specifics]
58
+
59
+ - [ ] **Task 2.2:** [Clear, actionable task description]
60
+ - File(s): `path/to/file.ts`
61
+ - Details: [Implementation specifics]
62
+
63
+ - [ ] **Task 2.3 (Verify):** Run verification for Phase 2
64
+ - [ ] API endpoints return correct responses
65
+ - [ ] Error cases handled properly
66
+ - [ ] Integration tests pass
67
+
68
+ ---
69
+
70
+ ## Phase 3: [Frontend / UI / Integration]
71
+
72
+ > **Goal:** [What this phase accomplishes]
73
+ >
74
+ > **Traces to:** [US-2, AC-2.1] from requirements.md
75
+
76
+ - [ ] **Task 3.1:** [Clear, actionable task description]
77
+ - File(s): `path/to/file.tsx`
78
+ - Details: [Implementation specifics]
79
+
80
+ - [ ] **Task 3.2:** [Clear, actionable task description]
81
+ - File(s): `path/to/file.tsx`
82
+ - Details: [Implementation specifics]
83
+
84
+ - [ ] **Task 3.3 (Verify):** Run verification for Phase 3
85
+ - [ ] UI renders correctly
86
+ - [ ] User interactions work as expected
87
+ - [ ] Responsive on all target screen sizes
88
+
89
+ ---
90
+
91
+ ## Phase 4: [Testing / Polish / Deployment]
92
+
93
+ > **Goal:** Final verification and cleanup
94
+
95
+ - [ ] **Task 4.1:** Write/update end-to-end tests
96
+ - [ ] Happy path test
97
+ - [ ] Edge case tests
98
+ - [ ] Error scenario tests
99
+
100
+ - [ ] **Task 4.2:** Code quality review
101
+ - [ ] No lint warnings
102
+ - [ ] No TypeScript errors
103
+ - [ ] All functions documented
104
+
105
+ - [ ] **Task 4.3:** Final integration verification
106
+ - [ ] All phases verified
107
+ - [ ] All acceptance criteria from requirements.md met
108
+ - [ ] No regressions in existing functionality
109
+
110
+ ---
111
+
112
+ ## Task Status Legend
113
+
114
+ | Symbol | Meaning |
115
+ |--------|---------|
116
+ | `- [ ]` | Not started |
117
+ | `- [/]` | In progress |
118
+ | `- [x]` | Completed |
119
+ | `- [!]` | Blocked / Needs attention |
120
+
121
+ ---
122
+
123
+ ## Notes
124
+
125
+ <!-- Add any implementation notes, discoveries, or decisions made during execution. -->
126
+
127
+ - [Date]: [Note about a decision or discovery]