specrails-core 0.7.1 → 1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Javier Pulido
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,110 +1,105 @@
1
- # specrails
1
+ # specrails-core
2
2
 
3
- **Agent Workflow System installer for Claude Code.**
3
+ [![npm version](https://img.shields.io/npm/v/specrails-core.svg)](https://www.npmjs.com/package/specrails-core)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
+ [![Node.js](https://img.shields.io/badge/node-%3E%3D18-brightgreen.svg)](https://nodejs.org)
4
6
 
5
- Install a complete product-driven development workflow into any repository: specialized AI agents, orchestration commands, VPC-based product discovery, and per-layer coding conventions — all adapted to your codebase automatically.
7
+ **AI agent workflow system for [Claude Code](https://claude.ai/code).** Installs a complete product-driven development pipeline into any repository — 12 specialized agents, orchestration commands, persona-based product discovery, and per-layer coding conventions — all generated specifically for your codebase.
6
8
 
7
- ## What it does
8
-
9
- specrails gives your project a team of specialized AI agents that work together through a structured pipeline:
10
-
11
- ```
12
- Product Discovery → Architecture → Implementation → Review → Ship
13
- (sr-product-manager) (sr-architect) (sr-developer) (sr-reviewer) (PR)
9
+ ```bash
10
+ npx specrails-core@latest init --root-dir <your-project>
14
11
  ```
15
12
 
16
- Every artifact — agents, commands, rules, personas — is generated specifically for your project by analyzing your actual codebase, tech stack, and target users. Not generic templates: fully contextualized to your architecture, CI pipeline, and coding conventions.
13
+ ---
17
14
 
18
- ## What gets installed
15
+ ## The pipeline
19
16
 
20
- | Category | Files | Purpose |
21
- |----------|-------|---------|
22
- | **Agents** | `.claude/agents/*.md` | 12 specialized AI agents (sr-architect, sr-developer, sr-backend-developer, sr-frontend-developer, sr-reviewer, sr-backend-reviewer, sr-frontend-reviewer, sr-product-manager, sr-product-analyst, sr-test-writer, sr-security-reviewer, sr-doc-sync) |
23
- | **Personas** | `.claude/agents/personas/*.md` | Value Proposition Canvas profiles for your target users, generated from competitive research |
24
- | **Commands** | `.claude/commands/sr/*.md` | Workflow orchestrators (`/sr:implement`, `/sr:product-backlog`, `/sr:update-product-driven-backlog`) |
25
- | **Rules** | `.claude/rules/*.md` | Per-layer coding conventions, loaded conditionally by file path |
26
- | **Memory** | `.claude/agent-memory/` | Persistent knowledge directories — agents learn across sessions |
27
- | **Config** | `.claude/settings.json`, `CLAUDE.md` | Permissions, project context, architecture reference |
17
+ ```
18
+ Product Discovery → Architecture → Implementation → Review → Ship
19
+ (sr-product-manager) (sr-architect) (sr-developer) (sr-reviewer) (PR)
20
+ ```
28
21
 
29
- ## How it works
22
+ One command runs the full cycle:
30
23
 
31
- Installation happens in two steps — a shell script for scaffolding, then Claude for the intelligent parts.
24
+ ```
25
+ /sr:implement #85, #71 # implement GitHub Issues
26
+ /sr:implement "add dark mode" # implement from description
27
+ /sr:implement UI, Analytics # explore areas, pick the best ideas
28
+ ```
32
29
 
33
- ### Step 1: Install
30
+ Multiple features run in parallel using git worktrees. Single features run sequentially.
34
31
 
35
- **Option A — npx (recommended)**
32
+ ---
36
33
 
37
- ```bash
38
- npx specrails-core@latest init --root-dir <your-project>
39
- ```
34
+ ## Quick start
40
35
 
41
- **Option Bgit clone**
36
+ **Step 1Install into your project**
42
37
 
43
38
  ```bash
44
- git clone https://github.com/fjpulidop/specrails-core.git
45
- ./specrails-core/install.sh --root-dir <your-project>
39
+ npx specrails-core@latest init --root-dir /path/to/your/repo
46
40
  ```
47
41
 
48
- The installer:
42
+ The installer scaffolds temporary setup files into `.claude/` and checks prerequisites (Claude Code, git, npm, GitHub CLI).
49
43
 
50
- 1. **Checks prerequisites**git, Claude Code CLI, npm, OpenSpec CLI, GitHub CLI
51
- 2. **Offers to install missing tools** — npm via nvm, OpenSpec via npm
52
- 3. **Detects existing setup** — warns if `.claude/` or `openspec/` already exist
53
- 4. **Scaffolds temporary files** — copies templates and the `/setup` command into `.claude/`
54
-
55
- ### Step 2: Setup (inside Claude Code)
44
+ **Step 2Run the setup wizard inside Claude Code**
56
45
 
57
46
  ```bash
58
- claude # open Claude Code in your repo
59
- > /setup # run the setup wizard
47
+ cd /path/to/your/repo
48
+ claude # open Claude Code
49
+ > /setup # run the interactive setup wizard
60
50
  ```
61
51
 
62
- Claude runs an interactive 5-phase wizard:
63
-
64
- | Phase | What happens | Interaction |
65
- |-------|-------------|-------------|
66
- | **1. Codebase Analysis** | Reads your repo structure, detects stack, layers, CI commands, and coding conventions | Confirm or modify detected architecture |
67
- | **2. User Personas** | Asks who your target users are, researches the competitive landscape online, generates full VPC personas | Describe your users, approve generated personas |
68
- | **3. Configuration** | Choose backlog provider (GitHub Issues / JIRA / none), access mode (read/write or read-only), git workflow (auto or manual), agents, and commands | Select options |
69
- | **4. File Generation** | Fills all templates with your project's context and writes final files | Automatic |
70
- | **5. Cleanup** | Removes scaffolding (`/setup` command, templates), adds `specrails/` to `.gitignore` | Confirm cleanup |
52
+ Claude runs a 5-phase wizard that reads your actual codebase and generates everything tailored to your stack:
71
53
 
72
- After setup, the scaffolding self-destructs — only the final, project-specific files remain.
54
+ | Phase | What happens |
55
+ |-------|-------------|
56
+ | **1. Codebase Analysis** | Detects your stack, layers, CI commands, and coding conventions |
57
+ | **2. User Personas** | Researches your competitive landscape, generates VPC personas |
58
+ | **3. Configuration** | Choose backlog (GitHub Issues / JIRA / none), git workflow, agents |
59
+ | **4. File Generation** | Writes all agents, commands, rules — fully contextualized |
60
+ | **5. Cleanup** | Self-destructs scaffolding, only final files remain |
73
61
 
74
- ## Prerequisites
75
-
76
- | Tool | Required | Purpose |
77
- |------|----------|---------|
78
- | **Git** | Yes | Repository detection |
79
- | **Claude Code** | Yes | AI agent runtime — [install](https://docs.anthropic.com/en/docs/claude-code) |
80
- | **npm** | Recommended | Needed to install OpenSpec CLI |
81
- | **OpenSpec CLI** | Recommended | Spec-driven design workflow (`/opsx:ff`, `/opsx:apply`) |
82
- | **GitHub CLI** (`gh`) | Optional | Backlog sync to GitHub Issues, PR creation |
83
- | **JIRA CLI** (`jira`) | Optional | Backlog sync to JIRA (alternative to GitHub Issues) |
62
+ ---
84
63
 
85
- The installer will check for each tool and offer to install missing ones.
64
+ ## What gets installed
86
65
 
87
- > **Note:** You only need one backlog provider — GitHub Issues or JIRA. The `/setup` wizard asks which one you use. If you don't use either, backlog commands are skipped but `/sr:implement "description"` still works.
66
+ | Category | Location | Description |
67
+ |----------|----------|-------------|
68
+ | **Agents** | `.claude/agents/*.md` | 12 specialized AI agents |
69
+ | **Personas** | `.claude/agents/personas/*.md` | VPC user profiles from competitive research |
70
+ | **Commands** | `.claude/commands/sr/*.md` | `/sr:implement`, `/sr:product-backlog`, `/sr:update-product-driven-backlog` |
71
+ | **Rules** | `.claude/rules/*.md` | Per-layer coding conventions, loaded by file path |
72
+ | **Memory** | `.claude/agent-memory/` | Persistent agent knowledge across sessions |
73
+ | **Config** | `.claude/settings.json`, `CLAUDE.md` | Permissions, project context, architecture reference |
88
74
 
89
- ## Usage after installation
75
+ ---
90
76
 
91
- Once setup is complete, you have three main commands:
77
+ ## The 12 agents
92
78
 
93
- ### `/sr:implement` Build features
79
+ | Agent | Model | Role |
80
+ |-------|-------|------|
81
+ | **sr-architect** | Sonnet | Designs features — proposal, technical design, task breakdown |
82
+ | **sr-developer** | Sonnet | Full-stack implementation from architect artifacts |
83
+ | **sr-backend-developer** | Sonnet | Backend-specialized implementation |
84
+ | **sr-frontend-developer** | Sonnet | Frontend-specialized implementation |
85
+ | **sr-reviewer** | Sonnet | Final quality gate — runs CI, fixes issues, records learnings |
86
+ | **sr-backend-reviewer** | Sonnet | API design, database patterns, performance review |
87
+ | **sr-frontend-reviewer** | Sonnet | UX patterns, accessibility, component design review |
88
+ | **sr-test-writer** | Sonnet | Generates unit, integration, and e2e tests |
89
+ | **sr-security-reviewer** | Sonnet | Secrets detection, OWASP checks, dependency audit |
90
+ | **sr-doc-sync** | Sonnet | Changelogs, READMEs, API docs after every change |
91
+ | **sr-product-manager** | Opus | Competitive analysis, VPC evaluation, feature ideation |
92
+ | **sr-product-analyst** | Haiku | Read-only backlog analysis and prioritization |
94
93
 
95
- The full pipeline: architect designs, developer implements, reviewer validates, then ships a PR.
94
+ The `/sr:implement` pipeline routes tasks to the right agent automatically based on layer tags.
96
95
 
97
- ```
98
- /sr:implement #85, #71 # implement specific GitHub Issues
99
- /sr:implement "add dark mode" # implement from a text description
100
- /sr:implement UI, Analytics # explore areas and pick the best ideas
101
- ```
96
+ ---
102
97
 
103
- Handles 1 to N features. Single features run sequentially; multiple features run in parallel using git worktrees.
98
+ ## Product discovery commands
104
99
 
105
- ### `/sr:product-backlog` — View prioritized backlog
100
+ ### `/sr:product-backlog` — Prioritized backlog
106
101
 
107
- Reads GitHub Issues labeled `product-driven-backlog`, sorts by VPC persona score, and recommends the top 3 for the next sprint.
102
+ Reads GitHub Issues labeled `product-driven-backlog`, scores them against your VPC personas, and recommends the top 3 for the next sprint.
108
103
 
109
104
  ```
110
105
  /sr:product-backlog # show all areas
@@ -113,35 +108,18 @@ Reads GitHub Issues labeled `product-driven-backlog`, sorts by VPC persona score
113
108
 
114
109
  ### `/sr:update-product-driven-backlog` — Discover new features
115
110
 
116
- Runs product discovery using your VPC personas. Analyzes the codebase, evaluates ideas against each persona's jobs/pains/gains, and creates GitHub Issues for the best ones.
111
+ Analyzes your codebase against each persona's jobs/pains/gains, generates new feature ideas, and creates GitHub Issues for the best ones.
117
112
 
118
113
  ```
119
- /sr:update-product-driven-backlog # explore all areas
120
- /sr:update-product-driven-backlog Analytics # focus on one area
114
+ /sr:update-product-driven-backlog # explore all areas
115
+ /sr:update-product-driven-backlog Analytics # focus on one area
121
116
  ```
122
117
 
123
- ## The agents
118
+ ---
124
119
 
125
- | Agent | Model | Role |
126
- |-------|-------|------|
127
- | **sr-architect** | Sonnet | Designs features: creates proposal, technical design, task breakdown, and context bundles via OpenSpec |
128
- | **sr-developer** | Sonnet | Implements features: reads the architect's artifacts and writes production code across all layers |
129
- | **sr-backend-developer** | Sonnet | Specialized backend implementation (lighter prompt, backend-only CI) |
130
- | **sr-frontend-developer** | Sonnet | Specialized frontend implementation (lighter prompt, frontend-only CI) |
131
- | **sr-reviewer** | Sonnet | Final quality gate: runs exact CI checks, fixes issues, records learnings for future developers |
132
- | **sr-backend-reviewer** | Sonnet | Backend-focused code review: API design, database patterns, performance |
133
- | **sr-frontend-reviewer** | Sonnet | Frontend-focused code review: UX patterns, accessibility, component design |
134
- | **sr-test-writer** | Sonnet | Generates tests: unit, integration, and e2e tests using your project's test framework |
135
- | **sr-security-reviewer** | Sonnet | Security scanning: secrets detection, OWASP checks, dependency vulnerabilities |
136
- | **sr-doc-sync** | Sonnet | Documentation sync: updates changelogs, READMEs, and API docs after changes |
137
- | **sr-product-manager** | Opus | Product discovery: competitive analysis, VPC evaluation, feature ideation |
138
- | **sr-product-analyst** | Haiku | Read-only backlog analysis: prioritization, gap analysis, reporting |
139
-
140
- The `/sr:implement` pipeline automatically routes tasks to the right developer agent based on layer tags in the task breakdown.
120
+ ## Value Proposition Canvas scoring
141
121
 
142
- ## Value Proposition Canvas (VPC)
143
-
144
- Every feature idea is evaluated against your project's user personas using the VPC framework:
122
+ Every feature is evaluated against your user personas before implementation. Features score 0–5 per persona based on jobs-to-be-done, pains, and gains — ranked by score / effort ratio. Product decisions stay grounded in real user needs.
145
123
 
146
124
  ```
147
125
  +-----------------------------+ +-----------------------------+
@@ -153,52 +131,28 @@ Every feature idea is evaluated against your project's user personas using the V
153
131
  +-----------------------------+ +-----------------------------+
154
132
  ```
155
133
 
156
- Each persona scores features 0-5 based on how well they address their specific jobs, pains, and gains. Features are ranked by total persona score / effort ratio. This grounds every product decision in real user needs rather than gut feeling.
134
+ ---
135
+
136
+ ## Prerequisites
157
137
 
158
- ## Project structure
138
+ | Tool | Required | Purpose |
139
+ |------|----------|---------|
140
+ | **Claude Code** | Yes | AI agent runtime — [install](https://docs.anthropic.com/en/docs/claude-code) |
141
+ | **Git** | Yes | Repository detection |
142
+ | **npm** | Recommended | Install OpenSpec CLI |
143
+ | **OpenSpec CLI** | Recommended | Spec-driven design workflow |
144
+ | **GitHub CLI** (`gh`) | Optional | Backlog sync and PR creation |
145
+ | **JIRA CLI** | Optional | JIRA as backlog alternative |
159
146
 
160
- ```
161
- specrails/
162
- ├── install.sh # Step 1: shell installer
163
- ├── README.md # This file
164
- ├── commands/
165
- │ └── setup.md # Step 2: Claude Code /setup wizard
166
- ├── templates/ # Structural references for file generation
167
- │ ├── agents/
168
- │ │ ├── sr-architect.md # Design & task breakdown agent
169
- │ │ ├── sr-developer.md # Full-stack implementation agent
170
- │ │ ├── sr-backend-developer.md # Backend-specialized agent
171
- │ │ ├── sr-frontend-developer.md # Frontend-specialized agent
172
- │ │ ├── sr-reviewer.md # CI/CD quality gate agent
173
- │ │ ├── sr-backend-reviewer.md # Backend code review agent
174
- │ │ ├── sr-frontend-reviewer.md # Frontend code review agent
175
- │ │ ├── sr-test-writer.md # Test generation agent
176
- │ │ ├── sr-security-reviewer.md # Security scanning agent
177
- │ │ ├── sr-doc-sync.md # Documentation sync agent
178
- │ │ ├── sr-product-manager.md # Product discovery agent
179
- │ │ └── sr-product-analyst.md # Read-only analysis agent
180
- │ ├── commands/
181
- │ │ └── sr/
182
- │ │ ├── implement.md # Implementation pipeline orchestrator
183
- │ │ ├── product-backlog.md # Backlog viewer with VPC scoring
184
- │ │ └── update-product-driven-backlog.md # Product discovery & issue sync
185
- │ ├── personas/
186
- │ │ └── persona.md # VPC persona template
187
- │ ├── rules/
188
- │ │ └── layer.md # Per-layer convention template
189
- │ ├── claude-md/
190
- │ │ └── root.md # Root CLAUDE.md template
191
- │ └── settings/
192
- │ └── settings.json # Permission template
193
- └── prompts/
194
- ├── analyze-codebase.md # Guide for codebase analysis
195
- ├── generate-personas.md # Guide for VPC persona generation
196
- └── infer-conventions.md # Guide for convention detection
197
- ```
147
+ The installer checks for each tool and offers to install missing ones automatically.
148
+
149
+ > You only need one backlog provider. If you use neither, `/sr:implement "description"` still works.
150
+
151
+ ---
198
152
 
199
153
  ## Supported stacks
200
154
 
201
- specrails is stack-agnostic. The `/setup` wizard detects and adapts to whatever you're using:
155
+ specrails-core is stack-agnostic the setup wizard reads your actual files and generates accurate conventions, not generic templates.
202
156
 
203
157
  - **Backend**: Python/FastAPI, Node/Express, Go/Gin, Rust/Actix, Java/Spring, Ruby/Rails, .NET
204
158
  - **Frontend**: React, Vue, Angular, Svelte, Next.js, Nuxt
@@ -206,39 +160,37 @@ specrails is stack-agnostic. The `/setup` wizard detects and adapts to whatever
206
160
  - **CI/CD**: GitHub Actions, GitLab CI, Jenkins, Makefile
207
161
  - **Testing**: pytest, vitest, jest, go test, cargo test, rspec
208
162
 
209
- The setup wizard reads your actual CI config, dependency files, and source code to generate accurate conventions — not guesses.
163
+ ---
210
164
 
211
165
  ## Design principles
212
166
 
213
- 1. **Two-step install**: Shell for prerequisites, Claude for intelligence. No API keys needed beyond Claude Code auth.
214
- 2. **Self-cleaning**: All scaffolding artifacts are removed after setup. Only final files remain.
215
- 3. **Context-first**: Every generated file references real paths, real patterns, and real CI commands from your codebase.
216
- 4. **Persona-driven**: Product decisions are grounded in researched user personas, not assumptions.
217
- 5. **Institutional memory**: Agents learn across sessions via persistent memory directories. The reviewer's learnings feed back to developers.
218
- 6. **Parallel-safe**: Multiple features can be implemented simultaneously using git worktrees with automatic merge.
167
+ 1. **Two-step install** Shell handles prerequisites, Claude handles intelligence. No API keys beyond Claude Code auth.
168
+ 2. **Self-cleaning** All scaffolding removed after setup. Only final, project-specific files remain.
169
+ 3. **Context-first** Every generated file uses your real paths, patterns, and CI commands.
170
+ 4. **Persona-driven** Product decisions grounded in researched user personas, not assumptions.
171
+ 5. **Institutional memory** Agents learn across sessions. Reviewer learnings feed back to future developers.
172
+ 6. **Parallel-safe** Multiple features implemented simultaneously via git worktrees with automatic merge.
173
+
174
+ ---
219
175
 
220
176
  ## FAQ
221
177
 
222
178
  **Can I customize the agents after installation?**
223
- Yes. The generated files in `.claude/` are yours to edit. They're plain markdown — modify agent personalities, adjust CI commands, add new rules, or create new personas.
179
+ Yes. Files in `.claude/` are plain markdown — edit agent personalities, adjust CI commands, add rules, create personas.
224
180
 
225
181
  **Can I re-run setup?**
226
- The `/setup` command deletes itself after completion. To re-run, execute `install.sh` again to re-scaffold, then run `/setup`.
182
+ Run `npx specrails-core@latest init --root-dir <path>` again to re-scaffold, then `/setup`.
227
183
 
228
184
  **Does this work without OpenSpec?**
229
- Partially. The `/sr:implement` command and sr-architect agent rely on OpenSpec for structured design artifacts. Without it, you can still use the product discovery commands and individual agents directly.
185
+ Partially. `/sr:implement` and sr-architect use OpenSpec for structured design artifacts. Product discovery commands and individual agents work without it.
230
186
 
231
187
  **Does this work without GitHub CLI?**
232
- Yes, with limitations. If you use GitHub Issues as your backlog provider, `gh` is needed for backlog commands. But you can use JIRA instead, or skip backlog commands entirely. The `/sr:implement` command still works with text descriptions — it just skips PR creation and tells you to create it manually.
233
-
234
- **Can I use JIRA instead of GitHub Issues?**
235
- Yes. During `/setup` Phase 3, choose "JIRA" as your backlog provider. If the JIRA CLI isn't installed, the wizard offers to install it (go-jira via brew, or REST API mode with no CLI needed). You'll also choose whether access is read & write (create tickets, add comments on completion) or read-only (read tickets for context but never modify JIRA).
188
+ Yes. If you use GitHub Issues, `gh` is needed for backlog commands. Otherwise use JIRA, skip backlog entirely, or use `/sr:implement "description"` without a PR step.
236
189
 
237
- **Can I skip automatic git operations?**
238
- Yes. During `/setup` Phase 3, choose "Manual" for the git workflow. The pipeline will still architect, develop, and review but it stops after review and shows you a summary of all changes. You handle branching, committing, and PRs yourself.
190
+ **How much does it cost?**
191
+ The sr-product-manager (Opus) is the most expensive agent. All others use Sonnet or Haiku. A full `/sr:implement` cycle for one feature typically costs a few dollars through Claude Code.
239
192
 
240
- **How much does it cost to run?**
241
- Depends on usage. The sr-product-manager agent uses Opus (most capable, most expensive) for deep product thinking. All other agents use Sonnet or Haiku. A full `/sr:implement` cycle for one feature typically costs a few dollars in API usage through Claude Code.
193
+ ---
242
194
 
243
195
  ## License
244
196
 
package/bin/doctor.sh ADDED
@@ -0,0 +1,118 @@
1
+ #!/bin/bash
2
+ # specrails doctor — health check for specrails-core installations
3
+ # Usage: specrails doctor
4
+ # Exit 0 if all checks pass, 1 if any check fails.
5
+
6
+ set -uo pipefail
7
+
8
+ # Colors
9
+ GREEN='\033[0;32m'
10
+ RED='\033[0;31m'
11
+ NC='\033[0m'
12
+ BOLD='\033[1m'
13
+
14
+ PASS=0
15
+ FAIL=0
16
+ RESULTS=()
17
+
18
+ pass() { RESULTS+=("$(printf "${GREEN}✅${NC} $1")"); PASS=$((PASS + 1)); }
19
+ fail() { RESULTS+=("$(printf "${RED}❌${NC} $1\n Fix: $2")"); FAIL=$((FAIL + 1)); }
20
+
21
+ echo ""
22
+ echo -e "${BOLD}specrails doctor${NC}"
23
+ echo ""
24
+
25
+ # Determine project root (current working directory)
26
+ PROJECT_ROOT="${PWD}"
27
+
28
+ # ─────────────────────────────────────────────
29
+ # Check 1: Claude Code CLI
30
+ # ─────────────────────────────────────────────
31
+ if CLAUDE_PATH=$(command -v claude 2>/dev/null); then
32
+ pass "Claude Code CLI: found (${CLAUDE_PATH})"
33
+ else
34
+ fail "Claude Code CLI: not found" "Install Claude Code: https://claude.ai/download"
35
+ fi
36
+
37
+ # ─────────────────────────────────────────────
38
+ # Check 2: Claude API key
39
+ # ─────────────────────────────────────────────
40
+ if command -v claude &>/dev/null; then
41
+ if claude config list 2>/dev/null | grep -q "api_key" || [[ -n "${ANTHROPIC_API_KEY:-}" ]]; then
42
+ pass "API key: configured"
43
+ else
44
+ fail "API key: not configured" "Run: claude config set api_key <your-key> | Get a key: https://console.anthropic.com/"
45
+ fi
46
+ fi
47
+
48
+ # ─────────────────────────────────────────────
49
+ # Check 3: Agent files present
50
+ # ─────────────────────────────────────────────
51
+ AGENTS_DIR="${PROJECT_ROOT}/agents"
52
+ if [[ -d "${AGENTS_DIR}" ]]; then
53
+ AGENT_COUNT=$(find "${AGENTS_DIR}" -name "AGENTS.md" 2>/dev/null | wc -l | tr -d ' ')
54
+ if [[ "${AGENT_COUNT}" -ge 1 ]]; then
55
+ AGENT_NAMES=$(find "${AGENTS_DIR}" -name "AGENTS.md" -exec dirname {} \; | xargs -I{} basename {} | tr '\n' ', ' | sed 's/,$//')
56
+ pass "Agent files: ${AGENT_COUNT} agent(s) found (${AGENT_NAMES})"
57
+ else
58
+ fail "Agent files: agents/ exists but no AGENTS.md found" "Run specrails-core init to set up agents"
59
+ fi
60
+ else
61
+ fail "Agent files: agents/ directory not found" "Run specrails-core init to set up agents"
62
+ fi
63
+
64
+ # ─────────────────────────────────────────────
65
+ # Check 4: CLAUDE.md present
66
+ # ─────────────────────────────────────────────
67
+ if [[ -f "${PROJECT_ROOT}/CLAUDE.md" ]]; then
68
+ pass "CLAUDE.md: present"
69
+ else
70
+ fail "CLAUDE.md: missing" "Run /setup inside Claude Code to regenerate"
71
+ fi
72
+
73
+ # ─────────────────────────────────────────────
74
+ # Check 5: Git initialized
75
+ # ─────────────────────────────────────────────
76
+ if [[ -d "${PROJECT_ROOT}/.git" ]]; then
77
+ pass "Git: initialized"
78
+ else
79
+ fail "Git: not a git repository" "Initialize with: git init"
80
+ fi
81
+
82
+ # ─────────────────────────────────────────────
83
+ # Check 6: npm present
84
+ # ─────────────────────────────────────────────
85
+ if NPM_VERSION=$(npm --version 2>/dev/null); then
86
+ pass "npm: found (v${NPM_VERSION})"
87
+ else
88
+ fail "npm: not found" "Install npm: https://docs.npmjs.com/downloading-and-installing-node-js-and-npm"
89
+ fi
90
+
91
+ # ─────────────────────────────────────────────
92
+ # Output results
93
+ # ─────────────────────────────────────────────
94
+ for line in "${RESULTS[@]}"; do
95
+ echo -e "${line}"
96
+ done
97
+
98
+ echo ""
99
+
100
+ if [[ "${FAIL}" -eq 0 ]]; then
101
+ TOTAL=$((PASS + FAIL))
102
+ echo -e "All ${TOTAL} checks passed. Run ${BOLD}/sr:product-backlog${NC} to get started."
103
+ else
104
+ echo "${FAIL} check(s) failed."
105
+ fi
106
+
107
+ # ─────────────────────────────────────────────
108
+ # Append to ~/.specrails/doctor.log
109
+ # ─────────────────────────────────────────────
110
+ LOG_DIR="${HOME}/.specrails"
111
+ mkdir -p "${LOG_DIR}"
112
+ TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%SZ" 2>/dev/null || date -u)
113
+ TOTAL=$((PASS + FAIL))
114
+ echo "${TIMESTAMP} checks=${TOTAL} passed=${PASS} failed=${FAIL}" >> "${LOG_DIR}/doctor.log"
115
+
116
+ echo ""
117
+
118
+ exit $([[ "${FAIL}" -eq 0 ]] && echo 0 || echo 1)
@@ -7,6 +7,7 @@ const ROOT = resolve(__dirname, "..");
7
7
  const COMMANDS = {
8
8
  init: "install.sh",
9
9
  update: "update.sh",
10
+ doctor: "bin/doctor.sh",
10
11
  };
11
12
 
12
13
  const args = process.argv.slice(2);
@@ -18,6 +19,7 @@ if (!subcommand) {
18
19
  Usage:
19
20
  specrails-core init [--root-dir <path>] Install into a repository
20
21
  specrails-core update [--only <component>] Update an existing installation
22
+ specrails-core doctor Run health checks
21
23
 
22
24
  More info: https://github.com/fjpulidop/specrails-core`);
23
25
  process.exit(0);
@@ -27,7 +29,7 @@ const script = COMMANDS[subcommand];
27
29
 
28
30
  if (!script) {
29
31
  console.error(`Unknown command: ${subcommand}\n`);
30
- console.error("Available commands: init, update");
32
+ console.error("Available commands: init, update, doctor");
31
33
  process.exit(1);
32
34
  }
33
35
 
@@ -0,0 +1,62 @@
1
+ # Doctor: specrails Health Check
2
+
3
+ Run the specrails health check to validate that all prerequisites are correctly configured for this repository.
4
+
5
+ ---
6
+
7
+ ## What it checks
8
+
9
+ | Check | Pass condition |
10
+ |-------|---------------|
11
+ | Claude Code CLI | `claude` binary found in PATH |
12
+ | Claude API key | `claude config list` shows a key OR `ANTHROPIC_API_KEY` env var set |
13
+ | Agent files | `agents/` directory exists with at least 1 `AGENTS.md` file |
14
+ | CLAUDE.md | `CLAUDE.md` present in the repo root |
15
+ | Git initialized | `.git/` directory present |
16
+ | npm | `npm` binary found in PATH |
17
+
18
+ ## How to run
19
+
20
+ This command delegates to the standalone health check script installed at `.specrails/bin/doctor.sh`. Run it directly:
21
+
22
+ ```
23
+ Bash tool: bash .specrails/bin/doctor.sh
24
+ ```
25
+
26
+ Or via the npm CLI wrapper:
27
+
28
+ ```
29
+ npx specrails-core@latest doctor
30
+ ```
31
+
32
+ ## Output
33
+
34
+ Each check is displayed as ✅ (pass) or ❌ (fail with fix instruction).
35
+
36
+ On all checks passed:
37
+ ```
38
+ All 6 checks passed. Run /sr:product-backlog to get started.
39
+ ```
40
+
41
+ On failure:
42
+ ```
43
+ ❌ API key: not configured
44
+ Fix: Run: claude config set api_key <your-key> | Get a key: https://console.anthropic.com/
45
+
46
+ 1 check(s) failed.
47
+ ```
48
+
49
+ ## Exit codes
50
+
51
+ - `0` — all checks passed
52
+ - `1` — one or more checks failed
53
+
54
+ ## Log file
55
+
56
+ Each run appends a timestamped summary to `~/.specrails/doctor.log`:
57
+
58
+ ```
59
+ 2026-03-20T10:00:00Z checks=6 passed=6 failed=0
60
+ ```
61
+
62
+ The `~/.specrails/` directory is created automatically if it does not exist.
package/commands/setup.md CHANGED
@@ -8,9 +8,13 @@ Interactive wizard to configure the full agent workflow system for this reposito
8
8
 
9
9
  ## Mode Detection
10
10
 
11
- Check if `$ARGUMENTS` contains `--update`:
12
- - If yes → execute **Update Mode** (below), then stop. Do NOT continue to the full setup wizard.
13
- - If noskip to **Phase 1** and execute the full setup wizard.
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 Quick Start.
14
+ 2. If `--advanced` is present → skip directly to **Phase 1** and execute the full 5-phase wizard.
15
+ 3. Otherwise (no flags) → execute **Quick Start Mode** (below), then stop. Do NOT execute Phase 1.
16
+
17
+ **Default is Quick Start.** The full wizard only runs when `--advanced` is explicitly passed.
14
18
 
15
19
  ---
16
20
 
@@ -193,6 +197,125 @@ Update `.specrails-manifest.json` to reflect the new checksums for all regenerat
193
197
 
194
198
  ---
195
199
 
200
+ ## Quick Start Mode
201
+
202
+ When no flags are passed (the default), run this streamlined 3-question setup. Do NOT run Phase 1–5. When QS4 is complete, stop.
203
+
204
+ ### QS1: Ask the 3 questions
205
+
206
+ Ask exactly these questions in sequence. Do not ask any other questions.
207
+
208
+ ```
209
+ Welcome to specrails! Let's get your AI agent team set up in 3 quick questions.
210
+
211
+ 1. What is this project? (one sentence)
212
+ > _
213
+
214
+ 2. Who are the target users?
215
+ > _
216
+
217
+ 3. Git access for agents — read-only or read-write?
218
+ (read-only = agents can read and suggest; read-write = agents can commit)
219
+ > _
220
+ ```
221
+
222
+ Store the answers as:
223
+ - `QS_PROJECT_DESCRIPTION` — answer to question 1
224
+ - `QS_TARGET_USERS` — answer to question 2
225
+ - `QS_GIT_ACCESS` — "read-only" or "read-write" (normalize if user types "ro", "rw", "readonly", etc.)
226
+
227
+ ### QS2: Apply opinionated defaults
228
+
229
+ Use these defaults for all configuration not asked in QS1:
230
+
231
+ | Setting | Quick Start Default |
232
+ |---------|-------------------|
233
+ | Agents enabled | sr-architect, sr-developer, sr-reviewer, sr-product-manager |
234
+ | Git mode | Derived from QS_GIT_ACCESS |
235
+ | CLAUDE.md template | `templates/CLAUDE-quickstart.md` |
236
+ | OpenSpec enabled | Yes if `openspec` CLI is detected in PATH, No otherwise |
237
+ | Telemetry | Not configured (deferred to PRD-002) |
238
+ | Backlog provider | None (user can configure later with `/setup --advanced`) |
239
+
240
+ Detect whether this is an existing codebase or new project:
241
+ - **Existing codebase**: `package.json`, `Gemfile`, `pyproject.toml`, `go.mod`, or `pom.xml` found in the repo root
242
+ - **New project**: none of the above found
243
+
244
+ Store as `QS_IS_EXISTING_CODEBASE=true/false`.
245
+
246
+ ### QS3: Generate files
247
+
248
+ Generate files using the Quick Start defaults.
249
+
250
+ **1. CLAUDE.md**
251
+
252
+ Read `setup-templates/claude-md/CLAUDE-quickstart.md` (or fall back to `setup-templates/claude-md/default.md` if quickstart template is not found).
253
+
254
+ Replace placeholders:
255
+ - `{{PROJECT_NAME}}` → derive from directory name or README.md first heading
256
+ - `{{PROJECT_DESCRIPTION}}` → `QS_PROJECT_DESCRIPTION`
257
+ - `{{TARGET_USERS}}` → `QS_TARGET_USERS`
258
+ - `{{GIT_ACCESS}}` → `QS_GIT_ACCESS`
259
+
260
+ Write to `CLAUDE.md` in the repo root. If `CLAUDE.md` already exists, ask:
261
+ > "CLAUDE.md already exists. Overwrite? [Y/n]"
262
+ Skip if user says no.
263
+
264
+ **2. Agent files**
265
+
266
+ 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`.
267
+
268
+ Fill placeholders with best-effort values from the limited context available:
269
+ - `{{PROJECT_NAME}}` → directory name or README first heading
270
+ - `{{PROJECT_DESCRIPTION}}` → `QS_PROJECT_DESCRIPTION`
271
+ - `{{TARGET_USERS}}` → `QS_TARGET_USERS`
272
+ - `{{GIT_ACCESS}}` → `QS_GIT_ACCESS`
273
+ - `{{ARCHITECTURE_DIAGRAM}}` → "(Quick Start — run `/setup --advanced` for full architecture analysis)"
274
+ - `{{TECH_EXPERTISE}}` → "(Quick Start — run `/setup --advanced` for codebase-specific expertise)"
275
+ - `{{LAYER_TAGS}}` → detect from package.json / Gemfile / go.mod if present; otherwise leave empty
276
+ - All other placeholders → "(not configured — run `/setup --advanced`)"
277
+
278
+ Create memory directories: `.claude/agent-memory/sr-<name>/`
279
+
280
+ **3. Command files**
281
+
282
+ Copy core commands from `setup-templates/commands/sr/` to `.claude/commands/sr/`:
283
+ - `implement.md`
284
+ - `batch-implement.md`
285
+ - `propose-spec.md`
286
+ - `health-check.md`
287
+ - `compat-check.md`
288
+ - `why.md`
289
+
290
+ Do NOT copy `product-backlog.md` or `update-product-driven-backlog.md` (no backlog provider configured).
291
+
292
+ **4. Cleanup**
293
+
294
+ Remove `setup-templates/` from `.claude/` (same as full wizard cleanup in Phase 5).
295
+
296
+ Remove `commands/setup.md` from `.claude/commands/` if it was copied there by the installer.
297
+
298
+ ### QS4: First Task Prompt
299
+
300
+ After generating all files, display the setup complete message.
301
+
302
+ Then, based on `QS_IS_EXISTING_CODEBASE`:
303
+ - **Existing codebase** (`true`): recommend `/sr:health-check`
304
+ - **New project** (`false`): recommend `/sr:product-backlog`
305
+
306
+ ```
307
+ ✅ Setup complete.
308
+
309
+ Try your first command:
310
+ > /sr:product-backlog
311
+ ```
312
+
313
+ (Replace `/sr:product-backlog` with `/sr:health-check` for existing codebases.)
314
+
315
+ Then stop. Do not execute Phase 1.
316
+
317
+ ---
318
+
196
319
  ## Phase 1: Codebase Analysis
197
320
 
198
321
  Analyze the repository to understand its architecture, stack, and conventions.
@@ -379,6 +502,8 @@ Which agents do you want to install?
379
502
  | sr-architect | Design features, create implementation plans | Sonnet | Yes |
380
503
  | sr-developer (full-stack) | Implement features across all layers | Sonnet | Yes |
381
504
  | sr-reviewer | CI/CD quality gate, fix issues | Sonnet | Yes |
505
+ | sr-test-writer | Generate unit, integration, and edge-case tests after implementation | Sonnet | Yes |
506
+ | sr-security-reviewer | Scan for secrets, OWASP vulnerabilities, hardcoded credentials | Sonnet | Yes |
382
507
  | sr-product-manager | Product discovery, ideation, VPC evaluation | Opus | Recommended |
383
508
  | sr-product-analyst | Read-only backlog analysis | Haiku | Recommended |
384
509
  | sr-backend-developer | Specialized backend implementation | Sonnet | If backend layer exists |
@@ -615,6 +740,8 @@ For each selected agent, read the template and generate the adapted version:
615
740
  - `setup-templates/agents/sr-architect.md` → `.claude/agents/sr-architect.md`
616
741
  - `setup-templates/agents/sr-developer.md` → `.claude/agents/sr-developer.md`
617
742
  - `setup-templates/agents/sr-reviewer.md` → `.claude/agents/sr-reviewer.md`
743
+ - `setup-templates/agents/sr-test-writer.md` → `.claude/agents/sr-test-writer.md`
744
+ - `setup-templates/agents/sr-security-reviewer.md` → `.claude/agents/sr-security-reviewer.md`
618
745
  - `setup-templates/agents/sr-product-manager.md` → `.claude/agents/sr-product-manager.md`
619
746
  - `setup-templates/agents/sr-product-analyst.md` → `.claude/agents/sr-product-analyst.md`
620
747
  - `setup-templates/agents/sr-backend-developer.md` → `.claude/agents/sr-backend-developer.md` (if backend layer)
@@ -636,6 +763,9 @@ When generating each agent:
636
763
  - `{{KEY_FILE_PATHS}}` → important file paths detected in Phase 1
637
764
  - `{{WARNINGS}}` → project-specific warnings (from existing CLAUDE.md or detected)
638
765
  - `{{MEMORY_PATH}}` → agent memory directory path (e.g., `.claude/agent-memory/sr-<agent-name>/`)
766
+ - `{{TECH_EXPERTISE}}` → detected languages, frameworks, and test frameworks from Phase 1
767
+ - `{{LAYER_CLAUDE_MD_PATHS}}` → comma-separated paths to per-layer rules files (e.g., `.claude/rules/backend.md`, `.claude/rules/frontend.md`)
768
+ - `{{SECURITY_EXEMPTIONS_PATH}}` → `.claude/security-exemptions.yaml`
639
769
  3. Write the final file
640
770
 
641
771
  ### 4.2 Generate personas
@@ -819,6 +949,8 @@ Display the complete installation summary:
819
949
  | sr-architect | .claude/agents/sr-architect.md | Sonnet |
820
950
  | sr-developer | .claude/agents/sr-developer.md | Sonnet |
821
951
  | sr-reviewer | .claude/agents/sr-reviewer.md | Sonnet |
952
+ | sr-test-writer | .claude/agents/sr-test-writer.md | Sonnet |
953
+ | sr-security-reviewer | .claude/agents/sr-security-reviewer.md | Sonnet |
822
954
  | sr-product-manager | .claude/agents/sr-product-manager.md | Opus |
823
955
 
824
956
  ### Personas Created
@@ -869,3 +1001,25 @@ Note: Only commands selected during setup are shown. Backlog commands are exclud
869
1001
  - `/sr:product-backlog` — see prioritized feature ideas
870
1002
  - `/sr:update-product-driven-backlog` — discover new features using VPC
871
1003
  ```
1004
+
1005
+ ## First Task Prompt (Advanced Mode)
1006
+
1007
+ After displaying the setup complete summary above, detect the project type and output:
1008
+
1009
+ **New project** (no `package.json`, `Gemfile`, `pyproject.toml`, `go.mod`, or `pom.xml` in root):
1010
+ ```
1011
+ ✅ Setup complete.
1012
+
1013
+ Try your first spec:
1014
+ > /sr:product-backlog
1015
+ ```
1016
+
1017
+ **Existing codebase** (one or more of the above files found in root):
1018
+ ```
1019
+ ✅ Setup complete.
1020
+
1021
+ Try your first spec:
1022
+ > /sr:health-check
1023
+ ```
1024
+
1025
+ Then stop.
package/install.sh CHANGED
@@ -149,6 +149,12 @@ generate_manifest() {
149
149
  artifacts_json="${artifacts_json}
150
150
  \"commands/setup.md\": \"${setup_checksum}\""
151
151
 
152
+ # Include commands/doctor.md
153
+ local doctor_checksum
154
+ doctor_checksum="sha256:$(shasum -a 256 "$SCRIPT_DIR/commands/doctor.md" | awk '{print $1}')"
155
+ artifacts_json="${artifacts_json},
156
+ \"commands/doctor.md\": \"${doctor_checksum}\""
157
+
152
158
  cat > "$REPO_ROOT/.specrails-manifest.json" << EOF
153
159
  {
154
160
  "version": "${version}",
@@ -186,36 +192,33 @@ if command -v claude &> /dev/null; then
186
192
  else
187
193
  fail "Claude Code CLI not found."
188
194
  echo ""
189
- echo " Install it with: npm install -g @anthropic-ai/claude-code"
190
- echo " Or see: https://docs.anthropic.com/en/docs/claude-code"
195
+ echo " Install it: https://claude.ai/download"
196
+ exit 1
197
+ fi
198
+
199
+ # 1.3 API key
200
+ if claude config list 2>/dev/null | grep -q "api_key" || [[ -n "${ANTHROPIC_API_KEY:-}" ]]; then
201
+ ok "Claude API key: configured"
202
+ else
203
+ fail "No Claude API key configured."
204
+ echo ""
205
+ echo " Set it: claude config set api_key <your-key>"
206
+ echo " Get one: https://console.anthropic.com/"
191
207
  exit 1
192
208
  fi
193
209
 
194
- # 1.3 npm
210
+ # 1.4 npm
195
211
  if command -v npm &> /dev/null; then
196
212
  NPM_VERSION=$(npm --version 2>/dev/null)
197
213
  ok "npm: v$NPM_VERSION"
198
214
  HAS_NPM=true
199
215
  else
200
- warn "npm not found. Required for OpenSpec CLI."
201
- echo ""
202
- if [ "$AUTO_YES" = true ]; then INSTALL_NPM="y"; else read -p " Install npm via nvm? (y/n): " INSTALL_NPM; fi
203
- if [ "$INSTALL_NPM" = "y" ] || [ "$INSTALL_NPM" = "Y" ]; then
204
- info "Installing nvm + node..."
205
- curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
206
- export NVM_DIR="$HOME/.nvm"
207
- [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
208
- nvm install --lts
209
- nvm use --lts
210
- ok "npm installed: v$(npm --version)"
211
- HAS_NPM=true
212
- else
213
- warn "Skipping npm install. OpenSpec CLI will not be available."
214
- HAS_NPM=false
215
- fi
216
+ warn "npm not found. OpenSpec CLI will be unavailable."
217
+ echo " Install npm: https://docs.npmjs.com/downloading-and-installing-node-js-and-npm"
218
+ HAS_NPM=false
216
219
  fi
217
220
 
218
- # 1.4 OpenSpec CLI
221
+ # 1.5 OpenSpec CLI
219
222
  if command -v openspec &> /dev/null; then
220
223
  OPENSPEC_VERSION=$(openspec --version 2>/dev/null || echo "unknown")
221
224
  ok "OpenSpec CLI: $OPENSPEC_VERSION"
@@ -252,7 +255,7 @@ else
252
255
  fi
253
256
  fi
254
257
 
255
- # 1.5 GitHub CLI (optional)
258
+ # 1.6 GitHub CLI (optional)
256
259
  if command -v gh &> /dev/null; then
257
260
  if gh auth status &> /dev/null; then
258
261
  ok "GitHub CLI: authenticated"
@@ -266,7 +269,7 @@ else
266
269
  HAS_GH=false
267
270
  fi
268
271
 
269
- # 1.6 OSS detection (requires gh auth; degrades gracefully)
272
+ # 1.7 OSS detection (requires gh auth; degrades gracefully)
270
273
  IS_OSS=false
271
274
  HAS_PUBLIC_REPO=false
272
275
  HAS_CI=false
@@ -289,7 +292,7 @@ if [ "$HAS_GH" = true ]; then
289
292
  fi
290
293
  fi
291
294
 
292
- # 1.7 JIRA CLI (optional)
295
+ # 1.8 JIRA CLI (optional)
293
296
  if command -v jira &> /dev/null; then
294
297
  ok "JIRA CLI: found"
295
298
  HAS_JIRA=true
@@ -362,6 +365,16 @@ mkdir -p "$REPO_ROOT/.claude/agent-memory/explanations"
362
365
  cp "$SCRIPT_DIR/commands/setup.md" "$REPO_ROOT/.claude/commands/setup.md"
363
366
  ok "Installed /setup command"
364
367
 
368
+ # Copy the /doctor command
369
+ cp "$SCRIPT_DIR/commands/doctor.md" "$REPO_ROOT/.claude/commands/doctor.md"
370
+ ok "Installed /doctor command"
371
+
372
+ # Install bin/doctor.sh for standalone use
373
+ mkdir -p "$REPO_ROOT/.specrails/bin"
374
+ cp "$SCRIPT_DIR/bin/doctor.sh" "$REPO_ROOT/.specrails/bin/doctor.sh"
375
+ chmod +x "$REPO_ROOT/.specrails/bin/doctor.sh"
376
+ ok "Installed specrails doctor (bin/doctor.sh)"
377
+
365
378
  # Copy templates
366
379
  cp -r "$SCRIPT_DIR/templates/"* "$REPO_ROOT/.claude/setup-templates/"
367
380
  ok "Installed setup templates"
@@ -0,0 +1,28 @@
1
+ {
2
+ "schemaVersion": "1.0",
3
+ "coreVersion": "1.0.1",
4
+ "minimumHubVersion": "1.3.0",
5
+ "cli": {
6
+ "initArgs": ["init", "--yes"],
7
+ "updateArgs": ["update"]
8
+ },
9
+ "checkpoints": [
10
+ "base_install",
11
+ "repo_analysis",
12
+ "stack_conventions",
13
+ "product_discovery",
14
+ "agent_generation",
15
+ "command_config",
16
+ "final_verification"
17
+ ],
18
+ "commands": [
19
+ "implement",
20
+ "batch-implement",
21
+ "why",
22
+ "product-backlog",
23
+ "update-product-driven-backlog",
24
+ "refactor-recommender",
25
+ "health-check",
26
+ "compat-check"
27
+ ]
28
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "specrails-core",
3
- "version": "0.7.1",
4
- "description": "Agent Workflow System installer for Claude Code",
3
+ "version": "1.1.0",
4
+ "description": "AI agent workflow system for Claude Code — installs 12 specialized agents, orchestration commands, and persona-driven product discovery into any repository",
5
5
  "bin": {
6
6
  "specrails-core": "bin/specrails-core.js"
7
7
  },
@@ -13,7 +13,8 @@
13
13
  "prompts/",
14
14
  ".claude/skills/",
15
15
  "commands/",
16
- "VERSION"
16
+ "VERSION",
17
+ "integration-contract.json"
17
18
  ],
18
19
  "engines": {
19
20
  "node": ">=18.0.0"
@@ -27,8 +28,27 @@
27
28
  "claude-code",
28
29
  "ai-agents",
29
30
  "workflow",
30
- "developer-tools"
31
+ "developer-tools",
32
+ "anthropic",
33
+ "llm",
34
+ "ai",
35
+ "automation",
36
+ "productivity",
37
+ "specrails",
38
+ "openspec",
39
+ "code-generation",
40
+ "product-management",
41
+ "vibe-coding",
42
+ "agents",
43
+ "multi-agent",
44
+ "software-engineering",
45
+ "devtools",
46
+ "ai-workflow"
31
47
  ],
48
+ "homepage": "https://github.com/fjpulidop/specrails-core#readme",
49
+ "bugs": {
50
+ "url": "https://github.com/fjpulidop/specrails-core/issues"
51
+ },
32
52
  "license": "MIT",
33
53
  "author": "fjpulidop"
34
54
  }
@@ -1,22 +1,22 @@
1
1
  ---
2
2
  name: sr-doc-sync
3
- description: "Use this agent after tests are written to automatically update documentation — changelog entries, README updates, and API docs — keeping docs in sync with code changes. Runs as Phase 3d in the implement pipeline.
3
+ description: "Use this agent after tests are written to detect documentation drift and update docs — changelog entries, README updates, and API docs — keeping docs in sync with code changes. Runs as Phase 3d in the implement pipeline.
4
4
 
5
5
  Examples:
6
6
 
7
7
  - Example 1:
8
8
  user: (orchestrator) Tests complete. Update docs for the implemented files.
9
- assistant: \"Launching the doc-sync agent to update documentation for the implemented code.\"
9
+ assistant: \"Launching the doc-sync agent to detect drift and update documentation for the implemented code.\"
10
10
 
11
11
  - Example 2:
12
12
  user: (orchestrator) Implementation and tests done. Sync docs.
13
- assistant: \"I'll use the doc-sync agent to generate changelog entries and update docs.\""
13
+ assistant: \"I'll use the doc-sync agent to detect drift, generate changelog entries, and update docs.\""
14
14
  model: sonnet
15
15
  color: yellow
16
16
  memory: project
17
17
  ---
18
18
 
19
- You are a documentation specialist. Your only job is to keep documentation in sync with code — you never modify implementation files or test files.
19
+ You are a documentation specialist. Your only job is to detect documentation drift and keep docs in sync with code — you never modify implementation files or test files.
20
20
 
21
21
  ## Your Identity & Expertise
22
22
 
@@ -27,7 +27,13 @@ You write documentation that is accurate, concise, and consistent with the proje
27
27
 
28
28
  ## Your Mission
29
29
 
30
- Detect the project's existing documentation conventions and generate matching updates for newly implemented code. You update changelogs, README files, and API docs to reflect the changes described in IMPLEMENTED_FILES_LIST and TASK_DESCRIPTION. You never run code — you read and write documentation files only.
30
+ Detect documentation drift between the implemented code and the existing docs, then generate matching updates. You:
31
+ 1. Compare function signatures/exports against existing docs to find drift
32
+ 2. Classify drift by severity (critical for API-facing surface, warning for internal)
33
+ 3. Propose targeted doc patches for each drift item
34
+ 4. Update changelogs, README files, and API docs to resolve all detected drift
35
+
36
+ You never run code — you read and write documentation files only.
31
37
 
32
38
  ## What You Receive
33
39
 
@@ -37,6 +43,53 @@ The orchestrator injects these inputs into your invocation prompt:
37
43
  - **TASK_DESCRIPTION**: the original task or feature description that drove the implementation. Use this as the basis for changelog entries and summary text.
38
44
  - Layer conventions at `{{LAYER_CLAUDE_MD_PATHS}}`: read these before generating docs to understand project-specific patterns.
39
45
 
46
+ ## Drift Detection Protocol
47
+
48
+ Before generating any documentation, analyze each file in IMPLEMENTED_FILES_LIST for documentation drift. Drift is the gap between what the code exposes and what the docs describe.
49
+
50
+ ### Step 1: Extract code signatures
51
+
52
+ For each file in IMPLEMENTED_FILES_LIST, read the file and extract:
53
+
54
+ | Language | What to extract |
55
+ |----------|----------------|
56
+ | TypeScript/JavaScript | Exported functions, classes, interfaces, constants, type aliases |
57
+ | Python | Module-level functions, classes, and constants marked `__all__` or without leading `_` |
58
+ | Ruby | Public methods, module-level constants, public class definitions |
59
+ | Go | Exported identifiers (capitalized functions, types, variables) |
60
+ | Other | Any symbol that is part of the module's public API |
61
+
62
+ For each extracted signature, note:
63
+ - **Name**: the identifier name
64
+ - **Signature**: parameter types and return type (if typed), or parameter names (if not)
65
+ - **Visibility**: `api-facing` if exported from a top-level index file, REST endpoint, or public interface; `internal` otherwise
66
+
67
+ ### Step 2: Locate existing documentation
68
+
69
+ For each extracted signature, search for existing documentation in this order:
70
+ 1. `docs/api/` — look for `.md` files matching the module or class name
71
+ 2. `docs/` — look for any `.md` file with matching content
72
+ 3. Root `README.md` — look for the identifier in the API or usage sections
73
+ 4. Inline docstrings or JSDoc comments in the source file itself
74
+
75
+ ### Step 3: Classify drift
76
+
77
+ For each extracted signature, classify the drift state:
78
+
79
+ | Drift Type | Condition | Severity |
80
+ |------------|-----------|----------|
81
+ | `undocumented` | Exported symbol has no matching doc entry | Critical if `api-facing`, Warning if `internal` |
82
+ | `stale-signature` | Doc entry exists but signature has changed (param names, types, return type) | Critical if `api-facing`, Warning if `internal` |
83
+ | `stale-description` | Doc entry exists but description references removed behavior or old name | Warning (regardless of visibility) |
84
+ | `phantom` | Doc entry exists for a symbol that no longer exists in the code | Critical if the phantom was `api-facing`, Warning if `internal` |
85
+ | `current` | Doc entry exists and matches the current signature | No action needed |
86
+
87
+ ### Step 4: Build drift report
88
+
89
+ Collect all non-`current` drift items. This report drives which documentation updates you will generate in the next phase.
90
+
91
+ If no drift is found (all signatures are `current`): proceed directly to "Documentation Generation" for changelog-only updates, then emit `DOC_SYNC_STATUS: DONE` with a note that no structural drift was detected.
92
+
40
93
  ## Doc Style Detection Protocol
41
94
 
42
95
  Before writing any documentation, detect the project's existing conventions by reading the following (stop at the first match for each category):
@@ -103,10 +156,12 @@ If no `docs/` directory exists: skip and note the reason in output.
103
156
 
104
157
  1. **Never modify implementation files.** Read them to understand changes, but write only to documentation files.
105
158
  2. **Never modify test files.** Documentation only.
106
- 3. **Match existing style exactly.** Do not introduce new heading levels, list styles, or formatting not already present in the file.
107
- 4. **Skip gracefully.** If there are no user-visible changes to document (e.g., pure refactors, internal changes), output `DOC_SYNC_STATUS: SKIPPED` with a clear reason. Do not force documentation where none is needed.
108
- 5. **Never ask for clarification.** Complete documentation generation with available information.
109
- 6. **Always emit the `DOC_SYNC_STATUS:` line as the very last line of output.** Nothing may follow it.
159
+ 3. **Always run drift detection first.** Classify all drift before writing any documentation.
160
+ 4. **Critical drift must be resolved.** All `Critical` drift items (undocumented or phantom `api-facing` symbols) must have a corresponding doc update. Do not skip Critical items.
161
+ 5. **Match existing style exactly.** Do not introduce new heading levels, list styles, or formatting not already present in the file.
162
+ 6. **Skip gracefully.** If there are no user-visible changes to document (e.g., pure refactors, internal changes) AND no drift detected, output `DOC_SYNC_STATUS: SKIPPED` with a clear reason. Do not force documentation where none is needed.
163
+ 7. **Never ask for clarification.** Complete documentation generation with available information.
164
+ 8. **Always emit the `DOC_SYNC_STATUS:` line as the very last line of output.** Nothing may follow it.
110
165
 
111
166
  ## Output Format
112
167
 
@@ -115,6 +170,16 @@ After writing all documentation updates, produce this report:
115
170
  ```
116
171
  ## Doc Sync Results
117
172
 
173
+ ### Drift Analysis
174
+ | Symbol | File | Drift Type | Severity | Resolution |
175
+ |--------|------|-----------|----------|-----------|
176
+ | <name> | <source file> | undocumented | Critical | Added to <doc file> |
177
+ | <name> | <source file> | stale-signature | Warning | Updated in <doc file> |
178
+ | <name> | <source file> | phantom | Critical | Removed from <doc file> |
179
+ (rows or "No drift detected")
180
+
181
+ **Drift summary**: X Critical, Y Warning
182
+
118
183
  ### Changelog
119
184
  - File: <path or "none found">
120
185
  - Action: <updated | skipped — reason>
@@ -139,7 +204,7 @@ DOC_SYNC_STATUS: DONE
139
204
  ```
140
205
 
141
206
  Set `DOC_SYNC_STATUS:` as follows:
142
- - `DONE` — one or more documentation files written successfully
207
+ - `DONE` — drift analysis complete and any needed documentation written
143
208
  - `SKIPPED` — no documentation files found or no user-visible changes to document
144
209
  - `FAILED` — an unrecoverable error occurred
145
210
 
@@ -161,6 +226,8 @@ What to save:
161
226
  - README structure and section names discovered
162
227
  - API doc location and format discovered
163
228
  - Files or sections that are always skipped for this repo
229
+ - Drift patterns discovered: which directories contain `api-facing` vs `internal` symbols
230
+ - Top-level index file path (e.g., `src/index.ts`, `lib/index.rb`) for visibility classification
164
231
 
165
232
  ## MEMORY.md
166
233
 
@@ -0,0 +1,58 @@
1
+ # {{PROJECT_NAME}}
2
+
3
+ > {{PROJECT_DESCRIPTION}}
4
+
5
+ **Target users:** {{TARGET_USERS}}
6
+
7
+ ---
8
+
9
+ ## Agent Team
10
+
11
+ This project uses the specrails agent workflow. The following agents are active:
12
+
13
+ - **CEO** — product direction and goal-setting
14
+ - **CTO** — architecture decisions and technical standards
15
+ - **Tech Lead** — implementation coordination
16
+ - **Founding Engineer** — full-stack development
17
+
18
+ Git access level: **{{GIT_ACCESS}}**
19
+
20
+ ---
21
+
22
+ ## Working with the Agent Team
23
+
24
+ Start with a product backlog to discover what to build first:
25
+
26
+ ```
27
+ /sr:product-backlog
28
+ ```
29
+
30
+ Then implement features using the full pipeline:
31
+
32
+ ```
33
+ /sr:implement #1 #2 #3
34
+ ```
35
+
36
+ ---
37
+
38
+ ## Health Check
39
+
40
+ If something seems off, run:
41
+
42
+ ```
43
+ specrails doctor
44
+ ```
45
+
46
+ Or inside Claude Code:
47
+
48
+ ```
49
+ /doctor
50
+ ```
51
+
52
+ ---
53
+
54
+ ## Engineering Standards
55
+
56
+ - Write specs before code (OpenSpec for behavioral specs)
57
+ - Conventional commits on all git commits
58
+ - All PRs require review before merge