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