specrails-core 4.12.0 → 5.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.
Files changed (76) hide show
  1. package/README.md +49 -78
  2. package/bin/specrails-core.mjs +18 -98
  3. package/bin/tui-installer.mjs +22 -105
  4. package/commands/doctor.md +1 -1
  5. package/dist/installer/cli.js +12 -2
  6. package/dist/installer/cli.js.map +1 -1
  7. package/dist/installer/commands/doctor.js +3 -5
  8. package/dist/installer/commands/doctor.js.map +1 -1
  9. package/dist/installer/commands/init.js +23 -19
  10. package/dist/installer/commands/init.js.map +1 -1
  11. package/dist/installer/commands/update.js +17 -16
  12. package/dist/installer/commands/update.js.map +1 -1
  13. package/dist/installer/commands/v5-migration.js +119 -0
  14. package/dist/installer/commands/v5-migration.js.map +1 -0
  15. package/dist/installer/phases/install-config.js +3 -6
  16. package/dist/installer/phases/install-config.js.map +1 -1
  17. package/dist/installer/phases/manifest.js +2 -6
  18. package/dist/installer/phases/manifest.js.map +1 -1
  19. package/dist/installer/phases/prereqs.js +0 -1
  20. package/dist/installer/phases/prereqs.js.map +1 -1
  21. package/dist/installer/phases/scaffold.js +38 -148
  22. package/dist/installer/phases/scaffold.js.map +1 -1
  23. package/package.json +1 -1
  24. package/schemas/profile.v1.json +1 -1
  25. package/templates/agents/sr-architect.md +30 -0
  26. package/templates/agents/sr-developer.md +21 -8
  27. package/templates/agents/sr-reviewer.md +44 -31
  28. package/templates/codex-skills/batch-implement/SKILL.md +9 -32
  29. package/templates/codex-skills/implement/SKILL.md +61 -143
  30. package/templates/codex-skills/rails/sr-architect/SKILL.md +38 -20
  31. package/templates/codex-skills/rails/sr-developer/SKILL.md +29 -10
  32. package/templates/codex-skills/rails/sr-reviewer/SKILL.md +21 -10
  33. package/templates/commands/specrails/doctor.md +1 -1
  34. package/templates/commands/specrails/implement.md +117 -288
  35. package/templates/commands/specrails/memory-inspect.md +6 -4
  36. package/templates/commands/specrails/propose-spec.md +1 -1
  37. package/templates/commands/specrails/refactor-recommender.md +8 -51
  38. package/templates/commands/specrails/retry.md +12 -48
  39. package/templates/commands/specrails/telemetry.md +1 -1
  40. package/templates/gemini-commands/implement.toml +9 -0
  41. package/templates/profiles/default.json +5 -18
  42. package/commands/enrich.md +0 -1456
  43. package/templates/agents/sr-backend-developer.md +0 -91
  44. package/templates/agents/sr-backend-reviewer.md +0 -152
  45. package/templates/agents/sr-doc-sync.md +0 -247
  46. package/templates/agents/sr-frontend-developer.md +0 -85
  47. package/templates/agents/sr-frontend-reviewer.md +0 -145
  48. package/templates/agents/sr-merge-resolver.md +0 -195
  49. package/templates/agents/sr-performance-reviewer.md +0 -186
  50. package/templates/agents/sr-product-analyst.md +0 -36
  51. package/templates/agents/sr-product-manager.md +0 -148
  52. package/templates/agents/sr-security-reviewer.md +0 -191
  53. package/templates/agents/sr-test-writer.md +0 -176
  54. package/templates/codex-skills/enrich/SKILL.md +0 -191
  55. package/templates/codex-skills/merge-resolve/SKILL.md +0 -88
  56. package/templates/codex-skills/rails/sr-backend-developer/SKILL.md +0 -93
  57. package/templates/codex-skills/rails/sr-backend-reviewer/SKILL.md +0 -120
  58. package/templates/codex-skills/rails/sr-doc-sync/SKILL.md +0 -124
  59. package/templates/codex-skills/rails/sr-frontend-developer/SKILL.md +0 -106
  60. package/templates/codex-skills/rails/sr-frontend-reviewer/SKILL.md +0 -111
  61. package/templates/codex-skills/rails/sr-merge-resolver/SKILL.md +0 -156
  62. package/templates/codex-skills/rails/sr-performance-reviewer/SKILL.md +0 -109
  63. package/templates/codex-skills/rails/sr-product-analyst/SKILL.md +0 -85
  64. package/templates/codex-skills/rails/sr-product-manager/SKILL.md +0 -131
  65. package/templates/codex-skills/rails/sr-security-reviewer/SKILL.md +0 -121
  66. package/templates/codex-skills/rails/sr-test-writer/SKILL.md +0 -115
  67. package/templates/commands/specrails/auto-propose-backlog-specs.md +0 -312
  68. package/templates/commands/specrails/enrich.md +0 -1456
  69. package/templates/commands/specrails/get-backlog-specs.md +0 -226
  70. package/templates/commands/specrails/merge-resolve.md +0 -172
  71. package/templates/commands/specrails/reconfig.md +0 -80
  72. package/templates/commands/specrails/vpc-drift.md +0 -405
  73. package/templates/commands/test.md +0 -58
  74. package/templates/personas/persona.md +0 -43
  75. package/templates/personas/the-maintainer.md +0 -98
  76. package/templates/settings/perf-thresholds.yml +0 -25
@@ -1,1456 +0,0 @@
1
- # Enrich: Agent Workflow System
2
-
3
- Interactive wizard to configure the full agent workflow system for this repository. Analyzes the codebase, discovers target users, generates VPC personas, and creates all agents, commands, rules, and configuration adapted to this project. Supports config-driven mode for direct installation from a pre-built config file.
4
-
5
- **Prerequisites:** Ensure this repo was initialized with `npx specrails-core@latest init` (or via specrails-desktop) so `.specrails/setup-templates/` exists.
6
-
7
- ### Desktop App Checkpoint Protocol
8
-
9
- When running inside specrails-desktop, emit checkpoint markers at key transitions so the desktop app `CheckpointTracker` can display progress. Each checkpoint is a single line printed to stdout:
10
-
11
- ```
12
- [checkpoint:phase_1_analysis] Codebase analysis complete
13
- [checkpoint:phase_2_personas] VPC personas generated
14
- [checkpoint:phase_3_commands] Commands and rules generated
15
- [checkpoint:phase_4_agents] Agent files generated
16
- [checkpoint:phase_5_cleanup] Cleanup and summary complete
17
- ```
18
-
19
- The desktop app parses these via `detectCheckpointFromText()` regex patterns. Always emit checkpoints at the end of each phase, even in `--from-config` and `--quick` modes.
20
-
21
- ---
22
-
23
- ## Mode Detection
24
-
25
- Check `$ARGUMENTS` in this order:
26
-
27
- 1. If `--update` is present → execute **Update Mode** (below), then stop.
28
- 2. If `--from-config` is present → execute **From-Config Mode** (below), then stop.
29
- 3. If `--quick` or `--lite` is present → execute **Quick Mode** (below), then stop.
30
- 4. Otherwise (no flags) → skip directly to **Phase 1** and execute the full 5-phase wizard.
31
-
32
- **Default is the full wizard.** Quick Mode only runs when `--quick` or `--lite` is explicitly passed.
33
-
34
- ---
35
-
36
- ## From-Config Mode
37
-
38
- When `--from-config` is passed, execute a fully automated installation using `.specrails/install-config.yaml`. No interactive prompts — all decisions come from the config file.
39
-
40
- ### FC1: Read and Validate Config
41
-
42
- Read `.specrails/install-config.yaml`. If it does not exist, display:
43
- > "`.specrails/install-config.yaml` not found. Run the TUI installer first (`npx specrails-core@latest init`) or use `/specrails:enrich` without `--from-config` for the interactive wizard."
44
- Then stop.
45
-
46
- Parse the YAML and extract:
47
- - `config.version` — must be `1`; if not, warn and proceed
48
- - `config.provider` — `claude` (this is the Claude enrichment flow); default `claude`
49
- - `config.tier` — `full` or `quick`; default `full`
50
- - `config.agents.selected` — list of agent names to install
51
- - `config.agents.excluded` — list of agent names to skip (for reference only)
52
- - `config.models.preset` — `balanced`, `budget`, or `max` (see Model Presets below)
53
- - `config.models.defaults.model` — default model override (overrides preset)
54
- - `config.models.overrides` — per-agent model overrides (highest priority)
55
-
56
- Store all values in variables prefixed `FC_`.
57
-
58
- **Model Presets** (applied when `config.models.defaults` is not set):
59
- - `balanced` (default): sr-architect=opus, sr-product-manager=opus, all others=sonnet
60
- - `budget`: all agents=haiku
61
- - `max`: all agents=opus
62
-
63
- To resolve the model for any given agent:
64
- 1. Check `config.models.overrides.<agent-name>` — if present, use it
65
- 2. Check `config.models.defaults.model` — if present, use it
66
- 3. Apply preset defaults based on `config.models.preset`
67
- 4. Fallback to model in template frontmatter
68
-
69
- ### FC2: Provider Setup
70
-
71
- This is the Claude enrichment flow. Set `SPECRAILS_DIR = ".claude"`.
72
-
73
- ### FC3: If tier is `quick` — run Quick Mode with config context
74
-
75
- If `FC_tier == "quick"`:
76
- - Set `FC_AGENTS_SELECTED` as the list of agents to generate (instead of defaults)
77
- - Execute Quick Mode (QS1–QS4), generating all `FC_AGENTS_SELECTED` agents (not just defaults)
78
- - Then stop.
79
-
80
- ### FC4: If tier is `full` — run automated full wizard
81
-
82
- **Phase 1 (Silent):** Run the full Phase 1 analysis (1.1–1.4) without any user prompts. Store all detected values internally.
83
-
84
- **Phase 2 (AI-Inferred VPC Discovery):** Run VPC persona generation from codebase analysis:
85
- - Analyze the codebase (README, package.json, source code, configs) to infer what the product does and who it serves
86
- - Generate `PROJECT_DESCRIPTION` (2–3 sentence summary) and `TARGET_USERS` from analysis
87
- - Use these inferred values to generate full VPC personas (3 primary, 3 secondary)
88
- - Do not ask the user any questions — infer everything from codebase analysis
89
-
90
- **Phase 3 (Silent):** Run Phase 3 normally without user prompts.
91
-
92
- **Phase 4 (Config-Driven Agent Generation):**
93
- - Generate only agents in `FC_AGENTS_SELECTED` (skip any not in the list)
94
- - Apply model resolution (FC1 preset/override logic) to each agent's frontmatter
95
- - Run all Phase 4 sub-phases (4.1, 4.2, 4.3, 4.4) normally but without interactive prompts
96
-
97
- **Phase 5 (Normal):** Run Phase 5 cleanup normally.
98
-
99
- ### FC5: Completion
100
-
101
- Display:
102
- ```
103
- ✅ Enrich complete (from-config).
104
-
105
- Agents generated: <count> of <total selected>
106
- Models applied:
107
- sr-architect: <resolved-model>
108
- sr-developer: <resolved-model>
109
- [... one line per generated agent ...]
110
-
111
- Next steps:
112
- > /specrails:implement <feature>
113
- ```
114
-
115
- ---
116
-
117
- ## Update Mode
118
-
119
- When `--update` is passed, execute this streamlined flow instead of the full wizard. Do not run any phases from the full wizard. When Phase U7 is complete, stop.
120
-
121
- ### Phase U1: Read Update Context
122
-
123
- Read the following files to understand the current installation state:
124
-
125
- 1. Read `.specrails/specrails-manifest.json` — contains agent template checksums from the last install/update. Structure:
126
- ```json
127
- {
128
- "version": "0.2.0",
129
- "installed_at": "2025-01-15T10:00:00Z",
130
- "artifacts": {
131
- "templates/agents/architect.md": "sha256:<checksum>",
132
- "templates/agents/developer.md": "sha256:<checksum>",
133
- "templates/agents/reviewer.md": "sha256:<checksum>"
134
- }
135
- }
136
- ```
137
- If this file does not exist, inform the user:
138
- > "No `.specrails/specrails-manifest.json` found. This repo predates the Node-native installer. Re-run `npx specrails-core@latest init` to refresh the install, then re-run `/specrails:enrich --update`."
139
- Then stop.
140
-
141
- 2. Read `.specrails/specrails-version` — contains the current version string (e.g., `0.2.0`). If it does not exist, treat version as `0.1.0 (legacy)`.
142
-
143
- 3. This is the **Claude** enrichment flow: it operates on `.claude/` (`specrails_dir = ".claude"`). Codex projects use their own codex-native `$enrich` skill, not this command.
144
-
145
- 4. List all template files in `.specrails/setup-templates/agents/` — these are the NEW agent templates from the update:
146
- ```bash
147
- ls .specrails/setup-templates/agents/
148
- ```
149
- Template files are named with `sr-` prefix (e.g., `sr-architect.md`, `sr-developer.md`).
150
-
151
- 5. List all template files in `.specrails/setup-templates/commands/specrails/` — these are the NEW command templates from the update:
152
- ```bash
153
- ls .specrails/setup-templates/commands/specrails/
154
- ```
155
- Command template files include `implement.md`, `batch-implement.md`, `compat-check.md`, `refactor-recommender.md`, `why.md`, `get-backlog-specs.md`, `auto-propose-backlog-specs.md`.
156
- If this directory does not exist, skip command template checking for this update.
157
-
158
- 6. Read `.specrails/backlog-config.json` if it exists — contains stored provider configuration needed for command placeholder substitution.
159
-
160
- 7. Read `.specrails/agents.yaml` if it exists — contains agent model configuration. Validate all `model:` values (only `opus`, `sonnet`, `haiku` are valid). Store as `AGENTS_CONFIG` for use in Phase U4. If the file does not exist, set `AGENTS_CONFIG = null`.
161
-
162
- ### Phase U2: Quick Codebase Re-Analysis
163
-
164
- Perform the same analysis as Phase 1 of the full setup wizard, but silently — do not prompt the user and do not show the findings table. Just execute and store results internally.
165
-
166
- Detect:
167
- - **Languages**: Check for `*.py`, `*.ts`, `*.tsx`, `*.go`, `*.rs`, `*.java`, `*.kt`, `*.rb`, `*.cs`
168
- - **Frameworks**: Search for imports (`fastapi`, `express`, `react`, `vue`, `angular`, `django`, `spring`, `gin`, `actix`, `rails`)
169
- - **Directory structure**: Identify backend/frontend/core/test directories
170
- - **Database**: Check for SQL files, ORM configs, migration directories
171
- - **CI/CD**: Parse `.github/workflows/*.yml` for lint/test/build commands
172
- - **Naming conventions**: Read 2-3 source files per detected layer
173
-
174
- Read:
175
- - `README.md` (if exists)
176
- - `package.json` / `pyproject.toml` / `Cargo.toml` / `go.mod` / `pom.xml` (detect stack)
177
- - `.github/workflows/*.yml` (detect CI commands)
178
-
179
- Store all results for use in Phases U4 and U5.
180
-
181
- ### Phase U3: Identify What Needs Regeneration
182
-
183
- **Agent templates:** For each agent template, find its entry in the manifest's `artifacts` map (keyed as `templates/agents/sr-<name>.md`). Compute the SHA-256 checksum of the corresponding file in `.specrails/setup-templates/agents/`:
184
-
185
- ```bash
186
- sha256sum .specrails/setup-templates/agents/sr-<name>.md
187
- ```
188
-
189
- Build three lists for agents:
190
-
191
- 1. **Changed agents**: agent name exists in manifest AND the current template checksum differs from the manifest checksum → mark for regeneration
192
- 2. **New agents**: template file exists in `.specrails/setup-templates/agents/` but the agent name is NOT in the manifest → mark for evaluation
193
- 3. **Unchanged agents**: agent name exists in manifest AND checksum matches → skip
194
-
195
- **Command templates:** If `.specrails/setup-templates/commands/specrails/` exists, for each command template file, find its entry in the manifest's `artifacts` map (keyed as `templates/commands/specrails/<name>.md`). Compute the SHA-256 checksum of the corresponding file in `.specrails/setup-templates/commands/specrails/`:
196
-
197
- ```bash
198
- sha256sum .specrails/setup-templates/commands/specrails/<name>.md
199
- ```
200
-
201
- Build three lists for commands:
202
-
203
- 1. **Changed commands**: command name exists in manifest AND the current template checksum differs from the manifest checksum → mark for update
204
- 2. **New commands**: template file exists in `.specrails/setup-templates/commands/specrails/` but the command name is NOT in the manifest → mark for evaluation
205
- 3. **Unchanged commands**: command name exists in manifest AND checksum matches → skip
206
-
207
- Display the combined analysis to the user:
208
-
209
- ```
210
- ## Update Analysis
211
-
212
- ### Agents — Changed Templates (will be regenerated)
213
- - sr-architect.md (template modified)
214
- - sr-developer.md (template modified)
215
-
216
- ### Agents — New Templates Available
217
- - sr-frontend-developer.md
218
- - sr-backend-developer.md
219
-
220
- ### Agents — Unchanged (keeping current)
221
- - sr-reviewer.md
222
- - sr-product-manager.md
223
-
224
- ### Commands — Changed Templates (will be updated)
225
- - implement.md (template modified)
226
-
227
- ### Commands — New Templates Available
228
- - refactor-recommender.md
229
-
230
- ### Commands — Unchanged (keeping current)
231
- - compat-check.md
232
- - why.md
233
- ```
234
-
235
- If there are no changed agents, no new agents, no changed commands, and no new commands, display:
236
- ```
237
- All agents and commands are already up to date. Nothing to regenerate.
238
- ```
239
- Then jump to Phase U7.
240
-
241
- ### Phase U4: Regenerate Changed Agents
242
-
243
- For each agent in the "changed" list:
244
-
245
- 1. Read the NEW template from `.specrails/setup-templates/agents/sr-<name>.md`
246
- 2. Use the codebase analysis from Phase U2 to fill in all `{{PLACEHOLDER}}` values, using the same substitution rules as Phase 4.1 of the full setup:
247
- - `{{PROJECT_NAME}}` → project name (from README.md or directory name)
248
- - `{{ARCHITECTURE_DIAGRAM}}` → detected architecture layers
249
- - `{{LAYER_TAGS}}` → detected layer tags (e.g., `[backend]`, `[frontend]`, `[api]`)
250
- - `{{CI_COMMANDS_BACKEND}}` → backend CI commands
251
- - `{{CI_COMMANDS_FRONTEND}}` → frontend CI commands
252
- - `{{LAYER_CONVENTIONS}}` → detected conventions per layer
253
- - `{{PERSONA_NAMES}}` → read existing persona names from `$SPECRAILS_DIR/agents/personas/` filenames
254
- - `{{PERSONA_FILES}}` → paths to existing persona files in `$SPECRAILS_DIR/agents/personas/`
255
- - `{{DOMAIN_EXPERTISE}}` → infer from detected stack and README
256
- - `{{KEY_FILE_PATHS}}` → important file paths detected in Phase U2
257
- - `{{WARNINGS}}` → read from existing `CLAUDE.md` if present
258
- - `{{MEMORY_PATH}}` → `$SPECRAILS_DIR/agent-memory/sr-<agent-name>/`
259
- 3. Resolve the agent's model using `AGENTS_CONFIG` (loaded in Phase U1, step 7):
260
- - Check `AGENTS_CONFIG.agents.<agent-name>.model` (per-agent override)
261
- - If not present, check `AGENTS_CONFIG.defaults.model` (global default)
262
- - If `AGENTS_CONFIG` is null, use the model from the template frontmatter
263
- - Replace the `model:` field in the YAML frontmatter with the resolved value before writing
264
- 4. Write the adapted agent (same rules as Phase 4.1):
265
- - Write to `.claude/agents/sr-<name>.md` (Markdown with YAML frontmatter)
266
- 5. Show: `✓ Regenerated sr-<name>`
267
-
268
- After regenerating all changed agents, verify no unresolved placeholders remain:
269
- ```bash
270
- grep -r '{{[A-Z_]*}}' .claude/agents/sr-*.md 2>/dev/null || echo "OK: no broken placeholders"
271
- ```
272
-
273
- ### Phase U4b: Update Changed Commands
274
-
275
- For each command in the "changed commands" list from Phase U3:
276
-
277
- 1. Read the NEW template from `.specrails/setup-templates/commands/specrails/<name>.md`
278
- 2. Read stored backlog configuration from `.specrails/backlog-config.json` (if it exists) to resolve provider-specific placeholders:
279
- - `BACKLOG_PROVIDER` → `provider` field (`github`, `jira`, or `none`)
280
- - `BACKLOG_WRITE` → `write_access` field
281
- - `JIRA_BASE_URL` → `jira_base_url` field
282
- - `JIRA_PROJECT_KEY` → `jira_project_key` field
283
- 3. Substitute all `{{PLACEHOLDER}}` values using the same rules as Phase 4.3 of the full setup:
284
- - `{{CI_COMMANDS_BACKEND}}` → backend CI commands detected in Phase U2
285
- - `{{CI_COMMANDS_FRONTEND}}` → frontend CI commands detected in Phase U2
286
- - `{{DEPENDENCY_CHECK_COMMANDS}}` → stack-specific dependency check commands from Phase U2
287
- - `{{TEST_RUNNER_CHECK}}` → test runner commands from Phase U2
288
- - `{{BACKLOG_FETCH_CMD}}` → provider-specific fetch command from backlog config
289
- - `{{BACKLOG_CREATE_CMD}}` → provider-specific create command from backlog config
290
- - `{{BACKLOG_VIEW_CMD}}` → provider-specific view command from backlog config
291
- - `{{BACKLOG_PREFLIGHT}}` → provider-specific preflight check from backlog config
292
- - Any other `{{PLACEHOLDER}}` values → use Phase U2 analysis data
293
- 4. Write the updated file to `.claude/commands/specrails/<name>.md`
294
- 5. Show: `✓ Updated /specrails:<name>`
295
-
296
- After updating all changed commands, verify no unresolved placeholders remain:
297
- ```bash
298
- grep -l '{{[A-Z_]*}}' .claude/commands/specrails/*.md 2>/dev/null || echo "OK: no broken placeholders"
299
- ```
300
- If any placeholders remain unresolved, warn the user:
301
- > "⚠ Some placeholders in `<filename>` could not be resolved automatically. Please review the file and fill them in manually."
302
-
303
- ### Phase U5: Evaluate New Agents
304
-
305
- For each agent in the "new" list:
306
-
307
- 1. Read the template from `.specrails/setup-templates/agents/sr-<name>.md` to understand what stack or layer it targets (read its description and any layer-specific comments)
308
- 2. Match against the codebase detected in Phase U2:
309
- - If the template targets a layer/stack that IS present (e.g., `sr-frontend-developer` and React was detected), prompt:
310
- > "New agent available: `sr-<name>` — your project uses [detected tech]. Add it? [Y/n]"
311
- - If the template targets a layer/stack that is NOT present (e.g., `sr-backend-developer` and no backend was detected), prompt:
312
- > "New agent available: `sr-<name>` — no [layer] detected in your project. Skip? [Y/n]"
313
- 3. If the user accepts (or presses Enter on a pre-selected default):
314
- - Generate the agent using the same template adaptation as Phase U4
315
- - Create memory directory if it does not exist: `$SPECRAILS_DIR/agent-memory/sr-<name>/`
316
- - Show: `✓ Added sr-<name>`
317
- 4. If the user declines:
318
- - Show: `→ Skipped sr-<name>`
319
-
320
- For each command in the "new commands" list from Phase U3:
321
-
322
- 1. Read the template from `.specrails/setup-templates/commands/specrails/<name>.md`
323
- 2. Prompt the user: `"New command available: /specrails:<name> — [one-line description]. Install it? [Y/n]"`
324
- 3. If the user accepts (or presses Enter):
325
- - Apply placeholder substitution using the same rules as Phase U4b (backlog config + codebase analysis)
326
- - Write to `.claude/commands/specrails/<name>.md` — show `✓ Added /specrails:<name>`
327
- 4. If the user declines:
328
- - Show `→ Skipped /specrails:<name>`
329
-
330
- ### Phase U6: Update Workflow Commands
331
-
332
- If any new agents were added in Phase U5:
333
-
334
- 1. Read the implement command at `.claude/commands/specrails/implement.md`
335
- 2. Check if the file references agent names in its orchestration steps (look for `sr-architect`, `sr-developer`, `sr-reviewer` etc.)
336
- 3. If newly added agents belong in the implementation pipeline (i.e., they are layer-specific developers such as `sr-frontend-developer` or `sr-backend-developer`), add them to the appropriate step in the implement command — specifically where parallel developer agents are launched
337
- 4. Write the updated file to `.claude/commands/specrails/implement.md` if any changes were made
338
- 5. Show which commands were updated, or "No command updates needed" if nothing changed
339
-
340
- This is a lightweight check — only update commands where the sr- agent clearly belongs. Do not restructure the entire command.
341
-
342
- ### Phase U7: Summary
343
-
344
- Display the final summary and stop. Do not continue to Phase 1 of the full setup wizard.
345
-
346
- ```
347
- ## Update Complete
348
-
349
- specrails updated from v<previous> to v<new>.
350
-
351
- | Action | Count |
352
- |---------------------|-------|
353
- | Agents regenerated | N |
354
- | Agents added | N |
355
- | Agents skipped | N |
356
- | Commands updated | N |
357
- | Commands added | N |
358
- | Commands skipped | N |
359
-
360
- All agents and commands are now up to date.
361
-
362
- ### Agents Regenerated
363
- [list agent names, or "(none)"]
364
-
365
- ### Agents Added
366
- [list agent names, or "(none)"]
367
-
368
- ### Agents Skipped
369
- [list agent names, or "(none)"]
370
-
371
- ### Commands Updated
372
- [list command names, or "(none)"]
373
-
374
- ### Commands Added
375
- [list command names, or "(none)"]
376
-
377
- ### Commands Skipped
378
- [list command names, or "(none)"]
379
- ```
380
-
381
- Update `.specrails/specrails-manifest.json` to reflect the new checksums for all regenerated/updated and added agents and commands:
382
- - For each regenerated agent: update its checksum entry to the new template's checksum (keyed as `templates/agents/sr-<name>.md`)
383
- - For each added agent: add a new entry with its checksum
384
- - For each updated command: update its checksum entry to the new template's checksum (keyed as `templates/commands/specrails/<name>.md`)
385
- - For each added command: add a new entry with its checksum
386
- - Update the `version` field to the version read from `.specrails/specrails-version`
387
-
388
- ---
389
-
390
- ## Quick Mode
391
-
392
- When `--quick` or `--lite` is passed, run this streamlined 3-question setup. Do NOT run Phase 1–5. When QS4 is complete, stop.
393
-
394
- ### QS1: Infer context and ask git access
395
-
396
- **Step 1 — AI inference (silent):** Analyze the codebase to infer:
397
- - `QS_PROJECT_DESCRIPTION` — a 2–3 sentence summary of what this project does (from README, package.json, source code, configs)
398
- - `QS_TARGET_USERS` — who the target users are (from docs, UI copy, API design, domain language)
399
-
400
- **Step 2 — Ask one question:**
401
-
402
- Display the following prompt EXACTLY ONCE:
403
-
404
- Welcome to specrails! Let's get your AI agent team set up.
405
-
406
- I've analyzed your codebase:
407
- - **Project:** {QS_PROJECT_DESCRIPTION}
408
- - **Target users:** {QS_TARGET_USERS}
409
-
410
- 1. Git access for agents — read-only or read-write?
411
- (read-only = agents can read and suggest; read-write = agents can commit)
412
-
413
- Store the answer as:
414
- - `QS_GIT_ACCESS` — "read-only" or "read-write" (normalize if user types "ro", "rw", "readonly", etc.)
415
-
416
- ### QS2: Apply opinionated defaults
417
-
418
- Use these defaults for all configuration not asked in QS1:
419
-
420
- | Setting | Quick Mode Default |
421
- |---------|------------------|
422
- | Agents enabled | sr-architect, sr-developer, sr-reviewer, sr-product-manager |
423
- | Git mode | Derived from QS_GIT_ACCESS |
424
- | CLAUDE.md template | `templates/CLAUDE-quickstart.md` |
425
- | OpenSpec enabled | Yes if `openspec` CLI is detected in PATH, No otherwise |
426
- | Telemetry | Not configured (deferred to PRD-002) |
427
- | Backlog provider | local (lightweight JSON-based, no external tools needed) |
428
-
429
- Detect whether this is an existing codebase or new project:
430
- - **Existing codebase**: `package.json`, `Gemfile`, `pyproject.toml`, `go.mod`, or `pom.xml` found in the repo root
431
- - **New project**: none of the above found
432
-
433
- Store as `QS_IS_EXISTING_CODEBASE=true/false`.
434
-
435
- ### QS2.5: Re-run Detection
436
-
437
- Before generating files, check if this is a re-run:
438
-
439
- 1. Check if commands already exist — check if `.claude/commands/specrails/` directory exists with any `.md` files:
440
- ```bash
441
- ls .claude/commands/specrails/*.md 2>/dev/null
442
- ```
443
- 2. If files are found → this is a **re-run**. Store `QS_IS_RERUN=true`.
444
- 3. If the directory does not exist or is empty → this is a **fresh install**. Store `QS_IS_RERUN=false`.
445
-
446
- In re-run mode, QS3 executes in **gap-fill mode** for command files:
447
- - For each command in the list, check if it already exists at `.claude/commands/specrails/<name>.md`
448
- - If it exists: skip it and show `✓ Already installed: /specrails:<name>`
449
- - If it does NOT exist: install it and show `✓ Added /specrails:<name> (was missing)`
450
- - Do NOT prompt the user for confirmation on missing files — install them automatically
451
-
452
- For CLAUDE.md/AGENTS.md and agent files, the existing per-file prompts already handle re-runs (user is asked before overwriting). No change needed there.
453
-
454
- ### QS3: Generate files
455
-
456
- Generate files using the Quick Mode defaults.
457
-
458
- **1. CLAUDE.md**
459
-
460
- Read `.specrails/setup-templates/claude-md/CLAUDE-quickstart.md` (or fall back to `.specrails/setup-templates/claude-md/default.md` if quickstart template is not found).
461
-
462
- Replace placeholders:
463
- - `{{PROJECT_NAME}}` → derive from directory name or README.md first heading
464
- - `{{GIT_ACCESS}}` → `QS_GIT_ACCESS`
465
-
466
- Write to `CLAUDE.md` in the repo root. If `CLAUDE.md` already exists, ask:
467
- > "CLAUDE.md already exists. Overwrite? [Y/n]"
468
- Skip if user says no.
469
-
470
- **2. Agent files**
471
-
472
- For each default agent (sr-architect, sr-developer, sr-reviewer, sr-product-manager), read the template from `.specrails/setup-templates/agents/<name>.md` and generate the adapted agent file using the rules from Phase 4.1:
473
- - Write to `.claude/agents/<name>.md` (Markdown with frontmatter)
474
-
475
- If `.specrails/agents.yaml` exists, read it and apply model resolution (per-agent override → defaults → template value) before writing each agent file.
476
-
477
- Fill placeholders with best-effort values from the limited context available:
478
- - `{{PROJECT_NAME}}` → directory name or README first heading
479
- - `{{GIT_ACCESS}}` → `QS_GIT_ACCESS`
480
- - `{{ARCHITECTURE_DIAGRAM}}` → "(Quick Mode — run `/specrails:enrich` for full architecture analysis)"
481
- - `{{TECH_EXPERTISE}}` → "(Quick Mode — run `/specrails:enrich` for codebase-specific expertise)"
482
- - `{{LAYER_TAGS}}` → detect from package.json / Gemfile / go.mod if present; otherwise leave empty
483
- - All other placeholders → "(not configured — run `/specrails:enrich`)"
484
-
485
- Create memory directories: `$SPECRAILS_DIR/agent-memory/sr-<name>/`
486
-
487
- **3. Command files**
488
-
489
- Core commands (always install if missing):
490
- - `implement.md`
491
- - `batch-implement.md`
492
- - `propose-spec.md`
493
- - `compat-check.md`
494
- - `why.md`
495
- - `get-backlog-specs.md`
496
- - `auto-propose-backlog-specs.md`
497
-
498
- **Initialize local ticket storage** (backlog provider defaults to `local`):
499
- 1. Copy `templates/local-tickets-schema.json` to `.specrails/local-tickets.json` and set `last_updated` to the current ISO-8601 timestamp. Skip if the file already exists.
500
- 2. Write `.specrails/backlog-config.json` (skip if already exists):
501
- ```json
502
- {
503
- "provider": "local",
504
- "write_access": true,
505
- "git_auto": true
506
- }
507
- ```
508
-
509
- If `QS_IS_RERUN=false` (fresh install): for each core command, read the template from `.specrails/setup-templates/commands/specrails/<name>.md`, substitute the backlog placeholders with local values (using the same table as Phase 4.3 "Local Tickets"), stub all persona placeholders with `(Quick Mode — run /specrails:enrich to configure personas)`, then write to `.claude/commands/specrails/<name>.md`.
510
-
511
- If `QS_IS_RERUN=true` (gap-fill mode): for each command in the list above, check if `.claude/commands/specrails/<name>.md` already exists:
512
- - If it exists: skip it — show `✓ Already installed: /specrails:<name>`
513
- - If it does NOT exist: read template, substitute placeholders as above, write to `.claude/commands/specrails/<name>.md` — show `✓ Added /specrails:<name> (was missing)`
514
-
515
- **4. Cleanup**
516
-
517
- Remove `.specrails/setup-templates/` (same as full wizard cleanup in Phase 5).
518
-
519
- Remove `commands/enrich.md` from `.claude/commands/` if it was copied there by the installer.
520
-
521
- ### QS4: First Task Prompt
522
-
523
- After generating all files, display the setup complete message.
524
-
525
- Then, based on `QS_IS_EXISTING_CODEBASE`:
526
- - **Existing codebase** (`true`): recommend `/specrails:refactor-recommender`
527
- - **New project** (`false`): recommend `/specrails:get-backlog-specs`
528
-
529
- If `QS_IS_RERUN=false`, display:
530
- ```
531
- ✅ Setup complete.
532
-
533
- Try your first command:
534
- > /specrails:get-backlog-specs
535
- ```
536
- (Replace `/specrails:get-backlog-specs` with `/specrails:refactor-recommender` for existing codebases.)
537
-
538
- If `QS_IS_RERUN=true`, display the gap-fill summary and stop:
539
- ```
540
- ✅ Re-run complete.
541
-
542
- Commands status:
543
- ✓ Already installed: /specrails:<name>
544
- ✓ Added /specrails:<name> (was missing)
545
- [... one line per command ...]
546
-
547
- All commands are up to date.
548
- ```
549
- If all commands were already present, display:
550
- ```
551
- ✅ Re-run complete. All commands already installed — nothing to add.
552
- ```
553
-
554
- Then stop. Do not execute Phase 1.
555
-
556
- ---
557
-
558
- ## Phase 1: Codebase Analysis
559
-
560
- Analyze the repository to understand its architecture, stack, and conventions.
561
-
562
- ### 1.1 Read project structure
563
-
564
- ```bash
565
- # Get the repo root and basic info
566
- git rev-parse --show-toplevel
567
- ls -la
568
- ```
569
-
570
- Read the following to understand the project:
571
- - `README.md` (if exists)
572
- - `CLAUDE.md` (if exists — don't overwrite, merge later)
573
- - `package.json` or `pyproject.toml` or `Cargo.toml` or `go.mod` or `pom.xml` (detect stack)
574
- - `.github/workflows/*.yml` (detect CI commands)
575
- - `docker-compose.yml` or `Dockerfile` (detect infra)
576
-
577
- ### 1.2 Detect architecture layers
578
-
579
- Use Glob and Grep to identify:
580
-
581
- 1. **Languages**: Check for `*.py`, `*.ts`, `*.tsx`, `*.go`, `*.rs`, `*.java`, `*.kt`, `*.rb`, `*.cs`
582
- 2. **Frameworks**: Search for imports (`fastapi`, `express`, `react`, `vue`, `angular`, `django`, `spring`, `gin`, `actix`, `rails`)
583
- 3. **Directory structure**: Identify backend/frontend/core/test directories
584
- 4. **Database**: Check for SQL files, ORM configs, migration directories
585
- 5. **CI/CD**: Parse workflow files for lint/test/build commands
586
-
587
- ### 1.3 Infer conventions
588
-
589
- Read 3-5 representative source files from each detected layer to understand:
590
- - Naming conventions (camelCase, snake_case, PascalCase)
591
- - Import patterns
592
- - Error handling patterns
593
- - Testing patterns (framework, structure, mocking approach)
594
- - API patterns (REST, GraphQL, tRPC)
595
-
596
- ### 1.4 Present findings
597
-
598
- Display the detected architecture to the user:
599
-
600
- ```
601
- ## Codebase Analysis
602
-
603
- | Layer | Tech | Path |
604
- |-------------|---------------------|---------------|
605
- | Backend | FastAPI (Python) | backend/ |
606
- | Frontend | React + TypeScript | frontend/ |
607
- | Core | Python package | src/ |
608
- | Tests | pytest | tests/ |
609
- | Database | PostgreSQL | migrations/ |
610
-
611
- ### CI Commands Detected
612
- - Lint: `ruff check .`
613
- - Format: `ruff format --check .`
614
- - Test: `pytest tests/ -q`
615
- - Frontend lint: `npm run lint`
616
- - Frontend build: `npx tsc --noEmit`
617
-
618
- ### Conventions Detected
619
- - Python: snake_case, type hints, Pydantic models
620
- - TypeScript: strict mode, functional components
621
- - Testing: pytest fixtures with scope="function"
622
-
623
- ### OSS Project Detection
624
-
625
- Read `.specrails/setup-templates/.oss-detection.json` if it exists.
626
-
627
- | Signal | Status |
628
- |--------|--------|
629
- | Public repository | [Yes / No / Unknown] |
630
- | CI workflows (.github/workflows/) | [Yes / No] |
631
- | CONTRIBUTING.md | [Yes / No] |
632
- | **Result** | **OSS detected / Not detected / Could not check** |
633
-
634
- If `is_oss: false` but at least one signal is `true`:
635
- > "Some OSS signals were found but not all three. Is this an open-source project? (yes/no)"
636
-
637
- If `.oss-detection.json` does not exist:
638
- > "Is this an open-source project? (yes/no)"
639
-
640
- When `IS_OSS=false` and no signals are present, skip OSS output entirely to avoid cluttering the display for non-OSS projects.
641
-
642
- Store the final OSS determination as `IS_OSS` for use throughout the rest of setup.
643
-
644
- [Confirm] [Modify] [Rescan]
645
- ```
646
-
647
- Wait for user confirmation. If they want to modify, ask what to change.
648
-
649
- ---
650
-
651
- ## Phase 2: User Personas & Product Discovery
652
-
653
- ### 2.1 Ask about target users
654
-
655
- Ask the user:
656
-
657
- > If IS_OSS=true, prepend:
658
- > "This is an OSS project. The **Maintainer** persona (Kai) is automatically included —
659
- > you do not need to add 'open-source maintainers' to your list.
660
- > Describe your other target user types below."
661
-
662
- > **Who are the target users of your software?**
663
- >
664
- > Describe them in natural language. Examples:
665
- > - "Developers who manage Kubernetes clusters"
666
- > - "Small business owners tracking inventory and sales"
667
- > - "Gamers who collect and trade digital items"
668
- >
669
- > I'll research the competitive landscape and create detailed personas
670
- > with Value Proposition Canvas profiles for each user type.
671
- >
672
- > **How many distinct user types do you have?** (typically 2-3)
673
-
674
- Wait for the user's response.
675
-
676
- ### 2.2 Research competitive landscape
677
-
678
- For each user type described, use WebSearch to research:
679
-
680
- 1. **Existing tools** they use today (competitors)
681
- 2. **Common pain points** reported in forums, Reddit, product reviews
682
- 3. **Feature gaps** in current tools
683
- 4. **Unmet needs** and workflow frustrations
684
-
685
- Search queries to use (adapt to the domain):
686
- - `"[domain] [user type] best tools 2025"`
687
- - `"[domain] [user type] pain points frustrations"`
688
- - `"[competitor name] missing features complaints"`
689
- - `"[domain] management app feature comparison"`
690
- - `site:reddit.com "[domain] [user type] what tool do you use"`
691
-
692
- ### 2.3 Generate VPC personas
693
-
694
- For each user type, generate a full Value Proposition Canvas persona file following the template at `.specrails/setup-templates/personas/persona.md`.
695
-
696
- Each persona must include:
697
- - **Profile**: Demographics, behaviors, tools used, spending patterns
698
- - **Customer Jobs**: Functional, social, emotional (6-8 jobs)
699
- - **Pains**: Graded by severity (Critical > High > Medium > Low) with 6-8 entries
700
- - **Gains**: Graded by impact (High > Medium > Low) with 6-8 entries
701
- - **Key Insight**: The #1 unmet need that this project can address
702
- - **Sources**: Links to competitive analysis, forums, reviews used in research
703
-
704
- ### 2.4 Present personas
705
-
706
- Display each generated persona to the user:
707
-
708
- ```
709
- ## Generated Personas
710
-
711
- ### Persona 1: "[Nickname]" — The [Role]
712
- - Age: X-Y
713
- - Key pain: [Critical pain]
714
- - Key insight: [Main unmet need]
715
-
716
- ### Persona 2: "[Nickname]" — The [Role]
717
- - Age: X-Y
718
- - Key pain: [Critical pain]
719
- - Key insight: [Main unmet need]
720
-
721
- [Accept] [Edit] [Regenerate]
722
- ```
723
-
724
- Wait for confirmation. If the user wants edits, apply them.
725
-
726
- ### 2.5 Initialize agent config
727
-
728
- Check for `.specrails/agents.yaml`:
729
-
730
- 1. If the file **exists**:
731
- - Read it
732
- - Validate all `model:` values — only `opus`, `sonnet`, and `haiku` are valid
733
- - If any value is invalid, warn the user and fall back to the template default for that agent
734
- - Store as `AGENTS_CONFIG` for use in Phase 4
735
-
736
- 2. If the file **does not exist**:
737
- - Generate it with the default model assignments matching the template hard-coded values:
738
-
739
- ```yaml
740
- # specrails agent configuration
741
- # Modify model assignments and other agent settings
742
- # Valid models: opus, sonnet, haiku
743
-
744
- defaults:
745
- model: sonnet
746
-
747
- agents:
748
- sr-architect:
749
- model: sonnet
750
- sr-developer:
751
- model: sonnet
752
- sr-reviewer:
753
- model: sonnet
754
- sr-product-manager:
755
- model: opus
756
- sr-product-analyst:
757
- model: haiku
758
- sr-test-writer:
759
- model: sonnet
760
- sr-security-reviewer:
761
- model: sonnet
762
- sr-backend-developer:
763
- model: sonnet
764
- sr-frontend-developer:
765
- model: sonnet
766
- sr-backend-reviewer:
767
- model: sonnet
768
- sr-frontend-reviewer:
769
- model: sonnet
770
- sr-doc-sync:
771
- model: sonnet
772
- sr-merge-resolver:
773
- model: sonnet
774
- sr-performance-reviewer:
775
- model: sonnet
776
- ```
777
-
778
- - Write this file to `.specrails/agents.yaml`
779
- - Store as `AGENTS_CONFIG` for use in Phase 4
780
- - Log: "Generated `.specrails/agents.yaml` with default model assignments"
781
-
782
- ---
783
-
784
- ## Phase 3: Configuration
785
-
786
- ### 3.1 Agents to install
787
-
788
- Present the available agents and let the user choose:
789
-
790
- ```
791
- ## Agent Selection
792
-
793
- Which agents do you want to install?
794
-
795
- | Agent | Purpose | Model | Required |
796
- |-------|---------|-------|----------|
797
- | sr-architect | Design features, create implementation plans | Sonnet | Yes |
798
- | sr-developer (full-stack) | Implement features across all layers | Sonnet | Yes |
799
- | sr-reviewer | CI/CD quality gate, fix issues | Sonnet | Yes |
800
- | sr-test-writer | Generate unit, integration, and edge-case tests after implementation | Sonnet | Yes |
801
- | sr-security-reviewer | Scan for secrets, OWASP vulnerabilities, hardcoded credentials | Sonnet | Yes |
802
- | sr-product-manager | Product discovery, ideation, VPC evaluation | Opus | Recommended |
803
- | sr-product-analyst | Read-only backlog analysis | Haiku | Recommended |
804
- | sr-backend-developer | Specialized backend implementation | Sonnet | If backend layer exists |
805
- | sr-frontend-developer | Specialized frontend implementation | Sonnet | If frontend layer exists |
806
-
807
- [All] [Required only] [Custom selection]
808
- ```
809
-
810
- ### 3.2 Backlog provider
811
-
812
- Ask the user how they want to manage their product backlog. Default is local — no external tools or accounts required:
813
-
814
- ```
815
- ## Backlog Provider
816
-
817
- Use local ticket management or connect an external provider?
818
-
819
- 1. **Local tickets** (default, recommended) — lightweight JSON-based ticket management built into the project.
820
- No external tools or accounts required. Tickets stored in `.specrails/local-tickets.json`, version-controlled and diffable.
821
- 2. **External provider** — connect GitHub Issues, JIRA, or disable backlog commands
822
- ```
823
-
824
- If the user selects **1** or presses Enter without typing anything: set `BACKLOG_PROVIDER=local` and proceed directly to **If Local Tickets** below. Do NOT ask about GitHub CLI, JIRA credentials, or any external provider configuration.
825
-
826
- If the user selects **2**: display the secondary menu:
827
-
828
- ```
829
- ## External Backlog Provider
830
-
831
- Which external provider?
832
-
833
- 1. **Local tickets** (recommended) — lightweight JSON-based ticket management built into the project.
834
- No external tools required. Tickets stored in `.specrails/local-tickets.json`, version-controlled and diffable.
835
- 2. **GitHub Issues** — uses `gh` CLI to read/create issues with labels and VPC scores
836
- 3. **JIRA** — uses JIRA CLI or REST API to read/create tickets in a JIRA project
837
- 4. **None** — skip backlog commands (you can still use /implement with text descriptions)
838
- ```
839
-
840
- Wait for the user's choice. Set `BACKLOG_PROVIDER` to `local`, `github`, `jira`, or `none`.
841
-
842
- #### If Local Tickets
843
-
844
- No external tools or credentials required. Initialize the storage file:
845
-
846
- 1. Copy `templates/local-tickets-schema.json` to `.specrails/local-tickets.json`
847
- 2. Set `last_updated` to the current ISO-8601 timestamp
848
-
849
- Store configuration in `.specrails/backlog-config.json`:
850
- ```json
851
- {
852
- "provider": "local",
853
- "write_access": true,
854
- "git_auto": true
855
- }
856
- ```
857
-
858
- Local tickets are always read-write — there is no "read only" mode since the file is local.
859
-
860
- **Ticket schema** — each entry in the `tickets` map has these fields:
861
-
862
- ```json
863
- {
864
- "id": 1,
865
- "title": "Feature title",
866
- "description": "Markdown description",
867
- "status": "todo",
868
- "priority": "medium",
869
- "labels": ["area:frontend", "effort:medium"],
870
- "assignee": null,
871
- "prerequisites": [],
872
- "metadata": {
873
- "vpc_scores": {},
874
- "effort_level": "Medium",
875
- "user_story": "",
876
- "area": ""
877
- },
878
- "comments": [],
879
- "created_at": "<ISO-8601>",
880
- "updated_at": "<ISO-8601>",
881
- "created_by": "user",
882
- "source": "manual"
883
- }
884
- ```
885
-
886
- **Status values:** `todo`, `in_progress`, `done`, `cancelled`
887
- **Priority values:** `critical`, `high`, `medium`, `low`
888
- **Labels:** Freeform strings following the `area:*` and `effort:*` convention
889
- **Source values:** `manual`, `get-backlog-specs`, `propose-spec`
890
-
891
- **Advisory file locking protocol** (CLI agents and desktop app server must both follow this):
892
-
893
- The `revision` counter in the JSON root enables optimistic concurrency — increment it on **every** write. The lock file prevents concurrent corruption:
894
-
895
- 1. **Acquire lock:** Check for `.specrails/local-tickets.json.lock`
896
- - If the file exists and its `timestamp` is less than 30 seconds old: wait 500ms and retry (max 5 attempts before aborting with an error)
897
- - If the file exists and its `timestamp` is 30+ seconds old (stale): delete it and proceed
898
- - If no lock file exists: proceed immediately
899
- 2. **Create lock file:** Write `{"agent": "<agent-name-or-process>", "timestamp": "<ISO-8601>"}` to `.specrails/local-tickets.json.lock`
900
- 3. **Minimal lock window:** Read the JSON → modify in memory → write back → release
901
- 4. **Release lock:** Delete `.specrails/local-tickets.json.lock`
902
- 5. **Always increment `revision`** by 1 and update `last_updated` on every successful write
903
-
904
- The desktop app server uses `proper-lockfile` (or equivalent) to honor the same protocol via the `.lock` file path.
905
-
906
- #### If GitHub Issues
907
-
908
- - Verify `gh auth status` works. If not, warn and offer to skip.
909
- - Ask about **access mode**:
910
-
911
- ```
912
- ## GitHub Issues — Access Mode
913
-
914
- How should we interact with GitHub Issues?
915
-
916
- 1. **Read & Write** (default) — read backlog, create new issues from product discovery,
917
- close resolved issues, add comments on partial progress
918
- 2. **Read only** — read backlog for prioritization, but don't create or modify issues.
919
- Product discovery will propose ideas as output but won't sync them to GitHub.
920
- ```
921
-
922
- Set `BACKLOG_WRITE=true/false`.
923
-
924
- - If write mode, ask if they want to create labels:
925
- - `product-driven-backlog` (purple) — product feature ideas
926
- - `area:*` labels for each detected layer/area
927
- - `enhancement`, `bug`, `tech-debt`
928
-
929
- #### If JIRA
930
-
931
- First, check if JIRA CLI is installed:
932
-
933
- ```bash
934
- command -v jira &> /dev/null
935
- ```
936
-
937
- If not installed, offer to install it:
938
-
939
- > JIRA CLI is not installed. There are several options:
940
- >
941
- > 1. **go-jira** (recommended) — lightweight CLI
942
- > - macOS: `brew install go-jira`
943
- > - Linux/other: `go install github.com/go-jira/jira/cmd/jira@latest`
944
- > 2. **Atlassian CLI** — official but heavier
945
- > - `npm install -g @atlassian/cli`
946
- > 3. **Skip CLI, use REST API** — no CLI needed, uses `curl` with API token
947
- >
948
- > Which option? (1/2/3)
949
-
950
- If the user chooses option 1 or 2, run the install command. If option 3, proceed with REST API mode.
951
-
952
- Then ask for JIRA configuration:
953
-
954
- > To connect to JIRA, I need:
955
- >
956
- > 1. **JIRA base URL** (e.g., `https://your-company.atlassian.net`)
957
- > 2. **Project key** (e.g., `PROJ`, `DECK`, `MYAPP`)
958
- > 3. **Authentication method**:
959
- > - **JIRA CLI** (`jira` command) — if already configured
960
- > - **API token** — stored in `.env` as `JIRA_API_TOKEN` and `JIRA_USER_EMAIL`
961
- >
962
- > Optional:
963
- > - **Custom issue type** for backlog items (default: "Story")
964
- > - **Custom fields** for VPC scores (or use labels/description)
965
-
966
- Then ask about **access mode**:
967
-
968
- ```
969
- ## JIRA — Access Mode
970
-
971
- How should we interact with JIRA?
972
-
973
- 1. **Read & Write** — read tickets for implementation context, create new tickets
974
- from product discovery, add a comment to tickets when implementation is complete
975
- 2. **Read only** — read tickets for implementation context, but never create or
976
- modify tickets. Product discovery will propose ideas as output only. After
977
- implementation, the pipeline will show what to update manually but won't
978
- touch JIRA.
979
- ```
980
-
981
- Set `BACKLOG_WRITE=true/false`.
982
-
983
- <!-- This command is mirrored from commands/enrich.md for staged installs. -->
984
-
985
- #### Project Label
986
-
987
- After the access mode selection, ask:
988
-
989
- > **Project Label (optional but recommended)**
990
- >
991
- > JIRA teams often tag all tickets for a product with a project label
992
- > (e.g., `PROJECT-specrails`, `PLATFORM`, `MOBILE`). This label is applied
993
- > to every ticket the backlog pipeline creates — making it easy to filter all
994
- > AI-generated backlog items across JIRA.
995
- >
996
- > Enter a project label, or press Enter to skip:
997
-
998
- If the user enters a label: set `PROJECT_LABEL=<value>`.
999
- If the user skips: set `PROJECT_LABEL=""`.
1000
-
1001
- #### Epic Link Field
1002
-
1003
- Ask:
1004
-
1005
- > **Epic Link Field (optional — advanced)**
1006
- >
1007
- > JIRA Next-Gen (team-managed) projects link stories to epics using the `parent`
1008
- > field. JIRA Classic (company-managed) projects use `Epic Link` (customfield_10014).
1009
- >
1010
- > Which does your project use?
1011
- > 1. `parent` — Next-Gen / team-managed **(default)**
1012
- > 2. `customfield_10014` — Classic / company-managed
1013
-
1014
- Set `EPIC_LINK_FIELD` to `parent` or `customfield_10014`. Default: `parent`.
1015
-
1016
- Store the full configuration in `.specrails/backlog-config.json`:
1017
- ```json
1018
- {
1019
- "provider": "jira",
1020
- "write_access": true,
1021
- "jira_base_url": "https://your-company.atlassian.net",
1022
- "jira_project_key": "PROJ",
1023
- "issue_type": "Story",
1024
- "auth_method": "api_token",
1025
- "cli_installed": true,
1026
- "project_label": "<PROJECT_LABEL or empty string>",
1027
- "epic_link_field": "parent",
1028
- "epic_mapping": {}
1029
- }
1030
- ```
1031
-
1032
- #### If None
1033
-
1034
- - Skip `/specrails:get-backlog-specs` and `/specrails:auto-propose-backlog-specs` commands.
1035
- - The `/specrails:implement` command will still work with text descriptions.
1036
-
1037
- ### 3.3 Git & shipping workflow
1038
-
1039
- Ask how the user wants to handle git operations after implementation:
1040
-
1041
- ```
1042
- ## Git & Shipping
1043
-
1044
- After implementation is complete, how should we handle shipping?
1045
-
1046
- 1. **Automatic** (default) — create branch, commit changes, push, and open a PR
1047
- (requires GitHub CLI for PRs, otherwise prints a compare URL)
1048
- 2. **Manual** — stop after implementation and review. You handle branching,
1049
- committing, and PR creation yourself. The pipeline will show a summary
1050
- of all changes but won't touch git.
1051
- ```
1052
-
1053
- Set `GIT_AUTO=true/false`.
1054
-
1055
- If automatic, also check if `gh` is authenticated (for PR creation). If not, warn that PRs will be skipped but commits and push will still work.
1056
-
1057
- ### 3.4 Commands to install
1058
-
1059
- ```
1060
- ## Command Selection
1061
-
1062
- | Command | Purpose | Requires |
1063
- |---------|---------|----------|
1064
- | /specrails:implement | Full pipeline: sr-architect → sr-developer → sr-reviewer → ship | sr-architect + sr-developer + sr-reviewer |
1065
- | /specrails:batch-implement | Orchestrate multiple features in dependency-aware waves | sr-architect + sr-developer + sr-reviewer |
1066
- | /specrails:propose-spec | Interactively propose and refine a feature spec, then create a GitHub issue | GitHub CLI |
1067
- | /specrails:get-backlog-specs | View prioritized backlog with VPC scores | sr-product-analyst + Backlog provider |
1068
- | /specrails:auto-propose-backlog-specs | Generate new feature ideas via product discovery | sr-product-manager + Backlog provider |
1069
- | /specrails:compat-check | Snapshot API surface and detect breaking changes | None |
1070
- | /specrails:refactor-recommender | Scan for refactoring opportunities ranked by impact/effort | None |
1071
- | /specrails:why | Search past architectural decisions from agent memory | None |
1072
-
1073
- [All] [Custom selection]
1074
- ```
1075
-
1076
- Note: If `BACKLOG_PROVIDER=none`, the backlog commands are not offered.
1077
-
1078
- ### 3.5 Confirm configuration
1079
-
1080
- Display the full configuration summary including access modes:
1081
-
1082
- ```
1083
- ## Configuration Summary
1084
-
1085
- | Setting | Value |
1086
- |---------|-------|
1087
- | Backlog provider | GitHub Issues / JIRA / None |
1088
- | Backlog access | Read & Write / Read only |
1089
- | Project label (JIRA) | PROJECT-specrails / (none) |
1090
- | Epic link field (JIRA) | parent / customfield_10014 |
1091
- | Git workflow | Automatic / Manual |
1092
- | Agents | [list] |
1093
- | Commands | [list] |
1094
- | Personas | [count] personas |
1095
-
1096
- Note: The `Project label (JIRA)` and `Epic link field (JIRA)` rows are only shown when `BACKLOG_PROVIDER=jira`.
1097
-
1098
- [Confirm] [Modify]
1099
- ```
1100
-
1101
- Wait for final confirmation.
1102
-
1103
- ---
1104
-
1105
- ## Phase 4: Generate Files
1106
-
1107
- Read each template from `.specrails/setup-templates/` and generate the final files adapted to this project. Use the codebase analysis from Phase 1, personas from Phase 2, and configuration from Phase 3.
1108
-
1109
- **Output base directory:** All output paths in Phase 4 use `.claude` as the base directory (`specrails_dir = ".claude"`).
1110
-
1111
- ### 4.1 Generate agents
1112
-
1113
- For each selected agent, read the template and generate the adapted version.
1114
-
1115
- **Template → Output mapping:**
1116
-
1117
- - `.specrails/setup-templates/agents/sr-architect.md` → `.claude/agents/sr-architect.md`
1118
- - `.specrails/setup-templates/agents/sr-developer.md` → `.claude/agents/sr-developer.md`
1119
- - `.specrails/setup-templates/agents/sr-reviewer.md` → `.claude/agents/sr-reviewer.md`
1120
- - `.specrails/setup-templates/agents/sr-test-writer.md` → `.claude/agents/sr-test-writer.md`
1121
- - `.specrails/setup-templates/agents/sr-security-reviewer.md` → `.claude/agents/sr-security-reviewer.md`
1122
- - `.specrails/setup-templates/agents/sr-product-manager.md` → `.claude/agents/sr-product-manager.md`
1123
- - `.specrails/setup-templates/agents/sr-product-analyst.md` → `.claude/agents/sr-product-analyst.md`
1124
- - `.specrails/setup-templates/agents/sr-backend-developer.md` → `.claude/agents/sr-backend-developer.md` (if backend layer)
1125
- - `.specrails/setup-templates/agents/sr-frontend-developer.md` → `.claude/agents/sr-frontend-developer.md` (if frontend layer)
1126
-
1127
- When generating each agent:
1128
- 1. Read the template
1129
- 2. Replace all `{{PLACEHOLDER}}` values with project-specific content:
1130
- - `{{PROJECT_NAME}}` → project name
1131
- - `{{ARCHITECTURE_DIAGRAM}}` → detected architecture
1132
- - `{{LAYER_TAGS}}` → detected layer tags (e.g., `[backend]`, `[frontend]`, `[api]`, `[mobile]`)
1133
- - `{{CI_COMMANDS_BACKEND}}` → backend CI commands from Phase 1
1134
- - `{{CI_COMMANDS_FRONTEND}}` → frontend CI commands from Phase 1
1135
- - `{{LAYER_CONVENTIONS}}` → detected conventions per layer
1136
- - `{{PERSONA_NAMES}}` → names from generated personas
1137
- - `{{PERSONA_FILES}}` → paths to persona files
1138
- - `{{DOMAIN_EXPERTISE}}` → domain knowledge from Phase 2 research
1139
- - `{{COMPETITIVE_LANDSCAPE}}` → competitors discovered in Phase 2
1140
- - `{{KEY_FILE_PATHS}}` → important file paths detected in Phase 1
1141
- - `{{WARNINGS}}` → project-specific warnings (from existing CLAUDE.md or detected)
1142
- - `{{MEMORY_PATH}}` → agent memory directory path (e.g., `$SPECRAILS_DIR/agent-memory/sr-<agent-name>/`)
1143
- - `{{TECH_EXPERTISE}}` → detected languages, frameworks, and test frameworks from Phase 1
1144
- - `{{LAYER_CLAUDE_MD_PATHS}}` → comma-separated paths to per-layer rules files (e.g., `$SPECRAILS_DIR/rules/backend.md`, `$SPECRAILS_DIR/rules/frontend.md`)
1145
- - `{{SECURITY_EXEMPTIONS_PATH}}` → `$SPECRAILS_DIR/security-exemptions.yaml`
1146
- 3. Resolve the agent's model using `AGENTS_CONFIG` (loaded in Phase 2.5):
1147
- - Check `AGENTS_CONFIG.agents.<agent-name>.model` (per-agent override)
1148
- - If not present, check `AGENTS_CONFIG.defaults.model` (global default)
1149
- - If `AGENTS_CONFIG` was not loaded (e.g., re-run without config), use the model from the template frontmatter (current behavior)
1150
- - Replace the `model:` field in the YAML frontmatter with the resolved value before writing
1151
- 4. Write the final file as Markdown with YAML frontmatter — the template file as-is (frontmatter preserved).
1152
-
1153
- ### 4.2 Generate personas
1154
-
1155
- If IS_OSS=true:
1156
- 1. Copy `.specrails/setup-templates/personas/the-maintainer.md` to `$SPECRAILS_DIR/agents/personas/the-maintainer.md`
1157
- 2. Log: "Maintainer persona included"
1158
- 3. Set MAINTAINER_INCLUDED=true for use in template substitution
1159
- 4. Set `{{MAINTAINER_PERSONA_LINE}}` = `- \`$SPECRAILS_DIR/agents/personas/the-maintainer.md\` — "Kai" the Maintainer (open-source maintainer)`
1160
- 5. Increment `{{PERSONA_COUNT}}` by 1 to account for the Maintainer
1161
-
1162
- If IS_OSS=false:
1163
- - Set `{{MAINTAINER_PERSONA_LINE}}` = *(empty string)*
1164
-
1165
- Then for each user-defined VPC persona from Phase 2.3:
1166
-
1167
- Write each persona to `$SPECRAILS_DIR/agents/personas/`:
1168
- - Use the VPC personas generated in Phase 2
1169
- - File naming: kebab-case of persona nickname (e.g., `the-developer.md`, `the-admin.md`)
1170
-
1171
- ### 4.3 Generate commands
1172
-
1173
- For each selected command, read the template and adapt.
1174
-
1175
- - `.specrails/setup-templates/commands/specrails/implement.md` → `.claude/commands/specrails/implement.md`
1176
- - `.specrails/setup-templates/commands/specrails/batch-implement.md` → `.claude/commands/specrails/batch-implement.md`
1177
- - `.specrails/setup-templates/commands/specrails/propose-spec.md` → `.claude/commands/specrails/propose-spec.md`
1178
- - `.specrails/setup-templates/commands/specrails/get-backlog-specs.md` → `.claude/commands/specrails/get-backlog-specs.md` (if `BACKLOG_PROVIDER != none`)
1179
- - `.specrails/setup-templates/commands/specrails/auto-propose-backlog-specs.md` → `.claude/commands/specrails/auto-propose-backlog-specs.md` (if `BACKLOG_PROVIDER != none`)
1180
- - `.specrails/setup-templates/commands/specrails/compat-check.md` → `.claude/commands/specrails/compat-check.md`
1181
- - `.specrails/setup-templates/commands/specrails/refactor-recommender.md` → `.claude/commands/specrails/refactor-recommender.md`
1182
- - `.specrails/setup-templates/commands/specrails/why.md` → `.claude/commands/specrails/why.md`
1183
- - `.specrails/setup-templates/commands/specrails/reconfig.md` → `.claude/commands/specrails/reconfig.md`
1184
-
1185
- Create the output directory before writing (`mkdir -p .claude/commands/specrails/`).
1186
-
1187
- Adapt:
1188
- - CI commands to match detected stack
1189
- - **Persona references** to match generated personas (see substitution rules below)
1190
- - File paths to match project structure
1191
- - Layer tags to match detected layers
1192
- - **Backlog provider commands** based on `BACKLOG_PROVIDER`:
1193
-
1194
- #### Backlog command persona placeholder substitution
1195
-
1196
- When adapting `auto-propose-backlog-specs.md` and `get-backlog-specs.md`, substitute the persona placeholders based on the full persona set (user-generated personas + Maintainer if `IS_OSS=true`):
1197
-
1198
- | Placeholder | Substitution rule |
1199
- |-------------|------------------|
1200
- | `{{PERSONA_FILE_READ_LIST}}` | One bullet per persona file: `- Read \`$SPECRAILS_DIR/agents/personas/{name}.md\`` |
1201
- | `{{PERSONA_SCORE_HEADERS}}` | Column headers for each persona nickname: e.g., `Alex \| Sara \| Kai` |
1202
- | `{{PERSONA_SCORE_SEPARATORS}}` | One `------` separator per persona column |
1203
- | `{{PERSONA_FIT_FORMAT}}` | Inline score display: e.g., `Alex: X/5, Sara: X/5, Kai: X/5` |
1204
- | `{{PERSONA_VPC_SECTIONS}}` | One VPC section block per persona (see format below) |
1205
- | `{{MAX_SCORE}}` | Total max score = 5 × number of personas (e.g., `15` for 3 personas) |
1206
- | `{{PERSONA_NAMES_WITH_ROLES}}` | Comma-separated: e.g., `Alex (Lead Dev), Sara (Product Founder), Kai (OSS Maintainer)` |
1207
-
1208
- **`{{PERSONA_VPC_SECTIONS}}` format** — repeat for each persona in order:
1209
- ```
1210
- ### "{Nickname}" — The {Role} (X/5)
1211
- - **Jobs addressed**: {list}
1212
- - **Pains relieved**: {list with severity}
1213
- - **Gains created**: {list with impact}
1214
- ```
1215
-
1216
- **Kai inclusion rule**: When `IS_OSS=true`, Kai (`sr-the-maintainer.md`) is always the last entry in persona lists and the rightmost column in scoring tables. Kai uses the evaluation criteria defined in `.claude/agents/personas/sr-the-maintainer.md` — features score high (4-5/5) for Kai when they reduce async review burden, enforce project-specific conventions, or automate release/dependency coordination; features score low (0-1/5) when they add configuration complexity or require paid tiers.
1217
-
1218
- **When `IS_OSS=false`**: All Kai-related persona references are omitted. `{{MAX_SCORE}}` reduces by 5. Tables and inline scores contain only user-generated personas.
1219
-
1220
- #### Local Tickets (`BACKLOG_PROVIDER=local`)
1221
-
1222
- For the local provider, backlog placeholders resolve to **inline file-operation instructions** embedded in the generated command markdown — not shell commands. Agents execute these by reading/writing `.specrails/local-tickets.json` directly using their file tools.
1223
-
1224
- All write operations must follow the **advisory file locking protocol** defined in Phase 3.2. Always increment `revision` and update `last_updated` on every write.
1225
-
1226
- | Placeholder | Substituted value |
1227
- |-------------|-------------------|
1228
- | `{{BACKLOG_PROVIDER_NAME}}` | `Local Tickets` |
1229
- | `{{BACKLOG_PREFLIGHT}}` | `[[ -f ".specrails/local-tickets.json" ]] && echo "Local tickets storage: OK" \|\| echo "WARNING: .specrails/local-tickets.json not found — run /specrails:enrich to initialize"` |
1230
- | `{{BACKLOG_FETCH_CMD}}` | Read `.specrails/local-tickets.json`. Parse the `tickets` map and return all entries where `status` is `"todo"` or `"in_progress"`. |
1231
- | `{{BACKLOG_FETCH_ALL_CMD}}` | Read `.specrails/local-tickets.json`. Parse the `tickets` map and return all entries regardless of status. |
1232
- | `{{BACKLOG_FETCH_CLOSED_CMD}}` | Read `.specrails/local-tickets.json`. Parse the `tickets` map and return all entries where `status` is `"done"` or `"cancelled"`. |
1233
- | `{{BACKLOG_VIEW_CMD}}` | Read `.specrails/local-tickets.json`. Parse JSON and return the full ticket object at `tickets["{id}"]`, or an error if not found. |
1234
- | `{{BACKLOG_CREATE_CMD}}` | Write to `.specrails/local-tickets.json` using the advisory locking protocol: acquire lock → read file → set `id = next_id`, increment `next_id`, set all ticket fields, set `created_at` and `updated_at` to now, bump `revision`, update `last_updated` → write → release lock. |
1235
- | `{{BACKLOG_UPDATE_CMD}}` | Write to `.specrails/local-tickets.json` using the advisory locking protocol: acquire lock → read file → update fields in `tickets["{id}"]`, set `updated_at` to now, bump `revision`, update `last_updated` → write → release lock. |
1236
- | `{{BACKLOG_DELETE_CMD}}` | Write to `.specrails/local-tickets.json` using the advisory locking protocol: acquire lock → read file → delete `tickets["{id}"]`, bump `revision`, update `last_updated` → write → release lock. |
1237
- | `{{BACKLOG_COMMENT_CMD}}` | Write to `.specrails/local-tickets.json` using the advisory locking protocol: acquire lock → read file → append `{"author": "<agent-name>", "body": "<comment>", "created_at": "<ISO-8601>"}` to `tickets["{id}"].comments` (create the array if absent), set `updated_at` to now, bump `revision`, update `last_updated` → write → release lock. |
1238
- | `{{BACKLOG_PARTIAL_COMMENT_CMD}}` | Same as `{{BACKLOG_COMMENT_CMD}}` but append `{"author": "<agent-name>", "body": "<comment>", "type": "progress", "created_at": "<ISO-8601>"}`. |
1239
- | `{{BACKLOG_INIT_LABELS_CMD}}` | No label initialization required. Local tickets use freeform label strings. Standard label conventions: `area:frontend`, `area:backend`, `area:api`, `effort:low`, `effort:medium`, `effort:high`. |
1240
-
1241
- #### GitHub Issues (`BACKLOG_PROVIDER=github`)
1242
- - Issue fetch: `gh issue list --label "product-driven-backlog" --state open --limit 100 --json number,title,labels,body`
1243
- - Issue create: `gh issue create --title "..." --label "..." --body "..."`
1244
- - Issue view: `gh issue view {number} --json number,title,labels,body`
1245
- - Issue label names to match project areas
1246
- - Pre-flight check: `gh auth status`
1247
-
1248
- #### JIRA (`BACKLOG_PROVIDER=jira`)
1249
- - Issue fetch: `jira issue list --project {{JIRA_PROJECT_KEY}} --type Story --label get-backlog-specs --status "To Do" --plain` or equivalent JIRA REST API call via curl:
1250
- ```bash
1251
- curl -s -u "$JIRA_USER_EMAIL:$JIRA_API_TOKEN" \
1252
- "{{JIRA_BASE_URL}}/rest/api/3/search?jql=project={{JIRA_PROJECT_KEY}} AND labels=get-backlog-specs AND status='To Do'&fields=summary,description,labels,priority"
1253
- ```
1254
- - Issue create: `jira issue create --project {{JIRA_PROJECT_KEY}} --type Story --summary "..." --label get-backlog-specs --description "..."` or equivalent REST API call
1255
- - Issue view: `jira issue view {key}` or REST API
1256
- - VPC scores stored in the issue description body (same markdown format, parsed from description)
1257
- - Pre-flight check: `jira me` or test API connectivity
1258
- - Store JIRA config in `.specrails/backlog-config.json`:
1259
- ```json
1260
- {
1261
- "provider": "jira",
1262
- "jira_base_url": "https://your-company.atlassian.net",
1263
- "jira_project_key": "PROJ",
1264
- "issue_type": "Story",
1265
- "auth_method": "api_token"
1266
- }
1267
- ```
1268
-
1269
- The command templates use `{{BACKLOG_FETCH_CMD}}`, `{{BACKLOG_CREATE_CMD}}`, `{{BACKLOG_VIEW_CMD}}`, `{{BACKLOG_PREFLIGHT}}`, and related placeholders that get filled with the provider-specific commands (for `local`) or instructions (for `github`, `jira`). The `{{BACKLOG_PROVIDER_NAME}}` placeholder is substituted with a human-readable provider label in all three cases.
1270
-
1271
- ### 4.4 Generate rules
1272
-
1273
- For each detected layer, read the layer rule template and generate a layer-specific rules file:
1274
- - `.specrails/setup-templates/rules/layer.md` → `$SPECRAILS_DIR/rules/{layer-name}.md`
1275
-
1276
- Each rule file must:
1277
- - Have the correct `paths:` frontmatter matching the layer's directory
1278
- - Contain conventions specific to that layer (from Phase 1 analysis)
1279
- - Reference actual file paths and patterns from the codebase
1280
-
1281
- ### 4.5 Generate root instructions file
1282
-
1283
- If no `CLAUDE.md` exists, generate one from the template. If one already exists, **merge** — add the agent workflow sections without removing existing content.
1284
-
1285
- ### 4.6 Generate settings
1286
-
1287
- Create or merge `.claude/settings.json` with permissions for:
1288
- - All detected CI commands
1289
- - Git operations
1290
- - OpenSpec CLI (if installed)
1291
- - GitHub CLI (if available)
1292
- - Language-specific tools (python, npm, cargo, go, etc.)
1293
-
1294
- ### 4.7 Initialize agent memory
1295
-
1296
- Create memory directories for each installed agent using the provider-aware base directory:
1297
-
1298
- ```bash
1299
- mkdir -p $SPECRAILS_DIR/agent-memory/sr-{agent-name}/
1300
- ```
1301
-
1302
- Each gets an empty `MEMORY.md` that will be populated during usage.
1303
-
1304
- ---
1305
-
1306
- ## Phase 5: Cleanup & Summary
1307
-
1308
- ### 5.1 Remove all scaffolding artifacts
1309
-
1310
- The setup process installed temporary files that are only needed during installation. Remove them all now that the final files have been generated.
1311
-
1312
- ```bash
1313
- # 1. Remove setup templates (used as structural references during generation)
1314
- rm -rf .specrails/setup-templates/
1315
-
1316
- # 2. Remove the /specrails:enrich command itself — it's a one-time installer, not a permanent command
1317
- rm -f .claude/commands/enrich.md
1318
-
1319
- # 3. Remove the specrails/ directory from the repo if it exists at the root
1320
- # (it was only needed for the retired shell installer and staging templates — everything is now in .claude/)
1321
- # NOTE: Only remove if it's inside this repo. Ask the user if unsure.
1322
- ```
1323
-
1324
- **What gets removed:**
1325
- | Artifact | Why |
1326
- |----------|-----|
1327
- | `.specrails/setup-templates/` | Temporary — templates already rendered into final files |
1328
- | `.claude/commands/enrich.md` | One-time installer — running it again would overwrite customized agents |
1329
-
1330
- **What to do with `specrails/`:**
1331
-
1332
- The `specrails/` directory should NOT be committed to the target repo — it's an installer tool, not part of the project. Always add it to `.gitignore`:
1333
-
1334
- ```bash
1335
- # Add specrails/ to .gitignore if not already there
1336
- if ! grep -q '^specrails/' .gitignore 2>/dev/null; then
1337
- echo '' >> .gitignore
1338
- echo '# specrails installer (one-time setup tool, not part of the project)' >> .gitignore
1339
- echo 'specrails/' >> .gitignore
1340
- fi
1341
- ```
1342
-
1343
- Then ask the user:
1344
-
1345
- > `specrails/` has been added to `.gitignore`. Do you also want to delete it?
1346
- >
1347
- > 1. **Keep it** (default) — stays locally in case you want to re-run setup or install in other repos
1348
- > 2. **Delete it** — everything is installed, you don't need it anymore
1349
-
1350
- Apply the user's choice.
1351
-
1352
- ### 5.2 Verify clean state
1353
-
1354
- After cleanup, verify that only the intended files remain:
1355
-
1356
- ```bash
1357
- # These should exist (the actual system):
1358
- ls .claude/agents/sr-*.md
1359
- ls .claude/agents/personas/*.md
1360
- ls .claude/commands/specrails/*.md
1361
- ls .claude/rules/*.md
1362
- ls .claude/agent-memory/
1363
-
1364
- # These should NOT exist (scaffolding):
1365
- # .specrails/setup-templates/ — GONE
1366
- # .claude/commands/enrich.md — GONE
1367
- ```
1368
-
1369
- If any scaffolding artifact remains, remove it.
1370
-
1371
- ### 5.3 Summary
1372
-
1373
- Display the complete installation summary:
1374
-
1375
- ```
1376
- ## Setup Complete
1377
-
1378
- ### Agents Installed
1379
- | Agent | File | Model |
1380
- |-------|------|-------|
1381
- | sr-architect | .claude/agents/sr-architect.md | Sonnet |
1382
- | sr-developer | .claude/agents/sr-developer.md | Sonnet |
1383
- | sr-reviewer | .claude/agents/sr-reviewer.md | Sonnet |
1384
- | sr-test-writer | .claude/agents/sr-test-writer.md | Sonnet |
1385
- | sr-security-reviewer | .claude/agents/sr-security-reviewer.md | Sonnet |
1386
- | sr-product-manager | .claude/agents/sr-product-manager.md | Opus |
1387
-
1388
- ### Personas Created
1389
- | Persona | File | Source |
1390
- |---------|------|--------|
1391
- [If IS_OSS=true:]
1392
- | "Kai" — The Maintainer | $SPECRAILS_DIR/agents/personas/sr-the-maintainer.md | Auto-included (OSS) |
1393
- [For each user-generated persona:]
1394
- | "[Name]" — The [Role] | $SPECRAILS_DIR/agents/personas/[name].md | Generated |
1395
-
1396
- ### Commands Installed
1397
- | Command | File |
1398
- |---------|------|
1399
- | /specrails:implement | .claude/commands/specrails/implement.md |
1400
- | /specrails:batch-implement | .claude/commands/specrails/batch-implement.md |
1401
- | /specrails:propose-spec | .claude/commands/specrails/propose-spec.md |
1402
- | /specrails:get-backlog-specs | .claude/commands/specrails/get-backlog-specs.md |
1403
- | /specrails:auto-propose-backlog-specs | .claude/commands/specrails/auto-propose-backlog-specs.md |
1404
- | /specrails:compat-check | .claude/commands/specrails/compat-check.md |
1405
- | /specrails:refactor-recommender | .claude/commands/specrails/refactor-recommender.md |
1406
- | /specrails:why | .claude/commands/specrails/why.md |
1407
-
1408
- Note: Only commands selected during setup are shown. Backlog commands are excluded if no backlog provider was configured.
1409
-
1410
- ### Rules Created
1411
- | Layer | File |
1412
- |-------|------|
1413
- | Backend | $SPECRAILS_DIR/rules/backend.md |
1414
- | Frontend | $SPECRAILS_DIR/rules/frontend.md |
1415
-
1416
- ### Scaffolding Removed
1417
- | Artifact | Status |
1418
- |----------|--------|
1419
- | .specrails/setup-templates/ | Deleted |
1420
- | .claude/commands/enrich.md | Deleted |
1421
- | specrails/ | [User's choice] |
1422
-
1423
- ### Next Steps
1424
- 1. Review the generated files in .claude/
1425
- 2. Run `/specrails:get-backlog-specs` to see your backlog (if GitHub Issues exist)
1426
- 3. Run `/specrails:auto-propose-backlog-specs` to generate feature ideas
1427
- 4. Run `/specrails:implement #issue-number` to implement a feature
1428
- 5. Commit the .claude/ directory to version control
1429
-
1430
- ### Quick Start
1431
- - `/specrails:implement "describe a feature"` — implement something right now
1432
- - `/specrails:get-backlog-specs` — see prioritized feature ideas
1433
- - `/specrails:auto-propose-backlog-specs` — discover new features using VPC
1434
- ```
1435
-
1436
- ## First Task Prompt (Full Wizard)
1437
-
1438
- After displaying the setup complete summary above, detect the project type and output:
1439
-
1440
- **New project** (no `package.json`, `Gemfile`, `pyproject.toml`, `go.mod`, or `pom.xml` in root):
1441
- ```
1442
- ✅ Setup complete.
1443
-
1444
- Try your first spec:
1445
- > /specrails:get-backlog-specs
1446
- ```
1447
-
1448
- **Existing codebase** (one or more of the above files found in root):
1449
- ```
1450
- ✅ Setup complete.
1451
-
1452
- Try your first spec:
1453
- > /specrails:refactor-recommender
1454
- ```
1455
-
1456
- Then stop.