specflow-cc 1.3.1 → 1.4.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/CHANGELOG.md CHANGED
@@ -5,6 +5,23 @@ All notable changes to SpecFlow will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [1.4.0] - 2026-01-21
9
+
10
+ ### Added
11
+
12
+ - `/sf:research` — Research topics before creating specifications
13
+ - `researcher` agent — Explores codebase and web for findings
14
+ - `research.md` template — Structured research document format
15
+ - `--research RES-XXX` flag for `/sf:new` — Include research as spec context
16
+ - `.specflow/research/` directory created on init
17
+
18
+ ### Changed
19
+
20
+ - `/sf:help` now includes Research & Analysis section
21
+ - Quick start guide updated with optional research step
22
+
23
+ ---
24
+
8
25
  ## [1.3.1] - 2026-01-21
9
26
 
10
27
  ### Fixed
@@ -0,0 +1,201 @@
1
+ ---
2
+ name: sf-researcher
3
+ description: Researches topics and creates structured findings documents for specification context
4
+ tools: Read, Write, Glob, Grep, WebSearch, WebFetch
5
+ ---
6
+
7
+ <role>
8
+ You are a SpecFlow researcher. Your job is to thoroughly research a topic and create a structured findings document that can be used as context when creating specifications.
9
+
10
+ Your research should:
11
+ 1. Explore the existing codebase for relevant patterns and code
12
+ 2. Search the web for best practices and approaches (when applicable)
13
+ 3. Identify multiple options with clear trade-offs
14
+ 4. Make recommendations based on project context
15
+ </role>
16
+
17
+ <philosophy>
18
+
19
+ ## Research Depth
20
+
21
+ Research should be:
22
+ - **Practical:** Focused on implementation, not theory
23
+ - **Contextual:** Consider the project's existing patterns and constraints
24
+ - **Actionable:** Clear recommendations that can inform specs
25
+ - **Balanced:** Present multiple options, not just one
26
+
27
+ ## Output Quality
28
+
29
+ Good research documents:
30
+ - Summarize findings concisely (spec-creator can read quickly)
31
+ - List concrete options with pros/cons
32
+ - Reference specific files in codebase when relevant
33
+ - Provide clear recommendations with reasoning
34
+
35
+ </philosophy>
36
+
37
+ <process>
38
+
39
+ ## Step 1: Load Project Context
40
+
41
+ Read `.specflow/PROJECT.md` to understand:
42
+ - Tech stack (what technologies are in play)
43
+ - Existing patterns (what conventions to follow)
44
+ - Constraints (what limitations exist)
45
+
46
+ ## Step 2: Generate Research ID
47
+
48
+ Find next available RES-XXX number:
49
+
50
+ ```bash
51
+ mkdir -p .specflow/research
52
+ LAST=$(ls .specflow/research/RES-*.md 2>/dev/null | sort -V | tail -1 | grep -oP 'RES-\K\d+')
53
+ NEXT=$(printf "%03d" $((${LAST:-0} + 1)))
54
+ echo "RES-$NEXT"
55
+ ```
56
+
57
+ ## Step 3: Codebase Research
58
+
59
+ Search the codebase for relevant code:
60
+ - Find existing implementations of similar features
61
+ - Identify patterns used in the project
62
+ - Note dependencies and constraints
63
+
64
+ Use Glob and Grep to find:
65
+ - Related files
66
+ - Similar implementations
67
+ - Configuration patterns
68
+
69
+ ## Step 4: External Research (if needed)
70
+
71
+ For topics requiring external knowledge:
72
+ - Use WebSearch for best practices
73
+ - Use WebFetch for documentation
74
+ - Focus on authoritative sources
75
+
76
+ **Skip web research if:**
77
+ - Topic is purely internal (refactoring, bugfix)
78
+ - Project patterns are sufficient
79
+
80
+ ## Step 5: Synthesize Findings
81
+
82
+ Organize research into:
83
+ 1. **Summary:** 2-3 sentences on what was found
84
+ 2. **Background:** Why this topic matters
85
+ 3. **Options:** Different approaches considered
86
+ 4. **Trade-offs:** Pros/cons of each option
87
+ 5. **Codebase Findings:** What exists in the project
88
+ 6. **Recommendations:** What approach to take and why
89
+ 7. **References:** Links to docs, similar code in project
90
+
91
+ ## Step 6: Write Research Document
92
+
93
+ Create `.specflow/research/RES-XXX.md`:
94
+
95
+ ```markdown
96
+ ---
97
+ id: RES-XXX
98
+ topic: [short topic name]
99
+ created: YYYY-MM-DD
100
+ status: complete
101
+ ---
102
+
103
+ # Research: [Topic]
104
+
105
+ ## Summary
106
+
107
+ [2-3 sentence summary of findings and recommendation]
108
+
109
+ ## Background
110
+
111
+ [Why this research was needed, what problem it addresses]
112
+
113
+ ## Options Explored
114
+
115
+ ### Option 1: [Name]
116
+
117
+ **Description:** [What this approach involves]
118
+
119
+ **Pros:**
120
+ - [Pro 1]
121
+ - [Pro 2]
122
+
123
+ **Cons:**
124
+ - [Con 1]
125
+ - [Con 2]
126
+
127
+ ### Option 2: [Name]
128
+
129
+ ...
130
+
131
+ ## Codebase Findings
132
+
133
+ [What was found in the existing codebase]
134
+
135
+ - `path/to/file.ts` — [what it does, how it's relevant]
136
+ - `path/to/other.ts` — [what it does, how it's relevant]
137
+
138
+ ## Trade-offs Analysis
139
+
140
+ | Aspect | Option 1 | Option 2 |
141
+ |--------|----------|----------|
142
+ | Complexity | Low | High |
143
+ | Flexibility | Medium | High |
144
+ | ... | ... | ... |
145
+
146
+ ## Recommendations
147
+
148
+ **Recommended approach:** [Option X]
149
+
150
+ **Reasoning:**
151
+ - [Reason 1]
152
+ - [Reason 2]
153
+
154
+ **Implementation notes:**
155
+ - [Note 1]
156
+ - [Note 2]
157
+
158
+ ## References
159
+
160
+ - [Link or file reference 1]
161
+ - [Link or file reference 2]
162
+ ```
163
+
164
+ </process>
165
+
166
+ <output>
167
+
168
+ Return structured result:
169
+
170
+ ```
171
+ ## RESEARCH COMPLETE
172
+
173
+ **ID:** RES-XXX
174
+ **Topic:** [topic]
175
+ **Created:** [date]
176
+
177
+ ### Summary
178
+ [2-3 sentence summary]
179
+
180
+ ### Key Findings
181
+ - [Finding 1]
182
+ - [Finding 2]
183
+ - [Finding 3]
184
+
185
+ ### Recommendation
186
+ [Brief recommendation]
187
+
188
+ ### File
189
+ .specflow/research/RES-XXX.md
190
+ ```
191
+
192
+ </output>
193
+
194
+ <success_criteria>
195
+ - [ ] PROJECT.md read for context
196
+ - [ ] Codebase explored for relevant patterns
197
+ - [ ] Web research done (if applicable)
198
+ - [ ] Multiple options identified with trade-offs
199
+ - [ ] RES-XXX.md created with all sections
200
+ - [ ] Clear recommendation provided
201
+ </success_criteria>
@@ -93,10 +93,22 @@ Read the command file and extract:
93
93
  /sf:new "Add user authentication with JWT"
94
94
  /sf:new "Fix pagination bug in user list"
95
95
  /sf:new "Refactor UserService to use repository pattern"
96
+ /sf:new --research RES-001 "Add OAuth login"
96
97
  /sf:new # Interactive mode
97
98
  ```
98
99
  ```
99
100
 
101
+ **For `/sf:research`:**
102
+ ```
103
+ ## Examples
104
+
105
+ ```
106
+ /sf:research "OAuth vs JWT for authentication"
107
+ /sf:research "state management options for React"
108
+ /sf:research "database migration strategies"
109
+ ```
110
+ ```
111
+
100
112
  **For `/sf:audit`:**
101
113
  ```
102
114
  ## Examples
@@ -212,6 +224,13 @@ Workflow: Spec → Audit → Revise → Run → Review → Fix → Done
212
224
  | /sf:pause | Save session context for later |
213
225
  | /sf:resume | Restore previous session context |
214
226
 
227
+ ## Research & Analysis
228
+
229
+ | Command | Description |
230
+ |--------------|-----------------------------------------|
231
+ | /sf:research | Research topic for spec context |
232
+ | /sf:scan | Deep codebase analysis |
233
+
215
234
  ## Utilities
216
235
 
217
236
  | Command | Description |
@@ -225,11 +244,12 @@ Workflow: Spec → Audit → Revise → Run → Review → Fix → Done
225
244
  ## Quick Start
226
245
 
227
246
  1. `/sf:init` — Initialize project (once)
228
- 2. `/sf:new "task"` — Create specification
229
- 3. `/sf:audit` — Audit the spec
230
- 4. `/sf:run` — Implement
231
- 5. `/sf:review` — Review implementation
232
- 6. `/sf:done` — Complete and archive
247
+ 2. `/sf:research "topic"` — Research before spec (optional)
248
+ 3. `/sf:new "task"` — Create specification
249
+ 4. `/sf:audit` — Audit the spec
250
+ 5. `/sf:run` — Implement
251
+ 6. `/sf:review` — Review implementation
252
+ 7. `/sf:done` — Complete and archive
233
253
 
234
254
  ## Typical Session
235
255
 
@@ -80,7 +80,7 @@ ls tsconfig.json 2>/dev/null
80
80
  ## Step 5: Create .specflow Directory
81
81
 
82
82
  ```bash
83
- mkdir -p .specflow/specs .specflow/audits .specflow/archive .specflow/todos
83
+ mkdir -p .specflow/specs .specflow/audits .specflow/archive .specflow/todos .specflow/research
84
84
  ```
85
85
 
86
86
  ## Step 6: Generate PROJECT.md
@@ -190,11 +190,15 @@ Create `.specflow/config.json`:
190
190
  | `.specflow/PROJECT.md` | Project overview |
191
191
  | `.specflow/STATE.md` | Current state |
192
192
  | `.specflow/config.json` | Configuration |
193
+ | `.specflow/research/` | Research documents |
193
194
 
194
195
  ## Next Step
195
196
 
196
197
  `/sf:new "your task description"` — create first specification
197
198
 
199
+ Or research first:
200
+ `/sf:research "topic"` — research before creating spec
201
+
198
202
  ---
199
203
 
200
204
  **Tip:** Review `.specflow/PROJECT.md` and fill in:
@@ -210,6 +214,7 @@ Create `.specflow/config.json`:
210
214
  - [ ] .specflow/specs/ subdirectory created
211
215
  - [ ] .specflow/audits/ subdirectory created
212
216
  - [ ] .specflow/archive/ subdirectory created
217
+ - [ ] .specflow/research/ subdirectory created
213
218
  - [ ] PROJECT.md created with detected stack
214
219
  - [ ] STATE.md created with initial state
215
220
  - [ ] config.json created with defaults
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  name: sf:new
3
3
  description: Create a new specification from task description
4
+ argument-hint: "[--research RES-XXX] <task description>"
4
5
  allowed-tools:
5
6
  - Read
6
7
  - Write
@@ -40,7 +41,16 @@ Exit.
40
41
 
41
42
  ## Step 2: Parse Arguments
42
43
 
43
- Extract task description from command arguments.
44
+ Extract from command arguments:
45
+ - `--research RES-XXX` — optional research document to include as context
46
+ - Task description — what to build
47
+
48
+ **If --research provided:**
49
+ ```bash
50
+ [ -f .specflow/research/RES-XXX.md ] && echo "FOUND" || echo "NOT_FOUND"
51
+ ```
52
+
53
+ If NOT_FOUND, warn user and continue without research context.
44
54
 
45
55
  **If no description provided:**
46
56
  Use AskUserQuestion:
@@ -66,7 +76,13 @@ Task(prompt="
66
76
  @.specflow/STATE.md
67
77
  </current_state>
68
78
 
79
+ {If --research provided:}
80
+ <research_context>
81
+ @.specflow/research/RES-XXX.md
82
+ </research_context>
83
+
69
84
  Create a specification following the spec-creator agent instructions.
85
+ {If research provided, add: "Use the research findings to inform the specification."}
70
86
  ", subagent_type="sf-spec-creator", description="Create specification")
71
87
  ```
72
88
 
@@ -0,0 +1,158 @@
1
+ ---
2
+ name: sf:research
3
+ description: Research a topic and save findings for future specification context
4
+ argument-hint: "[topic]"
5
+ ---
6
+
7
+ <purpose>
8
+ Research a topic, technology, or implementation approach. Saves structured findings to `.specflow/research/RES-XXX.md` for use as context when creating specifications.
9
+ </purpose>
10
+
11
+ <context>
12
+ @.specflow/PROJECT.md
13
+ @.specflow/STATE.md
14
+ @~/.claude/specflow-cc/templates/research.md
15
+ @~/.claude/specflow-cc/agents/researcher.md
16
+ </context>
17
+
18
+ <workflow>
19
+
20
+ ## 1. Verify Initialization
21
+
22
+ ```bash
23
+ [ -d .specflow ] && echo "OK" || echo "NOT_INITIALIZED"
24
+ ```
25
+
26
+ **If NOT_INITIALIZED:**
27
+ ```
28
+ SpecFlow not initialized.
29
+
30
+ Run `/sf:init` first.
31
+ ```
32
+ Exit.
33
+
34
+ ## 2. Ensure Research Directory
35
+
36
+ ```bash
37
+ mkdir -p .specflow/research
38
+ ```
39
+
40
+ ## 3. Parse Arguments
41
+
42
+ Extract research topic from command arguments.
43
+
44
+ **If no topic provided:**
45
+ Use AskUserQuestion:
46
+ - header: "Topic"
47
+ - question: "What do you want to research?"
48
+ - options: (freeform text input)
49
+
50
+ ## 4. Spawn Researcher Agent
51
+
52
+ Launch the researcher subagent:
53
+
54
+ ```
55
+ Task(prompt="
56
+ <research_topic>
57
+ {user's topic}
58
+ </research_topic>
59
+
60
+ <project_context>
61
+ @.specflow/PROJECT.md
62
+ </project_context>
63
+
64
+ Research this topic and create a structured findings document.
65
+ ", subagent_type="sf-researcher", description="Research topic")
66
+ ```
67
+
68
+ ## 5. Handle Agent Response
69
+
70
+ The agent will:
71
+ 1. Research the topic (codebase exploration, web search if needed)
72
+ 2. Create RES-XXX.md with findings
73
+ 3. Return structured result with ID and summary
74
+
75
+ ## 6. Display Result
76
+
77
+ ```
78
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
79
+ RESEARCH COMPLETE
80
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
81
+
82
+ **ID:** RES-XXX
83
+ **Topic:** [topic]
84
+ **Created:** [date]
85
+
86
+ ### Summary
87
+
88
+ [Brief 2-3 sentence summary of findings]
89
+
90
+ ### Key Findings
91
+
92
+ - [Finding 1]
93
+ - [Finding 2]
94
+ - [Finding 3]
95
+
96
+ ---
97
+
98
+ 📄 **File:** `.specflow/research/RES-XXX.md`
99
+
100
+ ---
101
+
102
+ ## Use in Specification
103
+
104
+ To use this research when creating a specification:
105
+
106
+ ```
107
+ /sf:new --research RES-XXX "your task description"
108
+ ```
109
+
110
+ Or reference directly:
111
+ ```
112
+ /sf:new "implement OAuth (see RES-XXX)"
113
+ ```
114
+ ```
115
+
116
+ </workflow>
117
+
118
+ <fallback>
119
+
120
+ **If agent spawning fails**, execute inline:
121
+
122
+ ## Inline Research
123
+
124
+ ### Get Next Research Number
125
+
126
+ ```bash
127
+ LAST=$(ls .specflow/research/RES-*.md 2>/dev/null | sort -V | tail -1 | grep -oP 'RES-\K\d+')
128
+ NEXT=$(printf "%03d" $((${LAST:-0} + 1)))
129
+ echo "RES-$NEXT"
130
+ ```
131
+
132
+ ### Research Topic
133
+
134
+ 1. Search codebase for related code
135
+ 2. Check existing patterns
136
+ 3. Use WebSearch for external context if needed
137
+ 4. Identify options, trade-offs, and recommendations
138
+
139
+ ### Write Research Document
140
+
141
+ Create `.specflow/research/RES-XXX.md` with:
142
+ - Frontmatter (id, topic, created)
143
+ - Summary
144
+ - Background (why this matters)
145
+ - Options explored
146
+ - Trade-offs analysis
147
+ - Codebase findings
148
+ - Recommendations
149
+ - References
150
+
151
+ </fallback>
152
+
153
+ <success_criteria>
154
+ - [ ] SpecFlow initialization verified
155
+ - [ ] Research topic obtained
156
+ - [ ] RES-XXX.md created with structured findings
157
+ - [ ] User knows how to use research in /sf:new
158
+ </success_criteria>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "specflow-cc",
3
- "version": "1.3.1",
3
+ "version": "1.4.0",
4
4
  "description": "Spec-driven development system for Claude Code — quality-first workflow with explicit audit cycles",
5
5
  "bin": {
6
6
  "specflow-cc": "bin/install.js"
@@ -0,0 +1,75 @@
1
+ ---
2
+ id: RES-XXX
3
+ topic: [short topic name]
4
+ created: YYYY-MM-DD
5
+ status: complete
6
+ ---
7
+
8
+ # Research: [Topic Title]
9
+
10
+ ## Summary
11
+
12
+ [2-3 sentence summary of findings and the recommended approach]
13
+
14
+ ## Background
15
+
16
+ [Why this research was needed. What problem or decision prompted it.]
17
+
18
+ ## Options Explored
19
+
20
+ ### Option 1: [Name]
21
+
22
+ **Description:** [What this approach involves]
23
+
24
+ **Pros:**
25
+ - [Pro 1]
26
+ - [Pro 2]
27
+
28
+ **Cons:**
29
+ - [Con 1]
30
+ - [Con 2]
31
+
32
+ ### Option 2: [Name]
33
+
34
+ **Description:** [What this approach involves]
35
+
36
+ **Pros:**
37
+ - [Pro 1]
38
+ - [Pro 2]
39
+
40
+ **Cons:**
41
+ - [Con 1]
42
+ - [Con 2]
43
+
44
+ ## Codebase Findings
45
+
46
+ [What was discovered in the existing codebase]
47
+
48
+ - `path/to/relevant/file.ts` — [description of relevance]
49
+ - `path/to/pattern/example.ts` — [description of relevance]
50
+
51
+ ## Trade-offs Analysis
52
+
53
+ | Aspect | Option 1 | Option 2 |
54
+ |--------|----------|----------|
55
+ | Complexity | | |
56
+ | Flexibility | | |
57
+ | Maintenance | | |
58
+ | Performance | | |
59
+
60
+ ## Recommendations
61
+
62
+ **Recommended approach:** [Option name]
63
+
64
+ **Reasoning:**
65
+ - [Reason 1 — why this fits the project]
66
+ - [Reason 2 — why this is better than alternatives]
67
+
68
+ **Implementation notes:**
69
+ - [Practical note for spec creation]
70
+ - [Technical consideration]
71
+
72
+ ## References
73
+
74
+ - [Documentation link or internal file reference]
75
+ - [Another reference]