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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
|
---
description: Start a new session - reads context and scaffolds .bonfire/ if needed
allowed-tools: Bash(git:*), Bash(gh:*), Bash(mkdir:*), Read, Write, Glob, AskUserQuestion, mcp__linear__*
model: haiku
---
# Start Session
## Step 1: Find Git Root
Run `git rev-parse --show-toplevel` to locate the repository root. All session files live at `<git-root>/.bonfire/`.
## Step 2: Check for Bonfire Directory
Check if `<git-root>/.bonfire/index.md` exists.
**If .bonfire/ does NOT exist**, scaffold it:
1. Tell the user: "No bonfire directory found. Let me set that up for you."
2. Use AskUserQuestion to ask setup questions (4 questions, one round):
1. "Where should specs be saved?" (Header: "Specs")
- .bonfire/specs/ (Recommended) - Keep with session context
- specs/ - Project root level
2. "Where should docs be saved?" (Header: "Docs")
- .bonfire/docs/ (Recommended) - Keep with session context
- docs/ - Project root level
3. "How should `.bonfire/` be handled in git?" (Header: "Git")
- ignore-all (Recommended) - Keep sessions private/local
- hybrid - Commit docs/specs, keep notes private
- commit-all - Share everything with team
4. "Enable Linear MCP integration?" (Header: "Linear")
- No (Recommended) - Skip Linear integration
- Yes - Fetch/create Linear issues (requires Linear MCP)
3. Create the directory structure based on user choices:
**Always create in .bonfire/**:
```
.bonfire/
├── index.md
├── config.json
├── archive/
├── scripts/
└── .gitignore
```
**If specsLocation is `.bonfire/specs/`**: create `.bonfire/specs/`
**If specsLocation is `specs/`**: create `<git-root>/specs/`
**If docsLocation is `.bonfire/docs/`**: create `.bonfire/docs/`
**If docsLocation is `docs/`**: create `<git-root>/docs/`
4. Detect project name from: package.json name → git remote → directory name
5. Create `config.json` with user's answers:
```json
{
"specsLocation": "<user-answer>",
"docsLocation": "<user-answer>",
"gitStrategy": "<user-answer>",
"linearEnabled": <true-or-false>
}
```
6. Create `index.md` with template:
```markdown
# Session Context: [PROJECT_NAME]
**Date**: [CURRENT_DATE]
**Status**: Active
**Branch**: main
---
## Current State
[Describe what you're working on]
---
## Recent Sessions
### Session 1 - [CURRENT_DATE]
**Goal**: [What you want to accomplish]
**Accomplished**:
- [List completed items]
**Decisions**:
- [Key decisions made]
**Blockers**: None
---
## Next Session Priorities
1. [Priority items]
---
## Key Resources
**Code References**:
- [Component/feature]: `path/to/file.ts`
**External Links**:
- [Issue Tracker](url)
---
## Archived Sessions
[Links to archived sessions will appear here]
---
## Notes
[Any additional context]
```
7. Create `.gitignore` based on chosen strategy and locations:
**Ignore all**:
```
*
!.gitignore
```
**Hybrid** (only include dirs that are inside .bonfire/):
```
*
!.gitignore
```
If docsLocation is `.bonfire/docs/`, add:
```
!docs/
!docs/**
```
If specsLocation is `.bonfire/specs/`, add:
```
!specs/
!specs/**
```
**Commit all**:
```
data/
scratch/
scripts/
```
**If .bonfire/ EXISTS**, proceed to Step 3.
## Step 3: Check/Update CLAUDE.md
Check if `<git-root>/CLAUDE.md` exists.
**If CLAUDE.md does NOT exist**, create it:
```markdown
# [PROJECT_NAME]
## Quick Context
Read `.bonfire/index.md` for current project state, recent work, and priorities.
## Bonfire Commands
- `/bonfire:start` - Start a session (reads context)
- `/bonfire:end` - End session (updates context)
- `/bonfire:spec` - Create implementation spec
- `/bonfire:document <topic>` - Document a topic
- `/bonfire:review` - Review work for blindspots and improvements
- `/bonfire:archive` - Archive completed work
- `/bonfire:configure` - Change project settings
```
**If CLAUDE.md EXISTS**, check if it references `.bonfire/index.md`. If not, append:
```markdown
## Session Context
Read `.bonfire/index.md` for current project state, recent work, and priorities.
```
## Step 4: Read Session Context
Read `<git-root>/.bonfire/index.md` and report when ready.
Summarize:
- Current state
- Recent work
- Next priorities
Then ask: "What do you want to work on this session?"
## Step 5: Fetch External Context (Optional)
**Only fetch if user provides a new URL or issue ID:**
### Detecting Issue Type
- **GitHub**: Starts with `#`, contains `github.com`, or doesn't match Linear pattern
- **Linear**: Matches `[A-Z]+-[0-9]+` pattern (e.g., `ENG-123`, `ABC-456`) or contains `linear.app`
### GitHub Issues/PRs
Use `gh` CLI:
- `gh pr view [URL] --json title,body,state,labels`
- `gh issue view [URL] --json title,body,state,labels`
### Linear Issues
First, read `<git-root>/.bonfire/config.json` and check `linearEnabled`.
**If `linearEnabled` is false or not set**: Skip Linear, treat as ad-hoc task.
**If `linearEnabled` is true**:
1. Use Linear MCP `linear_search_issues` tool to find the issue by ID (e.g., `ENG-123`)
2. Extract: title, description, state, priority, labels, assignee
3. On success: Summarize the issue context
4. On failure: Warn user - "Couldn't fetch Linear issue. Linear MCP may not be configured. Continue without issue context?"
Note: Tool names may vary by Linear MCP implementation. Common tools: `linear_search_issues`, `linear_create_issue`, `linear_update_issue`.
### Update Session Context
If issue was fetched successfully:
- Add reference to `index.md` under Current State
- Include issue ID, title, and link
- Note the issue tracker type (GitHub/Linear)
### Fallback
If no URL/issue ID provided (continuing work, ad-hoc task):
- Proceed with existing session context
- Session notes are the source of truth for ongoing work
Confirm understanding and ask how to proceed.
|