specrails-core 1.7.3 → 2.1.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.
package/commands/setup.md CHANGED
@@ -44,20 +44,22 @@ Read the following files to understand the current installation state:
44
44
 
45
45
  2. Read `.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
46
 
47
- 3. List all template files in `.claude/setup-templates/agents/` these are the NEW agent templates from the update:
47
+ 3. Determine `$SPECRAILS_DIR` by reading `$SPECRAILS_DIR/setup-templates/.provider-detection.json` — try `.claude/setup-templates/.provider-detection.json` first, then `.codex/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_DIR/setup-templates/agents/` — these are the NEW agent templates from the update:
48
50
  ```bash
49
- ls .claude/setup-templates/agents/
51
+ ls $SPECRAILS_DIR/setup-templates/agents/
50
52
  ```
51
53
  Template files are named with `sr-` prefix (e.g., `sr-architect.md`, `sr-developer.md`).
52
54
 
53
- 4. List all template files in `.claude/setup-templates/commands/sr/` — these are the NEW command templates from the update:
55
+ 5. List all template files in `$SPECRAILS_DIR/setup-templates/commands/sr/` — these are the NEW command templates from the update:
54
56
  ```bash
55
- ls .claude/setup-templates/commands/sr/
57
+ ls $SPECRAILS_DIR/setup-templates/commands/sr/
56
58
  ```
57
59
  Command template files include `implement.md`, `batch-implement.md`, `health-check.md`, `compat-check.md`, `refactor-recommender.md`, `why.md`, `product-backlog.md`, `update-product-driven-backlog.md`.
58
60
  If this directory does not exist, skip command template checking for this update.
59
61
 
60
- 5. Read `.claude/backlog-config.json` if it exists — contains stored provider configuration needed for command placeholder substitution.
62
+ 6. Read `$SPECRAILS_DIR/backlog-config.json` if it exists — contains stored provider configuration needed for command placeholder substitution.
61
63
 
62
64
  ### Phase U2: Quick Codebase Re-Analysis
63
65
 
@@ -143,7 +145,7 @@ Then jump to Phase U7.
143
145
 
144
146
  For each agent in the "changed" list:
145
147
 
146
- 1. Read the NEW template from `.claude/setup-templates/agents/sr-<name>.md`
148
+ 1. Read the NEW template from `$SPECRAILS_DIR/setup-templates/agents/sr-<name>.md`
147
149
  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:
148
150
  - `{{PROJECT_NAME}}` → project name (from README.md or directory name)
149
151
  - `{{ARCHITECTURE_DIAGRAM}}` → detected architecture layers
@@ -151,18 +153,23 @@ For each agent in the "changed" list:
151
153
  - `{{CI_COMMANDS_BACKEND}}` → backend CI commands
152
154
  - `{{CI_COMMANDS_FRONTEND}}` → frontend CI commands
153
155
  - `{{LAYER_CONVENTIONS}}` → detected conventions per layer
154
- - `{{PERSONA_NAMES}}` → read existing persona names from `.claude/agents/personas/` filenames
155
- - `{{PERSONA_FILES}}` → paths to existing persona files in `.claude/agents/personas/`
156
+ - `{{PERSONA_NAMES}}` → read existing persona names from `$SPECRAILS_DIR/agents/personas/` filenames
157
+ - `{{PERSONA_FILES}}` → paths to existing persona files in `$SPECRAILS_DIR/agents/personas/`
156
158
  - `{{DOMAIN_EXPERTISE}}` → infer from detected stack and README
157
159
  - `{{KEY_FILE_PATHS}}` → important file paths detected in Phase U2
158
160
  - `{{WARNINGS}}` → read from existing `CLAUDE.md` if present
159
- - `{{MEMORY_PATH}}` → `.claude/agent-memory/sr-<agent-name>/`
160
- 3. Write the adapted agent to `.claude/agents/sr-<name>.md`
161
+ - `{{MEMORY_PATH}}` → `$SPECRAILS_DIR/agent-memory/sr-<agent-name>/`
162
+ 3. Write the adapted agent using the format for the active provider (same dual-format rules as Phase 4.1):
163
+ - `cli_provider == "claude"`: write to `$SPECRAILS_DIR/agents/sr-<name>.md` (Markdown with YAML frontmatter)
164
+ - `cli_provider == "codex"`: write to `$SPECRAILS_DIR/agents/sr-<name>.toml` (TOML format with `name`, `description`, `model`, `prompt` fields)
161
165
  4. Show: `✓ Regenerated sr-<name>`
162
166
 
163
167
  After regenerating all changed agents, verify no unresolved placeholders remain:
164
168
  ```bash
169
+ # Claude Code
165
170
  grep -r '{{[A-Z_]*}}' .claude/agents/sr-*.md 2>/dev/null || echo "OK: no broken placeholders"
171
+ # Codex
172
+ grep -r '{{[A-Z_]*}}' .codex/agents/sr-*.toml 2>/dev/null || echo "OK: no broken placeholders"
166
173
  ```
167
174
 
168
175
  ### Phase U4b: Update Changed Commands
@@ -207,7 +214,7 @@ For each agent in the "new" list:
207
214
  > "New agent available: `sr-<name>` — no [layer] detected in your project. Skip? [Y/n]"
208
215
  3. If the user accepts (or presses Enter on a pre-selected default):
209
216
  - Generate the agent using the same template adaptation as Phase U4
210
- - Create memory directory if it does not exist: `.claude/agent-memory/sr-<name>/`
217
+ - Create memory directory if it does not exist: `$SPECRAILS_DIR/agent-memory/sr-<name>/`
211
218
  - Show: `✓ Added sr-<name>`
212
219
  4. If the user declines:
213
220
  - Show: `→ Skipped sr-<name>`
@@ -330,6 +337,25 @@ Detect whether this is an existing codebase or new project:
330
337
 
331
338
  Store as `QS_IS_EXISTING_CODEBASE=true/false`.
332
339
 
340
+ ### QS2.5: Re-run Detection
341
+
342
+ Before generating files, check if this is a re-run:
343
+
344
+ 1. Check if `.claude/commands/sr/` directory exists with any `.md` files:
345
+ ```bash
346
+ ls .claude/commands/sr/*.md 2>/dev/null
347
+ ```
348
+ 2. If `.md` files are found → this is a **re-run**. Store `QS_IS_RERUN=true`.
349
+ 3. If the directory does not exist or is empty → this is a **fresh install**. Store `QS_IS_RERUN=false`.
350
+
351
+ In re-run mode, QS3 executes in **gap-fill mode** for command files:
352
+ - For each command in the list, check if it already exists at `.claude/commands/sr/<name>.md`
353
+ - If it exists: skip it and show `✓ Already installed: /sr:<name>`
354
+ - If it does NOT exist: install it and show `✓ Added /sr:<name> (was missing)`
355
+ - Do NOT prompt the user for confirmation on missing files — install them automatically
356
+
357
+ For CLAUDE.md and agent files, the existing per-file prompts already handle re-runs (user is asked before overwriting). No change needed there.
358
+
333
359
  ### QS3: Generate files
334
360
 
335
361
  Generate files using the Quick Start defaults.
@@ -350,7 +376,9 @@ Skip if user says no.
350
376
 
351
377
  **2. Agent files**
352
378
 
353
- For each default agent (sr-architect, sr-developer, sr-reviewer, sr-product-manager), read the template from `setup-templates/agents/<name>.md` and generate the adapted agent file at `.claude/agents/<name>.md`.
379
+ For each default agent (sr-architect, sr-developer, sr-reviewer, sr-product-manager), read the template from `$SPECRAILS_DIR/setup-templates/agents/<name>.md` and generate the adapted agent file using the dual-format rules from Phase 4.1:
380
+ - `cli_provider == "claude"`: write to `.claude/agents/<name>.md` (Markdown with frontmatter)
381
+ - `cli_provider == "codex"`: write to `.codex/agents/<name>.toml` (TOML format)
354
382
 
355
383
  Fill placeholders with best-effort values from the limited context available:
356
384
  - `{{PROJECT_NAME}}` → directory name or README first heading
@@ -362,11 +390,11 @@ Fill placeholders with best-effort values from the limited context available:
362
390
  - `{{LAYER_TAGS}}` → detect from package.json / Gemfile / go.mod if present; otherwise leave empty
363
391
  - All other placeholders → "(not configured — run `/setup --advanced`)"
364
392
 
365
- Create memory directories: `.claude/agent-memory/sr-<name>/`
393
+ Create memory directories: `$SPECRAILS_DIR/agent-memory/sr-<name>/`
366
394
 
367
395
  **3. Command files**
368
396
 
369
- Copy core commands from `setup-templates/commands/sr/` to `.claude/commands/sr/`:
397
+ Core commands (always install if missing):
370
398
  - `implement.md`
371
399
  - `batch-implement.md`
372
400
  - `propose-spec.md`
@@ -376,6 +404,12 @@ Copy core commands from `setup-templates/commands/sr/` to `.claude/commands/sr/`
376
404
 
377
405
  Do NOT copy `product-backlog.md` or `update-product-driven-backlog.md` (no backlog provider configured).
378
406
 
407
+ If `QS_IS_RERUN=false` (fresh install): copy all core commands from `setup-templates/commands/sr/` to `.claude/commands/sr/`.
408
+
409
+ If `QS_IS_RERUN=true` (gap-fill mode): for each command in the list above, check if `.claude/commands/sr/<name>.md` already exists:
410
+ - If it exists: skip it — show `✓ Already installed: /sr:<name>`
411
+ - If it does NOT exist: copy from `setup-templates/commands/sr/<name>.md` — show `✓ Added /sr:<name> (was missing)`
412
+
379
413
  **4. Cleanup**
380
414
 
381
415
  Remove `setup-templates/` from `.claude/` (same as full wizard cleanup in Phase 5).
@@ -390,15 +424,31 @@ Then, based on `QS_IS_EXISTING_CODEBASE`:
390
424
  - **Existing codebase** (`true`): recommend `/sr:health-check`
391
425
  - **New project** (`false`): recommend `/sr:product-backlog`
392
426
 
427
+ If `QS_IS_RERUN=false`, display:
393
428
  ```
394
429
  ✅ Setup complete.
395
430
 
396
431
  Try your first command:
397
432
  > /sr:product-backlog
398
433
  ```
399
-
400
434
  (Replace `/sr:product-backlog` with `/sr:health-check` for existing codebases.)
401
435
 
436
+ If `QS_IS_RERUN=true`, display the gap-fill summary and stop:
437
+ ```
438
+ ✅ Re-run complete.
439
+
440
+ Commands status:
441
+ ✓ Already installed: /sr:<name>
442
+ ✓ Added /sr:<name> (was missing)
443
+ [... one line per command ...]
444
+
445
+ All commands are up to date.
446
+ ```
447
+ If all commands were already present, display:
448
+ ```
449
+ ✅ Re-run complete. All commands already installed — nothing to add.
450
+ ```
451
+
402
452
  Then stop. Do not execute Phase 1.
403
453
 
404
454
  ---
@@ -819,11 +869,15 @@ Wait for final confirmation.
819
869
 
820
870
  Read each template from `.claude/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.
821
871
 
872
+ **Provider detection (required before any file generation):** Read `$SPECRAILS_DIR/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"`.
873
+
822
874
  ### 4.1 Generate agents
823
875
 
824
- For each selected agent, read the template and generate the adapted version:
876
+ For each selected agent, read the template and generate the adapted version.
825
877
 
826
878
  **Template → Output mapping:**
879
+
880
+ **If `cli_provider == "claude"` (default):**
827
881
  - `setup-templates/agents/sr-architect.md` → `.claude/agents/sr-architect.md`
828
882
  - `setup-templates/agents/sr-developer.md` → `.claude/agents/sr-developer.md`
829
883
  - `setup-templates/agents/sr-reviewer.md` → `.claude/agents/sr-reviewer.md`
@@ -834,6 +888,17 @@ For each selected agent, read the template and generate the adapted version:
834
888
  - `setup-templates/agents/sr-backend-developer.md` → `.claude/agents/sr-backend-developer.md` (if backend layer)
835
889
  - `setup-templates/agents/sr-frontend-developer.md` → `.claude/agents/sr-frontend-developer.md` (if frontend layer)
836
890
 
891
+ **If `cli_provider == "codex"`:**
892
+ - `setup-templates/agents/sr-architect.md` → `.codex/agents/sr-architect.toml`
893
+ - `setup-templates/agents/sr-developer.md` → `.codex/agents/sr-developer.toml`
894
+ - `setup-templates/agents/sr-reviewer.md` → `.codex/agents/sr-reviewer.toml`
895
+ - `setup-templates/agents/sr-test-writer.md` → `.codex/agents/sr-test-writer.toml`
896
+ - `setup-templates/agents/sr-security-reviewer.md` → `.codex/agents/sr-security-reviewer.toml`
897
+ - `setup-templates/agents/sr-product-manager.md` → `.codex/agents/sr-product-manager.toml`
898
+ - `setup-templates/agents/sr-product-analyst.md` → `.codex/agents/sr-product-analyst.toml`
899
+ - `setup-templates/agents/sr-backend-developer.md` → `.codex/agents/sr-backend-developer.toml` (if backend layer)
900
+ - `setup-templates/agents/sr-frontend-developer.md` → `.codex/agents/sr-frontend-developer.toml` (if frontend layer)
901
+
837
902
  When generating each agent:
838
903
  1. Read the template
839
904
  2. Replace all `{{PLACEHOLDER}}` values with project-specific content:
@@ -849,19 +914,35 @@ When generating each agent:
849
914
  - `{{COMPETITIVE_LANDSCAPE}}` → competitors discovered in Phase 2
850
915
  - `{{KEY_FILE_PATHS}}` → important file paths detected in Phase 1
851
916
  - `{{WARNINGS}}` → project-specific warnings (from existing CLAUDE.md or detected)
852
- - `{{MEMORY_PATH}}` → agent memory directory path (e.g., `.claude/agent-memory/sr-<agent-name>/`)
917
+ - `{{MEMORY_PATH}}` → agent memory directory path (e.g., `$SPECRAILS_DIR/agent-memory/sr-<agent-name>/`)
853
918
  - `{{TECH_EXPERTISE}}` → detected languages, frameworks, and test frameworks from Phase 1
854
- - `{{LAYER_CLAUDE_MD_PATHS}}` → comma-separated paths to per-layer rules files (e.g., `.claude/rules/backend.md`, `.claude/rules/frontend.md`)
855
- - `{{SECURITY_EXEMPTIONS_PATH}}` → `.claude/security-exemptions.yaml`
856
- 3. Write the final file
919
+ - `{{LAYER_CLAUDE_MD_PATHS}}` → comma-separated paths to per-layer rules files (e.g., `$SPECRAILS_DIR/rules/backend.md`, `$SPECRAILS_DIR/rules/frontend.md`)
920
+ - `{{SECURITY_EXEMPTIONS_PATH}}` → `$SPECRAILS_DIR/security-exemptions.yaml`
921
+ 3. Write the final file in the format for the active provider:
922
+
923
+ **If `cli_provider == "claude"`:** Write as Markdown with YAML frontmatter — the template file as-is (frontmatter preserved).
924
+
925
+ **If `cli_provider == "codex"`:** Convert to TOML format:
926
+ - Extract YAML frontmatter fields: `name`, `description`, `model`
927
+ - Extract the body content (everything after the closing `---` of the frontmatter)
928
+ - Map the `model` field: `sonnet` → `codex-mini-latest`, `opus` → `o3`, `haiku` → `codex-mini-latest`
929
+ - Write a `.toml` file with this structure:
930
+ ```toml
931
+ name = "<name from frontmatter>"
932
+ description = "<description from frontmatter, escaped for TOML>"
933
+ model = "codex-mini-latest"
934
+ prompt = """
935
+ <body content after placeholder substitution>
936
+ """
937
+ ```
857
938
 
858
939
  ### 4.2 Generate personas
859
940
 
860
941
  If IS_OSS=true:
861
- 1. Copy `setup-templates/personas/the-maintainer.md` to `.claude/agents/personas/the-maintainer.md`
942
+ 1. Copy `setup-templates/personas/the-maintainer.md` to `$SPECRAILS_DIR/agents/personas/the-maintainer.md`
862
943
  2. Log: "Maintainer persona included"
863
944
  3. Set MAINTAINER_INCLUDED=true for use in template substitution
864
- 4. Set `{{MAINTAINER_PERSONA_LINE}}` = `- \`.claude/agents/personas/the-maintainer.md\` — "Kai" the Maintainer (open-source maintainer)`
945
+ 4. Set `{{MAINTAINER_PERSONA_LINE}}` = `- \`$SPECRAILS_DIR/agents/personas/the-maintainer.md\` — "Kai" the Maintainer (open-source maintainer)`
865
946
  5. Increment `{{PERSONA_COUNT}}` by 1 to account for the Maintainer
866
947
 
867
948
  If IS_OSS=false:
@@ -869,7 +950,7 @@ If IS_OSS=false:
869
950
 
870
951
  Then for each user-defined VPC persona from Phase 2.3:
871
952
 
872
- Write each persona to `.claude/agents/personas/`:
953
+ Write each persona to `$SPECRAILS_DIR/agents/personas/`:
873
954
  - Use the VPC personas generated in Phase 2
874
955
  - File naming: kebab-case of persona nickname (e.g., `the-developer.md`, `the-admin.md`)
875
956
 
@@ -965,6 +1046,10 @@ If no CLAUDE.md exists, generate one from the template. If one already exists, *
965
1046
 
966
1047
  ### 4.6 Generate settings
967
1048
 
1049
+ Read `.claude/setup-templates/.provider-detection.json` (written by `install.sh`) to determine `cli_provider` (`"claude"` or `"codex"`).
1050
+
1051
+ **If `cli_provider == "claude"` (default):**
1052
+
968
1053
  Create or merge `.claude/settings.json` with permissions for:
969
1054
  - All detected CI commands
970
1055
  - Git operations
@@ -972,12 +1057,35 @@ Create or merge `.claude/settings.json` with permissions for:
972
1057
  - GitHub CLI (if available)
973
1058
  - Language-specific tools (python, npm, cargo, go, etc.)
974
1059
 
1060
+ **If `cli_provider == "codex"`:**
1061
+
1062
+ 1. Read `setup-templates/settings/codex-config.toml`. Write it to `.codex/config.toml` as-is (no substitutions needed — the TOML is static).
1063
+
1064
+ 2. Read `setup-templates/settings/codex-rules.star`. Replace `{{CODEX_SHELL_RULES}}` with Starlark `prefix_rule(...)` lines for each detected tool allowance:
1065
+
1066
+ | Detected tool/command | Starlark rule |
1067
+ |----------------------|---------------|
1068
+ | OpenSpec CLI (`openspec`) | `prefix_rule(pattern=["openspec"], decision="allow")` |
1069
+ | Python (`python`, `pip`) | `prefix_rule(pattern=["python"], decision="allow")`<br>`prefix_rule(pattern=["pip"], decision="allow")` |
1070
+ | npm (`npm`) | `prefix_rule(pattern=["npm"], decision="allow")` |
1071
+ | Cargo (`cargo`) | `prefix_rule(pattern=["cargo"], decision="allow")` |
1072
+ | Go (`go`) | `prefix_rule(pattern=["go"], decision="allow")` |
1073
+ | Any detected CI command | `prefix_rule(pattern=["<cmd>"], decision="allow")` |
1074
+
1075
+ Write the rendered file to `.codex/rules/default.rules`.
1076
+
1077
+ ```bash
1078
+ mkdir -p .codex/rules
1079
+ ```
1080
+
1081
+ If `cli_provider` cannot be determined (file missing), fall back to `"claude"` behavior.
1082
+
975
1083
  ### 4.7 Initialize agent memory
976
1084
 
977
- Create memory directories for each installed agent:
1085
+ Create memory directories for each installed agent using the provider-aware base directory:
978
1086
 
979
1087
  ```bash
980
- mkdir -p .claude/agent-memory/sr-{agent-name}/
1088
+ mkdir -p $SPECRAILS_DIR/agent-memory/sr-{agent-name}/
981
1089
  ```
982
1090
 
983
1091
  Each gets an empty `MEMORY.md` that will be populated during usage.
@@ -1035,16 +1143,24 @@ Apply the user's choice.
1035
1143
  After cleanup, verify that only the intended files remain:
1036
1144
 
1037
1145
  ```bash
1038
- # These should exist (the actual system):
1146
+ # These should exist (the actual system) — use $SPECRAILS_DIR from .provider-detection.json:
1147
+ # If cli_provider == "claude":
1039
1148
  ls .claude/agents/sr-*.md
1040
1149
  ls .claude/agents/personas/*.md
1041
1150
  ls .claude/commands/sr/*.md
1042
1151
  ls .claude/rules/*.md
1043
1152
  ls .claude/agent-memory/
1044
1153
 
1154
+ # If cli_provider == "codex":
1155
+ ls .codex/agents/sr-*.toml
1156
+ ls .codex/agents/personas/*.md
1157
+ ls .codex/skills/sr-*/SKILL.md
1158
+ ls .codex/rules/*.md
1159
+ ls .codex/agent-memory/
1160
+
1045
1161
  # These should NOT exist (scaffolding):
1046
- # .claude/setup-templates/ — GONE
1047
- # .claude/commands/setup.md — GONE
1162
+ # $SPECRAILS_DIR/setup-templates/ — GONE
1163
+ # $SPECRAILS_DIR/commands/setup.md — GONE
1048
1164
  ```
1049
1165
 
1050
1166
  If any scaffolding artifact remains, remove it.
@@ -1059,20 +1175,28 @@ Display the complete installation summary:
1059
1175
  ### Agents Installed
1060
1176
  | Agent | File | Model |
1061
1177
  |-------|------|-------|
1178
+ [If cli_provider == "claude":]
1062
1179
  | sr-architect | .claude/agents/sr-architect.md | Sonnet |
1063
1180
  | sr-developer | .claude/agents/sr-developer.md | Sonnet |
1064
1181
  | sr-reviewer | .claude/agents/sr-reviewer.md | Sonnet |
1065
1182
  | sr-test-writer | .claude/agents/sr-test-writer.md | Sonnet |
1066
1183
  | sr-security-reviewer | .claude/agents/sr-security-reviewer.md | Sonnet |
1067
1184
  | sr-product-manager | .claude/agents/sr-product-manager.md | Opus |
1185
+ [If cli_provider == "codex":]
1186
+ | sr-architect | .codex/agents/sr-architect.toml | codex-mini-latest |
1187
+ | sr-developer | .codex/agents/sr-developer.toml | codex-mini-latest |
1188
+ | sr-reviewer | .codex/agents/sr-reviewer.toml | codex-mini-latest |
1189
+ | sr-test-writer | .codex/agents/sr-test-writer.toml | codex-mini-latest |
1190
+ | sr-security-reviewer | .codex/agents/sr-security-reviewer.toml | codex-mini-latest |
1191
+ | sr-product-manager | .codex/agents/sr-product-manager.toml | o3 |
1068
1192
 
1069
1193
  ### Personas Created
1070
1194
  | Persona | File | Source |
1071
1195
  |---------|------|--------|
1072
1196
  [If IS_OSS=true:]
1073
- | "Kai" — The Maintainer | .claude/agents/personas/sr-the-maintainer.md | Auto-included (OSS) |
1197
+ | "Kai" — The Maintainer | $SPECRAILS_DIR/agents/personas/sr-the-maintainer.md | Auto-included (OSS) |
1074
1198
  [For each user-generated persona:]
1075
- | "[Name]" — The [Role] | .claude/agents/personas/[name].md | Generated |
1199
+ | "[Name]" — The [Role] | $SPECRAILS_DIR/agents/personas/[name].md | Generated |
1076
1200
 
1077
1201
  ### Commands Installed
1078
1202
  | Command | File |
@@ -211,6 +211,30 @@ cat .specrails-version
211
211
 
212
212
  ## Troubleshooting
213
213
 
214
+ ### Claude Code authentication: OAuth vs API key
215
+
216
+ Claude Code supports two authentication modes:
217
+
218
+ - **OAuth** — the default for new installs (`claude auth login`). No API key in `claude config`.
219
+ - **API key** — explicit key set via `claude config set api_key <key>` or the `ANTHROPIC_API_KEY` environment variable.
220
+
221
+ The installer checks for an API key in `claude config` or `ANTHROPIC_API_KEY`. If you are using OAuth (the default), this check fails even though Claude Code is fully authenticated.
222
+
223
+ **Workaround:** pass `SPECRAILS_SKIP_PREREQS=1` to bypass the prerequisite gate:
224
+
225
+ ```bash
226
+ SPECRAILS_SKIP_PREREQS=1 npx specrails-core@latest init --root-dir .
227
+ ```
228
+
229
+ Or, if you prefer to authenticate with an API key explicitly:
230
+
231
+ ```bash
232
+ export ANTHROPIC_API_KEY=sk-ant-...
233
+ npx specrails-core@latest init --root-dir .
234
+ ```
235
+
236
+ `SPECRAILS_SKIP_PREREQS=1` skips all hard-exit prerequisite checks (Claude Code presence, API key, and tool availability). Use it only when you know the prerequisites are met.
237
+
214
238
  ### "This appears to be the specrails source repository"
215
239
 
216
240
  You're running the installer from inside the SpecRails repo. Run it from your target project instead: