1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
|
---
description: Create an implementation spec for a feature or task
allowed-tools: Read, Write, Bash(git:*), AskUserQuestion, Task
---
# Create Implementation Spec
A hybrid approach using subagents: research in isolated context, interview in main context, write in isolated context.
## Step 1: Find Git Root
Run `git rev-parse --show-toplevel` to locate the repository root.
## Step 2: Check Config
Read `<git-root>/.bonfire/config.json` if it exists.
**Specs location**: Read `specsLocation` from config. Default to `.bonfire/specs/` if not set.
## Step 3: Gather Initial Context
Get the topic from $ARGUMENTS or ask if unclear.
Check for existing context:
- Read `<git-root>/.bonfire/index.md` for project state
- Check for `SPEC.md` or `spec.md` in git root (user's spec template)
- If issue ID provided, note for filename
## Step 4: Research Phase (Subagent)
Use the Task tool to invoke the **codebase-explorer** subagent for research.
Provide a research directive with these questions:
```
Research the codebase for implementing: [TOPIC]
Find:
1. **Patterns & Architecture**: How similar features are implemented, existing abstractions to reuse, naming conventions
2. **Technical Constraints**: Dependencies, API boundaries, performance considerations
3. **Potential Conflicts**: Files that need changes, intersections with existing code, migration concerns
Return structured findings only - no raw file contents.
```
**Wait for the subagent to return findings** before proceeding.
The subagent runs in isolated context (haiku model, fast), preserving main context for interview.
## Step 5: Interview Phase (Main Context)
Using the research findings, interview the user with **informed questions** via AskUserQuestion.
### Round 1: Core Decisions
Ask about fundamental approach based on patterns found:
Example questions (adapt based on actual findings):
- "I found [Pattern A] in `services/` and [Pattern B] in `handlers/`. Which pattern should this feature follow?"
- "The existing [Component] handles [X]. Should we extend it or create a new [Y]?"
- "I see [Library] is used for [purpose]. Should we use it here or try [Alternative]?"
### Round 2: Edge Cases & Tradeoffs
Based on Round 1 answers and research, ask about:
- Error handling approach
- Edge cases identified in research
- Performance vs simplicity tradeoffs
- User experience considerations
Example questions:
- "What should happen when [edge case from research]?"
- "I found [potential conflict]. How should we handle it?"
- "[Approach A] is simpler but [tradeoff]. [Approach B] is more complex but [benefit]. Preference?"
### Round 3: Scope & Boundaries (if needed)
If scope is still unclear:
- What's explicitly out of scope?
- MVP vs full implementation?
- Dependencies on other work?
### Continue Until Complete
Keep asking rounds of questions until you have clarity on:
- [ ] Core approach and architecture
- [ ] Key technical decisions
- [ ] Error handling strategy
- [ ] Edge cases covered
- [ ] Testing approach
- [ ] Scope boundaries
Tell the user "I have enough to write the spec" when ready.
## Step 6: Write the Spec (Subagent)
Use the Task tool to invoke the **spec-writer** subagent.
Provide:
1. **Research findings** from Step 4
2. **Interview Q&A** from Step 5
3. **Metadata**: topic, issue ID, output path (`<git-root>/<specsLocation>/<filename>.md`)
The subagent will write the spec file directly.
**Naming convention**: `<issue-id>-<topic>.md` or `<topic>.md`
## Step 7: Link to Session Context
Add a reference to the spec in `<git-root>/.bonfire/index.md` under Current State.
## Step 8: Confirm
Read the generated spec and present a summary. Ask if user wants to:
- Proceed with implementation
- Refine specific sections
- Add more detail to any area
- Save for later
## Interview Tips
**Good questions are:**
- Informed by research (not generic)
- About tradeoffs (not yes/no)
- Specific to the codebase
- Non-obvious (user wouldn't think to mention)
**Bad questions:**
- "What features do you want?" (too broad)
- "Should we add error handling?" (obvious)
- Generic without codebase context
**Examples of good informed questions:**
- "I found `UserService` uses repository pattern but `OrderService` uses direct DB access. Which approach?"
- "The `auth` middleware validates JWT but doesn't check permissions. Should this feature add permission checks or assume auth is enough?"
- "There's a `BaseController` with shared logic. Extend it or keep this feature standalone?"
## Spec Lifecycle
Specs are **temporary artifacts** - they exist to guide implementation:
1. **Draft** → Created, ready for review
2. **In Progress** → Being implemented
3. **Completed** → Implementation done
**When a spec is fully implemented**:
- If it contains reusable reference material, move to `docs/`
- Delete the spec file - archive has the record
- Don't let specs accumulate
|