specdacular 0.8.0 → 0.9.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.
- package/README.md +166 -54
- package/commands/specd/continue.md +22 -14
- package/commands/specd/toolbox.md +58 -14
- package/package.json +1 -1
- package/specdacular/HELP.md +70 -9
- package/specdacular/STATE-MACHINE.md +376 -0
- package/specdacular/pipeline.json +76 -0
- package/specdacular/references/brain-routing.md +168 -0
- package/specdacular/references/commit-code.md +9 -6
- package/specdacular/references/commit-docs.md +9 -6
- package/specdacular/references/execute-hooks.md +127 -0
- package/specdacular/references/load-context.md +10 -9
- package/specdacular/references/resolve-pipeline.md +74 -0
- package/specdacular/references/select-feature.md +12 -5
- package/specdacular/references/validate-task.md +19 -11
- package/specdacular/templates/context/review-diff.md +60 -0
- package/specdacular/templates/context/section-display.md +51 -0
- package/specdacular/workflows/brain.md +378 -0
- package/specdacular/workflows/context-add.md +242 -0
- package/specdacular/workflows/context-manual-review.md +410 -0
- package/specdacular/workflows/continue.md +17 -259
- package/specdacular/workflows/execute.md +15 -42
- package/specdacular/workflows/map-codebase.md +14 -0
- package/specdacular/workflows/new.md +2 -2
- package/specdacular/workflows/phase-plan.md +142 -0
- package/specdacular/workflows/plan.md +10 -37
- package/specdacular/workflows/research.md +25 -7
- package/specdacular/workflows/review.md +11 -136
- package/specdacular/workflows/revise.md +126 -0
- package/specdacular/workflows/status.md +1 -1
|
@@ -0,0 +1,378 @@
|
|
|
1
|
+
<purpose>
|
|
2
|
+
Config-driven orchestrator that replaces continue.md's hardcoded flow control. Reads pipeline.json, determines the next step based on task state, handles modes (default/interactive/auto), dispatches step workflows, executes hooks, and manages state transitions.
|
|
3
|
+
|
|
4
|
+
The brain is the single source of truth for workflow orchestration. Step workflows just do their job and return — the brain decides what comes next.
|
|
5
|
+
|
|
6
|
+
**Modes:**
|
|
7
|
+
- **Default:** Auto-runs steps, pauses where `pause: true`. Smart about skipping unnecessary steps.
|
|
8
|
+
- **Interactive (`--interactive`):** Prompts at each stage transition with skip/jump options
|
|
9
|
+
- **Auto (`--auto`):** Runs everything, only stops on errors or task completion
|
|
10
|
+
</purpose>
|
|
11
|
+
|
|
12
|
+
<philosophy>
|
|
13
|
+
|
|
14
|
+
## One Orchestrator
|
|
15
|
+
|
|
16
|
+
All flow control lives here. Step workflows are pure execution — they do their work and return. They never dispatch the next step.
|
|
17
|
+
|
|
18
|
+
## Config-Driven
|
|
19
|
+
|
|
20
|
+
The pipeline comes from pipeline.json, not hardcoded logic. Users can swap steps, add hooks, or replace the entire pipeline.
|
|
21
|
+
|
|
22
|
+
## State Machine
|
|
23
|
+
|
|
24
|
+
The brain reads state → determines position → dispatches → updates state → loops. Every state transition is explicit and persisted before dispatch.
|
|
25
|
+
|
|
26
|
+
## Hooks Are Workflow Steps
|
|
27
|
+
|
|
28
|
+
Hooks are markdown files executed like any other workflow step. They can read and modify task files. No special output contract.
|
|
29
|
+
|
|
30
|
+
</philosophy>
|
|
31
|
+
|
|
32
|
+
<process>
|
|
33
|
+
|
|
34
|
+
<step name="parse_args">
|
|
35
|
+
Parse arguments to extract task name and mode.
|
|
36
|
+
|
|
37
|
+
**Parse $ARGUMENTS:**
|
|
38
|
+
- Extract task name (first argument, or only argument without --)
|
|
39
|
+
- Check for `--interactive` flag
|
|
40
|
+
- Check for `--auto` flag
|
|
41
|
+
- If `--interactive` → interactive mode
|
|
42
|
+
- If `--auto` → auto mode
|
|
43
|
+
- Otherwise → default mode
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
Mode: {default | interactive | auto}
|
|
47
|
+
Task: {task-name}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Continue to validate.
|
|
51
|
+
</step>
|
|
52
|
+
|
|
53
|
+
<step name="validate">
|
|
54
|
+
@~/.claude/specdacular/references/validate-task.md
|
|
55
|
+
|
|
56
|
+
Use basic validation with $TASK_NAME.
|
|
57
|
+
|
|
58
|
+
Continue to resolve_pipeline.
|
|
59
|
+
</step>
|
|
60
|
+
|
|
61
|
+
<step name="resolve_pipeline">
|
|
62
|
+
@~/.claude/specdacular/references/resolve-pipeline.md
|
|
63
|
+
|
|
64
|
+
Load and validate the pipeline configuration.
|
|
65
|
+
|
|
66
|
+
After loading, apply mode:
|
|
67
|
+
- If `--interactive` flag was set, use interactive mode
|
|
68
|
+
- If `--auto` flag was set, use auto mode
|
|
69
|
+
- Otherwise use default mode (auto-run, pause at `pause: true` steps)
|
|
70
|
+
|
|
71
|
+
**Check for orchestrator mode:**
|
|
72
|
+
Read `.specd/config.json` (project-level, not task-level). If it has `"type": "orchestrator"`:
|
|
73
|
+
- Set `$ORCHESTRATOR_MODE = true`
|
|
74
|
+
- Log: `Orchestrator mode: multi-project task management active.`
|
|
75
|
+
|
|
76
|
+
**How orchestrator mode works with the brain:**
|
|
77
|
+
|
|
78
|
+
The brain runs the same pipeline for orchestrator tasks. The difference is that step workflows detect orchestrator mode internally and hand off to specialized orchestrator workflows:
|
|
79
|
+
- `new.md` → detects orchestrator → delegates to `orchestrator/new.md` (multi-project task creation)
|
|
80
|
+
- `plan.md` → detects orchestrator → delegates to `orchestrator/plan.md` (cross-project phasing)
|
|
81
|
+
- `discuss.md`, `research.md` → work at orchestrator level (system-wide discussion/research)
|
|
82
|
+
- `execute.md` → for orchestrator tasks, reads DEPENDENCIES.md to determine cross-project phase order. Executes phases per-project respecting dependency graph.
|
|
83
|
+
- `review.md`, `revise.md` → work per-project within the orchestrator's coordination
|
|
84
|
+
|
|
85
|
+
The brain does NOT need different routing for orchestrator mode. The pipeline is the same — orchestrator awareness lives in the step workflows that need it. The brain's job is to drive the pipeline; the steps handle multi-project specifics.
|
|
86
|
+
|
|
87
|
+
**Important:** When in orchestrator mode, the phase-execution loop may need to coordinate across projects. The brain reads the orchestrator task's DEPENDENCIES.md to understand cross-project phase ordering, and dispatches execute/review/revise per project in dependency order.
|
|
88
|
+
|
|
89
|
+
Continue to main_loop.
|
|
90
|
+
</step>
|
|
91
|
+
|
|
92
|
+
<step name="main_loop">
|
|
93
|
+
The core orchestration loop. Repeats until task is complete or user stops.
|
|
94
|
+
|
|
95
|
+
**On each iteration:**
|
|
96
|
+
|
|
97
|
+
1. **Load current state:**
|
|
98
|
+
Read config.json, STATE.md, CONTEXT.md from task directory.
|
|
99
|
+
|
|
100
|
+
2. **Determine next step:**
|
|
101
|
+
@~/.claude/specdacular/references/brain-routing.md
|
|
102
|
+
|
|
103
|
+
This sets: `$NEXT_STEP`, `$NEXT_PIPELINE`, and optionally `$TASK_COMPLETE` or `$RESUME`.
|
|
104
|
+
|
|
105
|
+
3. **If task complete:**
|
|
106
|
+
Continue to complete.
|
|
107
|
+
|
|
108
|
+
4. **Find step config in pipeline:**
|
|
109
|
+
Look up `$NEXT_STEP` in `$PIPELINE.pipelines.$NEXT_PIPELINE`.
|
|
110
|
+
|
|
111
|
+
5. **Prompt or proceed:**
|
|
112
|
+
Continue to prompt_or_proceed.
|
|
113
|
+
|
|
114
|
+
6. **After step dispatch returns:**
|
|
115
|
+
Continue to update_state.
|
|
116
|
+
|
|
117
|
+
7. **After state update:**
|
|
118
|
+
Loop back to step 1 (re-read state, determine next step).
|
|
119
|
+
|
|
120
|
+
Continue to prompt_or_proceed.
|
|
121
|
+
</step>
|
|
122
|
+
|
|
123
|
+
<step name="prompt_or_proceed">
|
|
124
|
+
Mode-based dispatch decision.
|
|
125
|
+
|
|
126
|
+
**Default mode:**
|
|
127
|
+
Check the step's `pause` field:
|
|
128
|
+
- If `false` or absent: auto-proceed (no prompt). But first, evaluate if the step adds value — if not, skip it (see smart skipping below).
|
|
129
|
+
- If `true`: prompt user before proceeding
|
|
130
|
+
|
|
131
|
+
When pausing, present current state and ask what to do:
|
|
132
|
+
|
|
133
|
+
```
|
|
134
|
+
**Current state:** {stage description}
|
|
135
|
+
{Additional context based on step — e.g., phase number}
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Use AskUserQuestion with step-appropriate options:
|
|
139
|
+
|
|
140
|
+
For plan step (phase-execution pipeline — phase-plan.md):
|
|
141
|
+
- Auto-proceed (no pause). Plan has no pause field.
|
|
142
|
+
|
|
143
|
+
For execute step:
|
|
144
|
+
- "Execute" (Recommended) — Start/resume phase execution
|
|
145
|
+
- "Review plan" — Read the PLAN.md first
|
|
146
|
+
- "Stop for now" — Come back later
|
|
147
|
+
|
|
148
|
+
For review step:
|
|
149
|
+
- Dispatch directly (review has its own user interaction)
|
|
150
|
+
|
|
151
|
+
For revise step:
|
|
152
|
+
- Dispatch directly (revise has its own user interaction)
|
|
153
|
+
|
|
154
|
+
**Interactive mode (`--interactive`):**
|
|
155
|
+
Prompt at every stage transition, regardless of `pause` field.
|
|
156
|
+
|
|
157
|
+
Use AskUserQuestion with step-appropriate options:
|
|
158
|
+
|
|
159
|
+
For discuss step:
|
|
160
|
+
- "Discuss" (Recommended) — Dive into gray areas
|
|
161
|
+
- "Skip to research" — Move on without resolving
|
|
162
|
+
- "Skip to planning" — Jump straight to planning
|
|
163
|
+
|
|
164
|
+
For research step:
|
|
165
|
+
- "Research" (Recommended) — Investigate implementation patterns
|
|
166
|
+
- "Skip to planning" — Plan without research
|
|
167
|
+
- "Discuss more" — Continue discussion
|
|
168
|
+
|
|
169
|
+
For plan step (main pipeline — task-level):
|
|
170
|
+
- "Plan" (Recommended) — Create roadmap with phase goals
|
|
171
|
+
- "Research first" — Run research before planning
|
|
172
|
+
- "Discuss more" — Continue discussion
|
|
173
|
+
|
|
174
|
+
For plan step (phase-execution pipeline — phase-plan.md):
|
|
175
|
+
- "Plan this phase" (Recommended) — Create detailed PLAN.md
|
|
176
|
+
- "Skip to execute" — Execute without explicit planning
|
|
177
|
+
- "Stop for now" — Come back later
|
|
178
|
+
|
|
179
|
+
For execute step:
|
|
180
|
+
- "Execute" (Recommended) — Start/resume phase execution
|
|
181
|
+
- "Review plan" — Read the PLAN.md first
|
|
182
|
+
- "Stop for now" — Come back later
|
|
183
|
+
|
|
184
|
+
For review step:
|
|
185
|
+
- Dispatch directly (review has its own user interaction)
|
|
186
|
+
|
|
187
|
+
For revise step:
|
|
188
|
+
- Dispatch directly (revise has its own user interaction)
|
|
189
|
+
|
|
190
|
+
**Auto mode (`--auto`):**
|
|
191
|
+
Proceed without prompting. Apply smart skipping (see below). Only stop on errors or task completion.
|
|
192
|
+
|
|
193
|
+
**If user chooses "Stop for now":**
|
|
194
|
+
Save state and exit:
|
|
195
|
+
```
|
|
196
|
+
───────────────────────────────────────────────────────
|
|
197
|
+
|
|
198
|
+
Progress saved. Pick up where you left off anytime:
|
|
199
|
+
|
|
200
|
+
/specd:continue {task-name}
|
|
201
|
+
```
|
|
202
|
+
End workflow.
|
|
203
|
+
|
|
204
|
+
**If user chooses an alternative (e.g., "Skip to research"):**
|
|
205
|
+
Update `$NEXT_STEP` accordingly and continue to dispatch.
|
|
206
|
+
|
|
207
|
+
**Smart step skipping (default and auto modes):**
|
|
208
|
+
Before dispatching a step, evaluate whether it adds value. Skip if:
|
|
209
|
+
- **discuss:** No gray areas remaining in CONTEXT.md → skip, advance to research
|
|
210
|
+
- **research (task-level):** Task is straightforward (few files, clear requirements, no external dependencies) → skip, advance to plan
|
|
211
|
+
|
|
212
|
+
When skipping, log:
|
|
213
|
+
```
|
|
214
|
+
Skipping {step}: {reason}
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
In interactive mode, don't auto-skip — instead recommend skipping: mark the skip option as "(Recommended)" and the step as the alternative.
|
|
218
|
+
|
|
219
|
+
Continue to execute_hooks_and_step.
|
|
220
|
+
</step>
|
|
221
|
+
|
|
222
|
+
<step name="execute_hooks_and_step">
|
|
223
|
+
Execute pre-hooks, the step workflow, and post-hooks.
|
|
224
|
+
|
|
225
|
+
**Save state before dispatch:**
|
|
226
|
+
Update config.json to reflect the step is starting. For execute step, set `phases.current_status: "executing"` and record `phase_start_commit`.
|
|
227
|
+
|
|
228
|
+
Commit state:
|
|
229
|
+
@~/.claude/specdacular/references/commit-docs.md
|
|
230
|
+
- **$FILES:** config.json, STATE.md
|
|
231
|
+
- **$MESSAGE:** `docs({task-name}): starting {step-name}`
|
|
232
|
+
- **$LABEL:** `state transition`
|
|
233
|
+
|
|
234
|
+
**Execute pre-hooks:**
|
|
235
|
+
@~/.claude/specdacular/references/execute-hooks.md
|
|
236
|
+
|
|
237
|
+
Run pre-hooks in order:
|
|
238
|
+
1. Global `hooks.pre-step` from pipeline.json (if configured)
|
|
239
|
+
2. Step's `hooks.pre` from the step config (if configured)
|
|
240
|
+
3. Convention fallback: check `.specd/hooks/pre-{step-name}.md` (if file exists and no explicit config)
|
|
241
|
+
|
|
242
|
+
For each hook, use the execution logic from the reference.
|
|
243
|
+
|
|
244
|
+
If a required pre-hook fails, stop pipeline and save state. Do NOT dispatch the step.
|
|
245
|
+
|
|
246
|
+
**Dispatch step workflow:**
|
|
247
|
+
Resolve the workflow path from the step's `workflow` field.
|
|
248
|
+
Execute the workflow:
|
|
249
|
+
@~/.claude/specdacular/workflows/{workflow}
|
|
250
|
+
|
|
251
|
+
Pass $TASK_NAME as context.
|
|
252
|
+
|
|
253
|
+
**After step returns:**
|
|
254
|
+
|
|
255
|
+
**Execute post-hooks:**
|
|
256
|
+
@~/.claude/specdacular/references/execute-hooks.md
|
|
257
|
+
|
|
258
|
+
Run post-hooks in order:
|
|
259
|
+
1. Step's `hooks.post` from the step config (if configured)
|
|
260
|
+
2. Convention fallback: check `.specd/hooks/post-{step-name}.md` (if file exists and no explicit config)
|
|
261
|
+
3. Global `hooks.post-step` from pipeline.json (if configured)
|
|
262
|
+
|
|
263
|
+
For each hook, use the execution logic from the reference.
|
|
264
|
+
|
|
265
|
+
If a required post-hook fails, stop pipeline and save state.
|
|
266
|
+
|
|
267
|
+
Continue to update_state.
|
|
268
|
+
</step>
|
|
269
|
+
|
|
270
|
+
<step name="update_state">
|
|
271
|
+
Update state based on which step just completed.
|
|
272
|
+
|
|
273
|
+
**After discuss completes:**
|
|
274
|
+
- Stage stays at "discussion"
|
|
275
|
+
- Re-read CONTEXT.md to check if gray areas are resolved
|
|
276
|
+
- If all resolved, advance stage to "research"
|
|
277
|
+
|
|
278
|
+
**After research completes:**
|
|
279
|
+
- Set stage to "planning" in config.json
|
|
280
|
+
|
|
281
|
+
**After plan completes (task-level — main pipeline):**
|
|
282
|
+
- plan.md sets stage to "execution" and phases info in config.json
|
|
283
|
+
- Brain loops back, routing picks up phase-execution pipeline
|
|
284
|
+
|
|
285
|
+
**After plan completes (phase-level — phase-execution pipeline, phase-plan.md):**
|
|
286
|
+
- phase-plan.md creates PLAN.md but does NOT change config.json
|
|
287
|
+
- Status stays "pending" but PLAN.md now exists
|
|
288
|
+
- Brain loops back, routing sees pending + PLAN.md exists → routes to execute
|
|
289
|
+
|
|
290
|
+
**After execute completes:**
|
|
291
|
+
- Set `phases.current_status: "executed"` in config.json
|
|
292
|
+
|
|
293
|
+
**After review completes:**
|
|
294
|
+
- Read review outcome from config.json or STATE.md
|
|
295
|
+
- If user approved ("Looks good"): set `phases.current_status: "completed"`, increment `phases.completed`, advance to next phase or mark task complete
|
|
296
|
+
- If user wants revisions: set up for revise step
|
|
297
|
+
- If user stopped: save state, exit
|
|
298
|
+
|
|
299
|
+
**After revise completes:**
|
|
300
|
+
- Read config.json — revise should have set `phases.current_status: "pending"` (fix plan created, needs execution)
|
|
301
|
+
- Brain loops back to execute for the current phase (including decimal fix phases)
|
|
302
|
+
|
|
303
|
+
**Commit state updates:**
|
|
304
|
+
@~/.claude/specdacular/references/commit-docs.md
|
|
305
|
+
- **$FILES:** config.json, STATE.md
|
|
306
|
+
- **$MESSAGE:** `docs({task-name}): {step-name} complete`
|
|
307
|
+
- **$LABEL:** `state transition`
|
|
308
|
+
|
|
309
|
+
Return to main_loop.
|
|
310
|
+
</step>
|
|
311
|
+
|
|
312
|
+
<step name="phase_loop">
|
|
313
|
+
Handle the phase-execution sub-pipeline loop.
|
|
314
|
+
|
|
315
|
+
When the brain reaches the `phase-execution` pipeline reference in the main pipeline:
|
|
316
|
+
|
|
317
|
+
1. Read ROADMAP.md and config.json to determine current phase
|
|
318
|
+
2. Enter the phase-execution sub-pipeline (plan → execute → review → revise)
|
|
319
|
+
3. After each iteration through the sub-pipeline:
|
|
320
|
+
- If review approved and more phases remain: advance `phases.current`, set status "pending", loop
|
|
321
|
+
- If review approved and no more phases: exit sub-pipeline, task complete
|
|
322
|
+
- If revise created fix plans: stay on current phase, loop back to execute
|
|
323
|
+
- If user stopped: save state, exit
|
|
324
|
+
|
|
325
|
+
**Decimal phase handling:**
|
|
326
|
+
After revise creates a fix plan (e.g., phase-01.1/):
|
|
327
|
+
```bash
|
|
328
|
+
ls -d $TASK_DIR/phases/phase-$(printf '%02d' $CURRENT).* 2>/dev/null | sort -V
|
|
329
|
+
```
|
|
330
|
+
If decimal phases exist and are incomplete, execute them before advancing to next integer phase.
|
|
331
|
+
|
|
332
|
+
**Phase advancement:**
|
|
333
|
+
```
|
|
334
|
+
phases.current += 1
|
|
335
|
+
phases.current_status = "pending"
|
|
336
|
+
phases.phase_start_commit = null
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
Continue to main_loop (which will route to the next phase's execute step).
|
|
340
|
+
</step>
|
|
341
|
+
|
|
342
|
+
<step name="complete">
|
|
343
|
+
All phases complete. Task is done.
|
|
344
|
+
|
|
345
|
+
**Update state:**
|
|
346
|
+
- Set stage to "complete" in config.json
|
|
347
|
+
|
|
348
|
+
**Present:**
|
|
349
|
+
```
|
|
350
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
351
|
+
TASK COMPLETE
|
|
352
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
353
|
+
|
|
354
|
+
**Task:** {task-name}
|
|
355
|
+
**Phases completed:** {N}
|
|
356
|
+
**Decisions made:** {N}
|
|
357
|
+
|
|
358
|
+
All phases executed and reviewed. Task is done!
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
End workflow.
|
|
362
|
+
</step>
|
|
363
|
+
|
|
364
|
+
</process>
|
|
365
|
+
|
|
366
|
+
<success_criteria>
|
|
367
|
+
- Pipeline loaded from .specd/pipeline.json or installed default
|
|
368
|
+
- Pipeline validated (schema version, references, workflow paths)
|
|
369
|
+
- State-based routing matches all 8 state combinations
|
|
370
|
+
- Default mode auto-runs, pauses at `pause: true` steps, smart-skips unnecessary steps
|
|
371
|
+
- Interactive mode prompts at each transition with skip/jump options
|
|
372
|
+
- Auto mode proceeds without prompting, smart-skips, stops on errors
|
|
373
|
+
- Phase-execution sub-pipeline loops correctly per phase
|
|
374
|
+
- Decimal fix phases handled
|
|
375
|
+
- State saved before dispatch for reliable resume
|
|
376
|
+
- Stop/resume works at any point via /specd:continue
|
|
377
|
+
- Hook execution points marked for Phase 2
|
|
378
|
+
</success_criteria>
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
<purpose>
|
|
2
|
+
Guide the user to add new content to a codebase context file (.specd/codebase/*.md). Identifies the correct file and section, checks for duplicates, confirms placement, and writes the content with a USER_MODIFIED tag.
|
|
3
|
+
|
|
4
|
+
Output: Updated context file with new content added to the correct section.
|
|
5
|
+
</purpose>
|
|
6
|
+
|
|
7
|
+
<philosophy>
|
|
8
|
+
|
|
9
|
+
## Guide, Don't Assume
|
|
10
|
+
|
|
11
|
+
The agent suggests where content should go, but the user confirms before anything is written. Never auto-place content.
|
|
12
|
+
|
|
13
|
+
## Check for Duplicates
|
|
14
|
+
|
|
15
|
+
Before adding, search existing context files for similar content. Avoid creating duplicate documentation.
|
|
16
|
+
|
|
17
|
+
## Minimal Touch
|
|
18
|
+
|
|
19
|
+
Add the content where it belongs. Don't reorganize surrounding sections or rewrite adjacent content.
|
|
20
|
+
|
|
21
|
+
</philosophy>
|
|
22
|
+
|
|
23
|
+
<critical_rules>
|
|
24
|
+
|
|
25
|
+
## Date Format
|
|
26
|
+
|
|
27
|
+
Always write dates as `YYYY-MM-DD`. Never write times. Never write month names.
|
|
28
|
+
|
|
29
|
+
## USER_MODIFIED Tag Format
|
|
30
|
+
|
|
31
|
+
Exact format: `<!-- USER_MODIFIED: YYYY-MM-DD -->`
|
|
32
|
+
|
|
33
|
+
Placement: On its own line immediately after the section heading. No blank line between heading and tag.
|
|
34
|
+
|
|
35
|
+
If the section already has a USER_MODIFIED tag, update the date. Never add a second tag.
|
|
36
|
+
|
|
37
|
+
## Timestamp Lines
|
|
38
|
+
|
|
39
|
+
After writing content, update the document-level `Last Modified:` timestamp. If it doesn't exist, add it after `Generated:` or `**Analysis Date:**`.
|
|
40
|
+
|
|
41
|
+
</critical_rules>
|
|
42
|
+
|
|
43
|
+
<process>
|
|
44
|
+
|
|
45
|
+
<step name="validate">
|
|
46
|
+
Check that codebase context files exist.
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
ls .specd/codebase/*.md 2>/dev/null
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
**If no files found:**
|
|
53
|
+
```
|
|
54
|
+
No codebase context files found.
|
|
55
|
+
|
|
56
|
+
Run /specd:map-codebase to generate codebase documentation.
|
|
57
|
+
```
|
|
58
|
+
End workflow.
|
|
59
|
+
|
|
60
|
+
Continue to gather_input.
|
|
61
|
+
</step>
|
|
62
|
+
|
|
63
|
+
<step name="gather_input">
|
|
64
|
+
Ask what the user wants to add.
|
|
65
|
+
|
|
66
|
+
```
|
|
67
|
+
What do you want to add to the codebase context?
|
|
68
|
+
|
|
69
|
+
Describe the information — I'll figure out which file and section it belongs in.
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Wait for user response.
|
|
73
|
+
|
|
74
|
+
Continue to identify_target.
|
|
75
|
+
</step>
|
|
76
|
+
|
|
77
|
+
<step name="identify_target">
|
|
78
|
+
Determine where the content belongs.
|
|
79
|
+
|
|
80
|
+
**Step 1: Check for duplicates**
|
|
81
|
+
|
|
82
|
+
Search all context files for key terms from the user's description:
|
|
83
|
+
|
|
84
|
+
Use Grep to search `.specd/codebase/*.md` for the main keywords/concepts from the user's input.
|
|
85
|
+
|
|
86
|
+
**If similar content found:**
|
|
87
|
+
```
|
|
88
|
+
Similar content already exists:
|
|
89
|
+
|
|
90
|
+
**{file}** → {## Section}
|
|
91
|
+
{relevant excerpt, 2-3 lines}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Use AskUserQuestion:
|
|
95
|
+
- header: "Duplicate?"
|
|
96
|
+
- question: "Similar content exists. What would you like to do?"
|
|
97
|
+
- options:
|
|
98
|
+
- "Add anyway" — Add as new content in the best location
|
|
99
|
+
- "Update existing" — Modify the existing section instead
|
|
100
|
+
- "Cancel" — Don't add anything
|
|
101
|
+
|
|
102
|
+
If "Update existing": Switch to edit mode — show the existing section and ask what to change. Apply edit, add USER_MODIFIED tag. Continue to update_timestamps.
|
|
103
|
+
|
|
104
|
+
If "Cancel": End workflow.
|
|
105
|
+
|
|
106
|
+
**Step 2: Identify best file**
|
|
107
|
+
|
|
108
|
+
Based on the content type, determine the target file:
|
|
109
|
+
- **MAP.md** — Entry points, modules, functions, integrations, data flow
|
|
110
|
+
- **PATTERNS.md** — Code patterns, conventions, examples to follow
|
|
111
|
+
- **STRUCTURE.md** — Directory layout, where to put new files, naming conventions
|
|
112
|
+
- **CONCERNS.md** — Gotchas, anti-patterns, tech debt, fragile areas, warnings
|
|
113
|
+
|
|
114
|
+
**Step 3: Identify best section**
|
|
115
|
+
|
|
116
|
+
Read the target file. Determine which existing section the content fits under. If no existing section is appropriate, propose creating a new section.
|
|
117
|
+
|
|
118
|
+
Continue to confirm_placement.
|
|
119
|
+
</step>
|
|
120
|
+
|
|
121
|
+
<step name="confirm_placement">
|
|
122
|
+
Show the user where content will be placed and get confirmation.
|
|
123
|
+
|
|
124
|
+
```
|
|
125
|
+
I'll add this to:
|
|
126
|
+
|
|
127
|
+
**File:** {file}
|
|
128
|
+
**Section:** {## Section} → {### Subsection if applicable}
|
|
129
|
+
{If new section: "New section: ## {proposed title}"}
|
|
130
|
+
|
|
131
|
+
**Content to add:**
|
|
132
|
+
|
|
133
|
+
{formatted content that will be written}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
Use AskUserQuestion:
|
|
137
|
+
- header: "Placement"
|
|
138
|
+
- question: "Add content here?"
|
|
139
|
+
- options:
|
|
140
|
+
- "Confirm" — Add it here
|
|
141
|
+
- "Different section" — Show me other options
|
|
142
|
+
- "Cancel" — Don't add
|
|
143
|
+
|
|
144
|
+
**If "Different section":**
|
|
145
|
+
Show all sections across all 4 files as options:
|
|
146
|
+
|
|
147
|
+
```
|
|
148
|
+
Available sections:
|
|
149
|
+
|
|
150
|
+
MAP.md:
|
|
151
|
+
## Entry Points
|
|
152
|
+
## Core Modules
|
|
153
|
+
...
|
|
154
|
+
|
|
155
|
+
PATTERNS.md:
|
|
156
|
+
## Workflow/Command Pattern
|
|
157
|
+
...
|
|
158
|
+
|
|
159
|
+
STRUCTURE.md:
|
|
160
|
+
## Directory Layout
|
|
161
|
+
...
|
|
162
|
+
|
|
163
|
+
CONCERNS.md:
|
|
164
|
+
## Gotchas
|
|
165
|
+
## Anti-patterns
|
|
166
|
+
...
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
Use AskUserQuestion to let user pick from available sections, or type a custom section name.
|
|
170
|
+
|
|
171
|
+
**If "Cancel":** End workflow.
|
|
172
|
+
|
|
173
|
+
Continue to write_content.
|
|
174
|
+
</step>
|
|
175
|
+
|
|
176
|
+
<step name="write_content">
|
|
177
|
+
Insert content at the chosen location.
|
|
178
|
+
|
|
179
|
+
1. **If adding to existing section:**
|
|
180
|
+
- Append the new content at the end of the section (before the next heading)
|
|
181
|
+
- Add or update `<!-- USER_MODIFIED: {today} -->` after the section heading
|
|
182
|
+
|
|
183
|
+
2. **If creating new section:**
|
|
184
|
+
- Add the new `##` or `###` heading at an appropriate location in the file
|
|
185
|
+
- Add `<!-- USER_MODIFIED: {today} -->` on the line after the heading
|
|
186
|
+
- Add the content below
|
|
187
|
+
|
|
188
|
+
Use the Edit tool to make the changes.
|
|
189
|
+
|
|
190
|
+
Continue to update_timestamps.
|
|
191
|
+
</step>
|
|
192
|
+
|
|
193
|
+
<step name="update_timestamps">
|
|
194
|
+
Update the document-level timestamps.
|
|
195
|
+
|
|
196
|
+
1. Read the first 5 lines of the file
|
|
197
|
+
2. Set `Last Modified: {today}`
|
|
198
|
+
3. If the line doesn't exist, add it after `Generated:` or `**Analysis Date:**`
|
|
199
|
+
|
|
200
|
+
Continue to commit.
|
|
201
|
+
</step>
|
|
202
|
+
|
|
203
|
+
<step name="commit">
|
|
204
|
+
@~/.claude/specdacular/references/commit-docs.md
|
|
205
|
+
|
|
206
|
+
- **$FILES:** `.specd/codebase/{file}`
|
|
207
|
+
- **$MESSAGE:** `docs: add to {file} — {brief description of what was added}`
|
|
208
|
+
- **$LABEL:** `context addition`
|
|
209
|
+
|
|
210
|
+
Continue to completion.
|
|
211
|
+
</step>
|
|
212
|
+
|
|
213
|
+
<step name="completion">
|
|
214
|
+
Show what was added.
|
|
215
|
+
|
|
216
|
+
```
|
|
217
|
+
───────────────────────────────────────────────────────
|
|
218
|
+
Content added to: {file}
|
|
219
|
+
───────────────────────────────────────────────────────
|
|
220
|
+
|
|
221
|
+
**Section:** {section heading}
|
|
222
|
+
**Tagged:** USER_MODIFIED: {today}
|
|
223
|
+
**Last Modified:** updated to {today}
|
|
224
|
+
|
|
225
|
+
{Brief summary of what was added}
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
End workflow.
|
|
229
|
+
</step>
|
|
230
|
+
|
|
231
|
+
</process>
|
|
232
|
+
|
|
233
|
+
<success_criteria>
|
|
234
|
+
- User describes what to add
|
|
235
|
+
- Duplicate check performed across all context files
|
|
236
|
+
- Target file and section identified
|
|
237
|
+
- User confirms placement before writing
|
|
238
|
+
- Content written with USER_MODIFIED tag
|
|
239
|
+
- Last Modified timestamp updated
|
|
240
|
+
- Changes committed
|
|
241
|
+
- Summary shown
|
|
242
|
+
</success_criteria>
|