specflow-cc 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.
@@ -0,0 +1,319 @@
1
+ ---
2
+ name: sf:metrics
3
+ description: Show project statistics and quality metrics
4
+ allowed-tools:
5
+ - Read
6
+ - Bash
7
+ - Glob
8
+ - Grep
9
+ ---
10
+
11
+ <purpose>
12
+ Calculate and display project statistics including completion rates, quality metrics (audit/review cycles), complexity distribution, and actionable insights. Helps understand project health and identify areas for improvement.
13
+ </purpose>
14
+
15
+ <context>
16
+ @.specflow/PROJECT.md
17
+ @.specflow/STATE.md
18
+ @.specflow/specs/SPEC-*.md
19
+ @.specflow/archive/SPEC-*.md
20
+ @.specflow/todos/TODO.md
21
+ </context>
22
+
23
+ <workflow>
24
+
25
+ ## Step 1: Verify Initialization
26
+
27
+ ```bash
28
+ [ -d .specflow ] && echo "OK" || echo "NOT_INITIALIZED"
29
+ ```
30
+
31
+ **If NOT_INITIALIZED:**
32
+ ```
33
+ SpecFlow not initialized.
34
+
35
+ Run `/sf init` first.
36
+ ```
37
+ Exit.
38
+
39
+ ## Step 2: Gather Data
40
+
41
+ ### Count Specifications
42
+
43
+ ```bash
44
+ # Active specs
45
+ ACTIVE=$(ls .specflow/specs/SPEC-*.md 2>/dev/null | wc -l)
46
+
47
+ # Archived specs
48
+ ARCHIVED=$(ls .specflow/archive/SPEC-*.md 2>/dev/null | wc -l)
49
+
50
+ # Total
51
+ TOTAL=$((ACTIVE + ARCHIVED))
52
+ ```
53
+
54
+ ### Parse Active Specs
55
+
56
+ For each `.specflow/specs/SPEC-*.md`:
57
+ - Extract status from frontmatter
58
+ - Extract complexity from frontmatter
59
+ - Extract type from frontmatter
60
+ - Count audit entries
61
+
62
+ Group by status:
63
+ - draft
64
+ - audited
65
+ - running
66
+ - review
67
+ - (done specs are in archive)
68
+
69
+ ### Parse Archived Specs
70
+
71
+ For each `.specflow/archive/SPEC-*.md`:
72
+ - Extract complexity
73
+ - Extract type
74
+ - Count audit cycles (Audit v1, v2, etc.)
75
+ - Count review cycles
76
+ - Check if first-pass audit (only 1 audit = first-pass)
77
+ - Check if first-pass review (only 1 review = first-pass)
78
+
79
+ ### Parse To-Dos
80
+
81
+ ```bash
82
+ # Count todos
83
+ TODO_COUNT=$(grep -c "^## TODO-" .specflow/todos/TODO.md 2>/dev/null || echo 0)
84
+
85
+ # Count converted (todos that became specs - check STATE.md decisions)
86
+ # This is approximated by todos with "converted" or spec reference
87
+ ```
88
+
89
+ ### Get Project Start Date
90
+
91
+ Read `.specflow/PROJECT.md` for initialized date, or use earliest spec creation date.
92
+
93
+ ## Step 3: Calculate Metrics
94
+
95
+ ### Completion Metrics
96
+
97
+ ```
98
+ Total created: TOTAL
99
+ Completed: ARCHIVED
100
+ In progress: ACTIVE (non-draft)
101
+ Draft: count where status = draft
102
+ Completion rate: (ARCHIVED / TOTAL) × 100%
103
+ ```
104
+
105
+ ### Quality Metrics
106
+
107
+ ```
108
+ Avg audit cycles: sum(audits) / ARCHIVED
109
+ Avg review cycles: sum(reviews) / ARCHIVED
110
+ First-pass audit rate: (specs with 1 audit / ARCHIVED) × 100%
111
+ First-pass review rate: (specs with 1 review / ARCHIVED) × 100%
112
+ ```
113
+
114
+ ### Complexity Distribution
115
+
116
+ ```
117
+ Small: count where complexity = small
118
+ Medium: count where complexity = medium
119
+ Large: count where complexity = large
120
+ ```
121
+
122
+ ### Type Distribution
123
+
124
+ ```
125
+ Feature: count where type = feature
126
+ Refactor: count where type = refactor
127
+ Bugfix: count where type = bugfix
128
+ ```
129
+
130
+ ### To-Do Metrics
131
+
132
+ ```
133
+ Total items: TODO_COUNT
134
+ Pending: count without conversion
135
+ Converted: count with conversion
136
+ Conversion rate: (converted / total) × 100%
137
+ ```
138
+
139
+ ## Step 4: Generate Insights
140
+
141
+ Based on calculated metrics, generate 2-4 actionable insights:
142
+
143
+ **If first-pass audit rate < 50%:**
144
+ - "Consider more thorough initial specifications"
145
+
146
+ **If avg audit cycles > 2:**
147
+ - "Specs may benefit from better scoping upfront"
148
+
149
+ **If large specs > 20% of total:**
150
+ - "Consider splitting large specs earlier (/sf split)"
151
+
152
+ **If first-pass review rate > 70%:**
153
+ - "Good implementation quality — specs are well-defined"
154
+
155
+ **If completion rate < 50% and TOTAL > 5:**
156
+ - "Many specs in progress — consider completing before starting new"
157
+
158
+ **If TODO_COUNT > 5 and conversion rate < 30%:**
159
+ - "Backlog growing — consider /sf priority or /sf plan"
160
+
161
+ **If all metrics good:**
162
+ - "Project health is excellent — keep up the discipline!"
163
+
164
+ ## Step 5: Display Metrics
165
+
166
+ ```
167
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
168
+ PROJECT METRICS
169
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
170
+
171
+ **Project:** {project name from PROJECT.md}
172
+ **Initialized:** {date}
173
+ **Period:** {days} days
174
+
175
+ ---
176
+
177
+ ## Specifications
178
+
179
+ | Metric | Value |
180
+ |---------------------|----------|
181
+ | Total created | {N} |
182
+ | Completed | {N} |
183
+ | In progress | {N} |
184
+ | Draft | {N} |
185
+ | Completion rate | {N}% |
186
+
187
+ ## Status Breakdown
188
+
189
+ | Status | Count |
190
+ |-----------|-------|
191
+ | done | {N} |
192
+ | review | {N} |
193
+ | running | {N} |
194
+ | audited | {N} |
195
+ | draft | {N} |
196
+
197
+ ## Complexity Distribution
198
+
199
+ | Size | Count | % of Total |
200
+ |--------|-------|------------|
201
+ | Small | {N} | {N}% |
202
+ | Medium | {N} | {N}% |
203
+ | Large | {N} | {N}% |
204
+
205
+ ## Type Distribution
206
+
207
+ | Type | Count | % of Total |
208
+ |----------|-------|------------|
209
+ | feature | {N} | {N}% |
210
+ | refactor | {N} | {N}% |
211
+ | bugfix | {N} | {N}% |
212
+
213
+ ## Quality Metrics
214
+
215
+ {If ARCHIVED > 0:}
216
+ | Metric | Value |
217
+ |--------------------------|-------|
218
+ | Avg audit cycles | {N.N} |
219
+ | Avg review cycles | {N.N} |
220
+ | First-pass audit rate | {N}% |
221
+ | First-pass review rate | {N}% |
222
+
223
+ ### Audit Results
224
+
225
+ | Result | Count | % |
226
+ |--------------------|-------|-------|
227
+ | Approved (1st try) | {N} | {N}% |
228
+ | Approved (2+ tries)| {N} | {N}% |
229
+
230
+ ### Review Results
231
+
232
+ | Result | Count | % |
233
+ |--------------------|-------|-------|
234
+ | Approved (1st try) | {N} | {N}% |
235
+ | Approved (2+ tries)| {N} | {N}% |
236
+
237
+ {If ARCHIVED = 0:}
238
+ *No completed specifications yet — quality metrics will appear after first completion.*
239
+
240
+ ## To-Do Backlog
241
+
242
+ {If TODO.md exists and has items:}
243
+ | Metric | Value |
244
+ |----------------|-------|
245
+ | Total items | {N} |
246
+ | Pending | {N} |
247
+ | Converted | {N} |
248
+ | Conversion rate| {N}% |
249
+
250
+ {If no todos:}
251
+ No to-do items.
252
+
253
+ Add ideas: `/sf todo "idea"`
254
+
255
+ ---
256
+
257
+ ## Insights
258
+
259
+ {List 2-4 insights based on analysis}
260
+
261
+ - {Insight 1}
262
+ - {Insight 2}
263
+ - {Insight 3}
264
+
265
+ ---
266
+
267
+ *Metrics calculated from project data*
268
+ *Period: {start date} — {today}*
269
+ ```
270
+
271
+ ## Step 6: Handle Insufficient Data
272
+
273
+ **If TOTAL = 0:**
274
+ ```
275
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
276
+ PROJECT METRICS
277
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
278
+
279
+ **Project:** {project name}
280
+ **Initialized:** {date}
281
+
282
+ ---
283
+
284
+ ## Insufficient Data
285
+
286
+ No specifications created yet.
287
+
288
+ Create your first specification to start tracking metrics:
289
+
290
+ `/sf new "task description"`
291
+
292
+ ---
293
+
294
+ ## What Metrics Will Track
295
+
296
+ Once you have specifications:
297
+ - Completion rates
298
+ - Audit/review cycle efficiency
299
+ - Complexity distribution
300
+ - Quality trends
301
+
302
+ **Tip:** The more specs you complete, the more valuable these insights become.
303
+ ```
304
+
305
+ </workflow>
306
+
307
+ <success_criteria>
308
+ - [ ] Initialization verified
309
+ - [ ] All specs (active + archived) counted
310
+ - [ ] Status breakdown calculated
311
+ - [ ] Complexity distribution calculated
312
+ - [ ] Type distribution calculated
313
+ - [ ] Audit cycles averaged (if archived exists)
314
+ - [ ] Review cycles averaged (if archived exists)
315
+ - [ ] First-pass rates calculated
316
+ - [ ] To-do metrics included
317
+ - [ ] Actionable insights generated
318
+ - [ ] Insufficient data handled gracefully
319
+ </success_criteria>
@@ -0,0 +1,171 @@
1
+ ---
2
+ name: sf:new
3
+ description: Create a new specification from task description
4
+ allowed-tools:
5
+ - Read
6
+ - Write
7
+ - Bash
8
+ - Glob
9
+ - Grep
10
+ - Task
11
+ - AskUserQuestion
12
+ ---
13
+
14
+ <purpose>
15
+ Create a new specification from a task description. Asks critical questions if needed, estimates complexity, and creates a well-structured SPEC-XXX.md file.
16
+ </purpose>
17
+
18
+ <context>
19
+ @.specflow/PROJECT.md
20
+ @.specflow/STATE.md
21
+ @~/.claude/specflow-cc/templates/spec.md
22
+ @~/.claude/specflow-cc/agents/spec-creator.md
23
+ </context>
24
+
25
+ <workflow>
26
+
27
+ ## Step 1: Verify Initialization
28
+
29
+ ```bash
30
+ [ -d .specflow ] && echo "OK" || echo "NOT_INITIALIZED"
31
+ ```
32
+
33
+ **If NOT_INITIALIZED:**
34
+ ```
35
+ SpecFlow not initialized.
36
+
37
+ Run `/sf init` first.
38
+ ```
39
+ Exit.
40
+
41
+ ## Step 2: Parse Arguments
42
+
43
+ Extract task description from command arguments.
44
+
45
+ **If no description provided:**
46
+ Use AskUserQuestion:
47
+ - header: "Task"
48
+ - question: "What do you want to build?"
49
+ - options: (freeform text input)
50
+
51
+ ## Step 3: Spawn Spec Creator Agent
52
+
53
+ Launch the spec-creator subagent with context:
54
+
55
+ ```
56
+ Task(prompt="
57
+ <task_description>
58
+ {user's task description}
59
+ </task_description>
60
+
61
+ <project_context>
62
+ @.specflow/PROJECT.md
63
+ </project_context>
64
+
65
+ <current_state>
66
+ @.specflow/STATE.md
67
+ </current_state>
68
+
69
+ Create a specification following the spec-creator agent instructions.
70
+ ", subagent_type="sf-spec-creator", description="Create specification")
71
+ ```
72
+
73
+ ## Step 4: Handle Agent Response
74
+
75
+ The agent will:
76
+ 1. Ask critical questions (0-3) if needed
77
+ 2. Create SPEC-XXX.md
78
+ 3. Update STATE.md
79
+ 4. Return structured result
80
+
81
+ ## Step 5: Display Result
82
+
83
+ ```
84
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
85
+ SPECIFICATION CREATED
86
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
87
+
88
+ **ID:** SPEC-XXX
89
+ **Title:** [title]
90
+ **Type:** [feature | refactor | bugfix]
91
+ **Complexity:** [small | medium | large]
92
+
93
+ ### Assumptions Made
94
+
95
+ - [List assumptions agent made]
96
+
97
+ ### File
98
+
99
+ `.specflow/specs/SPEC-XXX.md`
100
+
101
+ ---
102
+
103
+ ## Next Step
104
+
105
+ `/sf audit` — audit specification before implementation
106
+
107
+ {If complexity is large:}
108
+
109
+ ### Warning
110
+
111
+ Specification is large (>150k tokens estimated).
112
+ Consider `/sf split SPEC-XXX` to decompose into smaller specs.
113
+ ```
114
+
115
+ </workflow>
116
+
117
+ <fallback>
118
+
119
+ **If agent spawning fails**, execute inline:
120
+
121
+ ## Inline Spec Creation
122
+
123
+ ### Get Next Spec Number
124
+
125
+ ```bash
126
+ LAST=$(ls .specflow/specs/SPEC-*.md 2>/dev/null | sort -V | tail -1 | grep -oP 'SPEC-\K\d+')
127
+ NEXT=$(printf "%03d" $((${LAST:-0} + 1)))
128
+ echo "SPEC-$NEXT"
129
+ ```
130
+
131
+ ### Analyze Task
132
+
133
+ Based on task description:
134
+ - Determine type: feature/refactor/bugfix
135
+ - Identify likely files to modify
136
+ - Estimate complexity
137
+
138
+ ### Write Specification
139
+
140
+ Create `.specflow/specs/SPEC-XXX.md` with:
141
+ - Frontmatter (id, type, status: draft, priority: medium, complexity, created)
142
+ - Context section
143
+ - Task section
144
+ - Requirements section
145
+ - Acceptance criteria
146
+ - Constraints
147
+ - Assumptions
148
+
149
+ ### Update STATE.md
150
+
151
+ ```markdown
152
+ ## Current Position
153
+
154
+ - **Active Specification:** SPEC-XXX
155
+ - **Status:** drafting
156
+ - **Next Step:** /sf audit
157
+ ```
158
+
159
+ Add to Queue table.
160
+
161
+ </fallback>
162
+
163
+ <success_criteria>
164
+ - [ ] SpecFlow initialization verified
165
+ - [ ] Task description obtained
166
+ - [ ] SPEC-XXX.md created with all sections
167
+ - [ ] Complexity estimated (small/medium/large)
168
+ - [ ] Assumptions documented
169
+ - [ ] STATE.md updated with new spec
170
+ - [ ] User knows next step is /sf audit
171
+ </success_criteria>
@@ -0,0 +1,182 @@
1
+ ---
2
+ name: sf:next
3
+ description: Find and activate the highest priority actionable specification
4
+ allowed-tools:
5
+ - Read
6
+ - Write
7
+ - Bash
8
+ - Glob
9
+ ---
10
+
11
+ <purpose>
12
+ Find the highest priority specification that needs action, set it as active in STATE.md, and show its summary with the recommended next action. Helps quickly jump back into work.
13
+ </purpose>
14
+
15
+ <context>
16
+ @.specflow/STATE.md
17
+ </context>
18
+
19
+ <workflow>
20
+
21
+ ## Step 1: Verify Initialization
22
+
23
+ ```bash
24
+ [ -d .specflow ] && echo "OK" || echo "NOT_INITIALIZED"
25
+ ```
26
+
27
+ **If NOT_INITIALIZED:**
28
+ ```
29
+ SpecFlow not initialized.
30
+
31
+ Run `/sf init` to start.
32
+ ```
33
+ Exit.
34
+
35
+ ## Step 2: Find All Specifications
36
+
37
+ ```bash
38
+ ls -1 .specflow/specs/SPEC-*.md 2>/dev/null
39
+ ```
40
+
41
+ **If no specs found:**
42
+ ```
43
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
44
+ NO ACTIONABLE TASKS
45
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
46
+
47
+ No specifications ready for work.
48
+
49
+ **Options:**
50
+ - `/sf new "description"` — create new specification
51
+ - `/sf todos` — view idea backlog
52
+ ```
53
+ Exit.
54
+
55
+ ## Step 3: Parse and Score Specifications
56
+
57
+ For each spec, read frontmatter and calculate priority score:
58
+
59
+ ### Status Priority (higher = more urgent)
60
+ | Status | Score | Reason |
61
+ |--------|-------|--------|
62
+ | review | 100 | Needs immediate attention (almost done) |
63
+ | running | 90 | In progress, continue |
64
+ | audited | 80 | Ready to implement |
65
+ | revision_requested | 70 | Needs revision |
66
+ | auditing | 60 | Audit in progress |
67
+ | draft | 50 | Needs audit |
68
+
69
+ ### Priority Modifier
70
+ | Priority | Modifier |
71
+ |----------|----------|
72
+ | high | +30 |
73
+ | medium | +20 |
74
+ | low | +10 |
75
+
76
+ ### Final Score
77
+ `score = status_score + priority_modifier`
78
+
79
+ For ties, prefer older specs (lower ID number).
80
+
81
+ ## Step 4: Select Best Candidate
82
+
83
+ Choose spec with highest score.
84
+
85
+ **If no actionable specs** (all done or blocked):
86
+ ```
87
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
88
+ NO ACTIONABLE TASKS
89
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
90
+
91
+ All specifications are either completed or blocked.
92
+
93
+ **Options:**
94
+ - `/sf new "description"` — create new specification
95
+ - `/sf todos` — view idea backlog
96
+ - `/sf list` — see all specifications
97
+ ```
98
+ Exit.
99
+
100
+ ## Step 5: Update STATE.md
101
+
102
+ Update `.specflow/STATE.md`:
103
+ - Set **Active Specification** to selected spec
104
+ - Set **Status** based on spec's current status
105
+ - Set **Next Step** based on recommended action
106
+
107
+ ## Step 6: Determine Recommended Action
108
+
109
+ | Status | Recommended Command | Description |
110
+ |--------|---------------------|-------------|
111
+ | draft | `/sf audit` | Audit specification |
112
+ | auditing | Continue audit | Complete the audit |
113
+ | revision_requested | `/sf revise` | Address audit comments |
114
+ | audited | `/sf run` | Implement specification |
115
+ | running | Continue or `/sf review` | Complete implementation |
116
+ | review | `/sf fix` or `/sf done` | Address review or finalize |
117
+
118
+ ## Step 7: Display Next Task
119
+
120
+ ```
121
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
122
+ NEXT TASK
123
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
124
+
125
+ **{ID}:** {Title}
126
+ **Priority:** {priority} | **Status:** {status} | **Complexity:** {complexity}
127
+
128
+ ---
129
+
130
+ ## Summary
131
+
132
+ {First 2-3 sentences from Context or Task section}
133
+
134
+ ## Acceptance Criteria
135
+
136
+ {List acceptance criteria with checkboxes}
137
+
138
+ ---
139
+
140
+ {If there are outstanding issues from audit/review:}
141
+ ## Outstanding Issues
142
+
143
+ From {audit/review} v{N}:
144
+ 1. {issue}
145
+ 2. {issue}
146
+
147
+ ---
148
+
149
+ **Ready to {action description}:** `{recommended_command}`
150
+
151
+ {If more specs in queue:}
152
+ **Queue:** {N} more specs waiting
153
+ ```
154
+
155
+ ## Step 8: Show Context Tips
156
+
157
+ **If status is revision_requested:**
158
+ ```
159
+ **Tip:** Review audit comments with `/sf show {ID}` before revising.
160
+ ```
161
+
162
+ **If status is review:**
163
+ ```
164
+ **Tip:** Check implementation against acceptance criteria.
165
+ ```
166
+
167
+ **If complexity is large:**
168
+ ```
169
+ **Tip:** Consider `/sf split {ID}` to break into smaller specs.
170
+ ```
171
+
172
+ </workflow>
173
+
174
+ <success_criteria>
175
+ - [ ] Initialization verified
176
+ - [ ] All specs scanned and scored
177
+ - [ ] Highest priority actionable spec selected
178
+ - [ ] STATE.md updated with new active spec
179
+ - [ ] Summary displayed with acceptance criteria
180
+ - [ ] Clear recommended action provided
181
+ - [ ] Queue status shown
182
+ </success_criteria>