specrails-core 1.7.2 → 2.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.
@@ -0,0 +1,193 @@
1
+ # Getting Started with SpecRails + Codex
2
+
3
+ This guide gets you running SpecRails using OpenAI Codex as your AI agent. If you are using Claude Code instead, see the [standard installation guide](installation.md).
4
+
5
+ > **Beta**: Codex support is available in SpecRails 1.x as a beta feature. Core Skills work out of the box. See [Codex vs Claude Code](codex-vs-claude-code.md) for what is and is not supported.
6
+
7
+ ---
8
+
9
+ ## Requirements
10
+
11
+ | Tool | Version | Notes |
12
+ |------|---------|-------|
13
+ | **Node.js** | 18+ | Required for the installer |
14
+ | **Codex CLI** | Latest | `npm i -g @openai/codex` |
15
+ | **Git** | Any | Your project must be a git repository |
16
+
17
+ Optional but recommended:
18
+
19
+ | Tool | Why |
20
+ |------|-----|
21
+ | **GitHub CLI** (`gh`) | Automatic PR creation and Issue integration |
22
+
23
+ ### Install Codex CLI
24
+
25
+ ```bash
26
+ npm i -g @openai/codex
27
+ ```
28
+
29
+ Verify the install:
30
+
31
+ ```bash
32
+ codex --version
33
+ ```
34
+
35
+ You need an OpenAI account with Codex access. Sign in with:
36
+
37
+ ```bash
38
+ codex auth login
39
+ ```
40
+
41
+ ---
42
+
43
+ ## Install SpecRails
44
+
45
+ Run the installer from inside your project directory:
46
+
47
+ ```bash
48
+ cd your-project
49
+ npx specrails-core@latest init --root-dir .
50
+ ```
51
+
52
+ The installer detects Codex CLI automatically and generates configuration in `.codex/` instead of `.claude/`.
53
+
54
+ ### Flags
55
+
56
+ | Flag | Effect |
57
+ |------|--------|
58
+ | `--root-dir <path>` | Target directory (default: current directory) |
59
+ | `--yes` / `-y` | Skip confirmation prompts |
60
+
61
+ ### What gets installed
62
+
63
+ ```
64
+ your-project/
65
+ ├── AGENTS.md # SpecRails agent instructions for Codex
66
+ └── .codex/
67
+ ├── skills/ # Workflow skills (/sr:*, /opsx:*)
68
+ ├── agents/ # Agent definitions (TOML)
69
+ ├── rules/ # Per-layer coding conventions
70
+ ├── agent-memory/ # Persistent agent memory
71
+ └── config.toml # Permissions and configuration
72
+ ```
73
+
74
+ ---
75
+
76
+ ## Configure with setup
77
+
78
+ After installation, open Codex and run the setup skill:
79
+
80
+ ```bash
81
+ codex
82
+ ```
83
+
84
+ Then invoke the setup skill:
85
+
86
+ ```
87
+ /setup
88
+ ```
89
+
90
+ Or run it non-interactively:
91
+
92
+ ```bash
93
+ codex exec "run /setup --yes"
94
+ ```
95
+
96
+ The wizard runs 5 phases:
97
+
98
+ | Phase | What happens |
99
+ |-------|-------------|
100
+ | **1. Analyze** | Detects your tech stack, architecture layers, and CI commands |
101
+ | **2. Personas** | Researches your domain and generates VPC user profiles |
102
+ | **3. Configure** | Asks about your backlog provider, git workflow, and agent selection |
103
+ | **4. Generate** | Fills all templates with your project-specific context |
104
+ | **5. Cleanup** | Removes setup files, leaving only your tailored workflow |
105
+
106
+ ---
107
+
108
+ ## Use your first skill
109
+
110
+ Once setup is complete, try generating a feature:
111
+
112
+ ```bash
113
+ codex
114
+ ```
115
+
116
+ ```
117
+ /sr:implement "add a health check endpoint"
118
+ ```
119
+
120
+ Or with a GitHub issue number:
121
+
122
+ ```
123
+ /sr:implement #42
124
+ ```
125
+
126
+ This runs the full SpecRails pipeline: Architect → Developer → Reviewer → PR.
127
+
128
+ ---
129
+
130
+ ## Codex Cloud (alternative)
131
+
132
+ If you prefer the web interface, SpecRails Skills also work in **Codex Cloud** at [chatgpt.com/codex](https://chatgpt.com/codex). Connect your repository and use Skills from the UI.
133
+
134
+ Note that Codex Cloud runs asynchronously — long-running skills like `/sr:implement` are well-suited to this environment.
135
+
136
+ ---
137
+
138
+ ## Verify
139
+
140
+ Check that everything installed correctly:
141
+
142
+ ```bash
143
+ # List generated agent configs
144
+ ls .codex/agents/
145
+
146
+ # List installed skills
147
+ ls .codex/skills/
148
+
149
+ # Check for unresolved placeholders (should return nothing)
150
+ grep -r '{{[A-Z_]*}}' .codex/agents/ .codex/skills/ 2>/dev/null
151
+
152
+ # Check the installed version
153
+ cat .specrails-version
154
+ ```
155
+
156
+ ---
157
+
158
+ ## Troubleshooting
159
+
160
+ ### "No AI CLI found"
161
+
162
+ Neither `claude` nor `codex` was found in your `PATH`. Install Codex CLI:
163
+
164
+ ```bash
165
+ npm i -g @openai/codex
166
+ ```
167
+
168
+ ### Codex CLI not detected
169
+
170
+ The installer looks for `codex` in your `PATH`. If it is installed but not found, verify:
171
+
172
+ ```bash
173
+ which codex
174
+ codex --version
175
+ ```
176
+
177
+ If Codex is installed via a custom path, pass the provider explicitly:
178
+
179
+ ```bash
180
+ CLI_PROVIDER=codex npx specrails-core@latest init --root-dir .
181
+ ```
182
+
183
+ ### Existing `.codex/` directory detected
184
+
185
+ The installer warns if SpecRails artifacts already exist. You can merge or abort to review manually.
186
+
187
+ ### Placeholders not resolved
188
+
189
+ If you see `{{PLACEHOLDER}}` in generated files, `/setup` did not complete. Re-run `/setup` or fill the values manually.
190
+
191
+ ---
192
+
193
+ [← Installation](installation.md) · [Codex vs Claude Code →](codex-vs-claude-code.md) · [CLI Reference →](cli-reference.md)
@@ -0,0 +1,177 @@
1
+ # Installation
2
+
3
+ Install SpecRails into any git repository in two steps: run the installer, then run `/setup` inside your AI CLI.
4
+
5
+ SpecRails supports both **Claude Code** and **OpenAI Codex**. The installer detects which CLI you have and configures accordingly. See [Codex vs Claude Code](codex-vs-claude-code.md) for a feature comparison.
6
+
7
+ ## Requirements
8
+
9
+ | Tool | Version | Notes |
10
+ |------|---------|-------|
11
+ | **Node.js** | 18+ | Required for the installer |
12
+ | **Claude Code** | Latest | Stable — [install guide](https://docs.anthropic.com/en/docs/claude-code) |
13
+ | **Codex CLI** | Latest | Beta — `npm i -g @openai/codex` |
14
+ | **Git** | Any | Your project must be a git repository |
15
+
16
+ You need at least one of Claude Code or Codex CLI. If both are installed, the installer uses Claude Code by default. Override with `CLI_PROVIDER=codex`.
17
+
18
+ Optional but recommended:
19
+
20
+ | Tool | Why |
21
+ |------|-----|
22
+ | **GitHub CLI** (`gh`) | Automatic PR creation and Issue integration |
23
+
24
+ ## Install
25
+
26
+ Run the installer from inside your project directory:
27
+
28
+ ```bash
29
+ cd your-project
30
+ npx specrails-core@latest init --root-dir .
31
+ ```
32
+
33
+ The installer copies agent templates, skills, and configuration files into `.claude/` (Claude Code) or `.codex/` (Codex). It does not modify your existing code.
34
+
35
+ ### Flags
36
+
37
+ | Flag | Effect |
38
+ |------|--------|
39
+ | `--root-dir <path>` | Target directory (default: current directory) |
40
+ | `--yes` / `-y` | Skip confirmation prompts |
41
+
42
+ You can also force a specific provider:
43
+
44
+ ```bash
45
+ CLI_PROVIDER=codex npx specrails-core@latest init --root-dir .
46
+ ```
47
+
48
+ ### What gets installed
49
+
50
+ **Claude Code:**
51
+
52
+ ```
53
+ your-project/
54
+ └── .claude/
55
+ ├── commands/setup.md # The /setup wizard
56
+ ├── skills/ # Workflow skills (/sr:*, /opsx:*)
57
+ ├── agents/ # Agent definitions
58
+ ├── rules/ # Per-layer coding conventions
59
+ ├── web-manager/ # Pipeline Monitor dashboard (optional)
60
+ └── settings.json # Permissions
61
+ ```
62
+
63
+ **Codex (beta):**
64
+
65
+ ```
66
+ your-project/
67
+ ├── AGENTS.md # SpecRails agent instructions for Codex
68
+ └── .codex/
69
+ ├── skills/ # Workflow skills (/sr:*, /opsx:*)
70
+ ├── agents/ # Agent definitions (TOML)
71
+ ├── rules/ # Per-layer coding conventions
72
+ └── config.toml # Permissions
73
+ ```
74
+
75
+ The installer also writes `.specrails-version` and `.specrails-manifest.json` to track the installed version.
76
+
77
+ ## Configure with /setup
78
+
79
+ After installation, open your AI CLI in your project and run the setup wizard:
80
+
81
+ ```bash
82
+ claude # Claude Code
83
+ # or
84
+ codex # Codex
85
+ ```
86
+
87
+ ```
88
+ /setup
89
+ ```
90
+
91
+ The wizard runs 5 phases:
92
+
93
+ | Phase | What happens |
94
+ |-------|-------------|
95
+ | **1. Analyze** | Detects your tech stack, architecture layers, and CI commands |
96
+ | **2. Personas** | Researches your domain and generates VPC user profiles |
97
+ | **3. Configure** | Asks about your backlog provider, git workflow, and agent selection |
98
+ | **4. Generate** | Fills all templates with your project-specific context |
99
+ | **5. Cleanup** | Removes setup files, leaving only your tailored workflow |
100
+
101
+ After setup, `.claude/` contains fully configured agents and commands ready to use. The `/setup` command removes itself — it only runs once.
102
+
103
+ ## Verify
104
+
105
+ Check that everything installed correctly:
106
+
107
+ ```bash
108
+ # List generated agents
109
+ ls .claude/agents/
110
+
111
+ # Check for unresolved placeholders (should return nothing)
112
+ grep -r '{{[A-Z_]*}}' .claude/agents/ .claude/commands/ .claude/rules/
113
+
114
+ # Check the installed version
115
+ cat .specrails-version
116
+ ```
117
+
118
+ ## Troubleshooting
119
+
120
+ ### "This appears to be the specrails source repository"
121
+
122
+ You ran the installer from inside the SpecRails source repo. Run it from your target project instead:
123
+
124
+ ```bash
125
+ cd /path/to/your-project
126
+ npx specrails-core@latest init --root-dir .
127
+ ```
128
+
129
+ ### Existing `.claude/` directory detected
130
+
131
+ The installer warns if SpecRails artifacts already exist. You can merge (install alongside existing files) or abort to review manually.
132
+
133
+ ### Placeholders not resolved
134
+
135
+ If you see `{{PLACEHOLDER}}` in generated files, the `/setup` wizard did not complete. Re-run `/setup` or fill the values manually.
136
+
137
+ ### "No Claude API key configured"
138
+
139
+ Claude Code supports two authentication modes:
140
+
141
+ - **OAuth** — the default for new installs (`claude auth login`). No API key appears in `claude config`.
142
+ - **API key** — explicit key set via `claude config set api_key <key>` or `ANTHROPIC_API_KEY`.
143
+
144
+ If you authenticated via OAuth, the installer's prerequisite check still fails even though Claude Code is working. Bypass it with:
145
+
146
+ ```bash
147
+ SPECRAILS_SKIP_PREREQS=1 npx specrails-core@latest init --root-dir .
148
+ ```
149
+
150
+ Or set an API key explicitly if you prefer:
151
+
152
+ ```bash
153
+ export ANTHROPIC_API_KEY=sk-ant-...
154
+ npx specrails-core@latest init --root-dir .
155
+ ```
156
+
157
+ ### Claude Code not found
158
+
159
+ Install Claude Code following [Anthropic's guide](https://docs.anthropic.com/en/docs/claude-code), then re-run the installer.
160
+
161
+ ### Codex CLI not found
162
+
163
+ Install Codex CLI and re-run:
164
+
165
+ ```bash
166
+ npm i -g @openai/codex
167
+ ```
168
+
169
+ Or force the provider if Codex is installed at a non-standard path:
170
+
171
+ ```bash
172
+ CLI_PROVIDER=codex npx specrails-core@latest init --root-dir .
173
+ ```
174
+
175
+ ---
176
+
177
+ [Quick Start →](quick-start.md) · [Getting Started (Codex) →](getting-started-codex.md) · [CLI Reference →](cli-reference.md)
@@ -0,0 +1,158 @@
1
+ # Quick Start
2
+
3
+ Get SpecRails running in your project in under 10 minutes.
4
+
5
+ ## Before you begin
6
+
7
+ You need:
8
+ - **Node.js 18+** — check with `node --version`
9
+ - **Claude Code** — install from [docs.anthropic.com/en/docs/claude-code](https://docs.anthropic.com/en/docs/claude-code)
10
+ - **A git repository** — your project must have a `.git` directory
11
+
12
+ Optional:
13
+ - **GitHub CLI** (`gh`) — enables automatic PR creation
14
+
15
+ ## Step 1: Install
16
+
17
+ From inside your project directory:
18
+
19
+ ```bash
20
+ npx specrails-core@latest init --root-dir .
21
+ ```
22
+
23
+ Expected output:
24
+
25
+ ```
26
+ ✓ Prerequisites checked
27
+ ✓ Templates installed → .claude/
28
+ ✓ Version tracked → .specrails-version
29
+ ```
30
+
31
+ This copies agent templates and commands into `.claude/`. Your existing code is not touched.
32
+
33
+ ## Step 2: Run the setup wizard
34
+
35
+ Open Claude Code in your project:
36
+
37
+ ```bash
38
+ claude
39
+ ```
40
+
41
+ Then run:
42
+
43
+ ```
44
+ /setup
45
+ ```
46
+
47
+ The wizard runs automatically and takes about 5 minutes. It analyzes your codebase and configures SpecRails for your specific project:
48
+
49
+ ```
50
+ Phase 1/5 Analyzing codebase...
51
+ → Detected: TypeScript, Express, PostgreSQL
52
+ → Found 3 architecture layers
53
+ → Identified CI commands: npm test, npm run lint
54
+
55
+ Phase 2/5 Generating user personas...
56
+ → Researching your domain
57
+ → Created 3 VPC profiles
58
+
59
+ Phase 3/5 Configuration...
60
+ → Backlog provider: GitHub Issues
61
+ → Git workflow: trunk-based
62
+
63
+ Phase 4/5 Generating files...
64
+ → sr-architect.md (adapted to your stack)
65
+ → sr-developer.md (knows your CI commands)
66
+ → sr-reviewer.md (runs your specific checks)
67
+ → 9 more agents
68
+
69
+ Phase 5/5 Cleanup complete. /setup removed.
70
+
71
+ ✓ SpecRails is ready. Run /sr:implement to start building.
72
+ ```
73
+
74
+ After setup, the `/setup` command is gone — it's a one-time wizard.
75
+
76
+ ## Step 3: Implement your first feature
77
+
78
+ Pick something small. Either reference a GitHub Issue or describe it in plain text:
79
+
80
+ ```
81
+ /sr:implement #42
82
+ ```
83
+
84
+ or:
85
+
86
+ ```
87
+ /sr:implement "add a health check endpoint to the API"
88
+ ```
89
+
90
+ The pipeline runs automatically:
91
+
92
+ ```
93
+ Phase 3a Architect designing...
94
+ → Design: GET /health endpoint + middleware
95
+ → Tasks: 3 steps
96
+
97
+ Phase 3b Developer implementing...
98
+ → src/routes/health.ts (created)
99
+ → src/middleware/health.ts (created)
100
+ → src/app.ts (modified)
101
+
102
+ Phase 3c Test Writer generating...
103
+ → tests/routes/health.test.ts (created)
104
+ → 5 tests, all passing
105
+
106
+ Phase 3d Doc Sync updating...
107
+ → CHANGELOG.md updated
108
+
109
+ Phase 4 Security Reviewer scanning...
110
+ → No critical findings
111
+
112
+ Phase 4b Reviewer running CI...
113
+ → ✓ lint ✓ typecheck ✓ tests
114
+
115
+ Phase 4b-conf Confidence: 91% — threshold met
116
+
117
+ PR #43 created: feat: add health check endpoint
118
+ ```
119
+
120
+ One command. The PR is ready for human review.
121
+
122
+ ## What's next?
123
+
124
+ **Explore the backlog:**
125
+
126
+ ```
127
+ /sr:product-backlog
128
+ ```
129
+
130
+ See your GitHub Issues ranked by persona fit and effort. The top 3 are safe to implement next.
131
+
132
+ **Generate new feature ideas:**
133
+
134
+ ```
135
+ /sr:update-product-driven-backlog
136
+ ```
137
+
138
+ The Product Manager researches your competitive landscape and creates well-formed GitHub Issues for new features.
139
+
140
+ **Run multiple features in parallel:**
141
+
142
+ ```
143
+ /sr:implement #42, #43, #44
144
+ ```
145
+
146
+ Each feature gets its own git worktree. Pipelines run concurrently and merge automatically.
147
+
148
+ **Ask why a decision was made:**
149
+
150
+ ```
151
+ /sr:why "why did we choose this database schema"
152
+ ```
153
+
154
+ Agents record their reasoning as they work. `/sr:why` searches those records in plain language.
155
+
156
+ ---
157
+
158
+ [← Installation](installation.md) · [CLI Reference →](cli-reference.md) · [FAQ →](faq.md)
package/docs/workflows.md CHANGED
@@ -294,6 +294,24 @@ Open-ended thinking mode. Use for brainstorming, investigating problems, or clar
294
294
  /opsx:explore
295
295
  ```
296
296
 
297
+ ### `/sr:opsx-diff` — Spec Change Diff
298
+
299
+ Visualize the before/after diff of an OpenSpec change — what behavioral requirements are being added, modified, or removed.
300
+
301
+ ```
302
+ /sr:opsx-diff <change-name>
303
+ /sr:opsx-diff my-feature --format json
304
+ /sr:opsx-diff my-feature --summary-only
305
+ ```
306
+
307
+ | Flag | Effect |
308
+ |------|--------|
309
+ | `<change-name>` | Kebab-case name of the change to diff (required) |
310
+ | `--format json` | Emit structured JSON instead of markdown |
311
+ | `--summary-only` | Show file-level summary only, skip inline line-level diff |
312
+
313
+ Compares the current specs against the named OpenSpec change. Useful during review to confirm a change matches its design intent before archiving.
314
+
297
315
  ### Typical OpenSpec flow
298
316
 
299
317
  ```
@@ -316,6 +334,53 @@ Or step by step:
316
334
 
317
335
  ---
318
336
 
337
+ ## `/sr:telemetry`
338
+
339
+ Inspect per-agent execution metrics: token usage, estimated API cost, run count, average duration, and success/failure rate.
340
+
341
+ ```
342
+ /sr:telemetry
343
+ /sr:telemetry --period today
344
+ /sr:telemetry --agent sr-developer
345
+ /sr:telemetry --format json
346
+ /sr:telemetry --save
347
+ ```
348
+
349
+ ### Flags
350
+
351
+ | Flag | Effect |
352
+ |------|--------|
353
+ | `--period <filter>` | Time window: `today`, `week` (default), or `all` |
354
+ | `--agent <name>` | Focus on a single agent (e.g. `sr-developer`) |
355
+ | `--format <fmt>` | Output format: `markdown` (default) or `json` |
356
+ | `--save` | Write a snapshot to `.claude/telemetry/` after display |
357
+
358
+ Reads Claude CLI JSONL session logs and agent-memory files to produce a cost dashboard with trend indicators and optimization recommendations.
359
+
360
+ ---
361
+
362
+ ## `/sr:merge-resolve`
363
+
364
+ Resolve git conflict markers using AI-powered context analysis.
365
+
366
+ ```
367
+ /sr:merge-resolve
368
+ /sr:merge-resolve --files src/api/routes.ts src/db/schema.ts
369
+ /sr:merge-resolve --context openspec/changes/
370
+ ```
371
+
372
+ ### Flags
373
+
374
+ | Flag | Effect |
375
+ |------|--------|
376
+ | `--files <paths>` | Explicit file paths or globs to process (default: auto-detect from working tree) |
377
+ | `--context <dir>` | Directory of OpenSpec context bundles (default: `openspec/changes/`) |
378
+ | `--threshold <n>` | Minimum confidence threshold to auto-apply a resolution |
379
+
380
+ For each conflict block, the command reads the OpenSpec context bundles from the features that produced the conflict, infers the correct resolution, and writes it in place. Conflicts it cannot safely resolve are left with clean markers for manual review. Always review the result before committing.
381
+
382
+ ---
383
+
319
384
  ## `/sr:retry`
320
385
 
321
386
  Resume a failed `/sr:implement` run from the last successful phase — without restarting from scratch.