specrails-core 1.3.0 → 1.5.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/README.md CHANGED
@@ -1,76 +1,85 @@
1
1
  # specrails-core
2
2
 
3
3
  [![npm version](https://img.shields.io/npm/v/specrails-core.svg)](https://www.npmjs.com/package/specrails-core)
4
+ [![GitHub Stars](https://img.shields.io/github/stars/fjpulidop/specrails-core?style=social)](https://github.com/fjpulidop/specrails-core)
4
5
  [![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)
6
+ [![npm downloads](https://img.shields.io/npm/dw/specrails-core.svg)](https://www.npmjs.com/package/specrails-core)
7
+ [![Claude Code](https://img.shields.io/badge/Built%20for-Claude%20Code-blueviolet)](https://docs.anthropic.com/en/docs/claude-code)
6
8
 
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.
9
+ **Your AI development team. From idea to production code.**
10
+
11
+ One command gives your repo a full team of specialized AI agents: architect, developer, reviewer, product manager — all working together through a structured pipeline, fully adapted to your codebase.
8
12
 
9
13
  ```bash
10
- npx specrails-core@latest init --root-dir <your-project>
14
+ npx specrails-core@latest init --root-dir .
11
15
  ```
12
16
 
13
- ---
17
+ > **Requirements:** [Claude Code](https://docs.anthropic.com/en/docs/claude-code) (required), Node 18+, git
14
18
 
15
- ## The pipeline
19
+ <!--
20
+ BOARD: Add demo GIF here — this is the #1 conversion driver on Product Hunt and npm.
21
+ Record a 60-90s screen capture showing:
22
+ 1. `npx specrails-core@latest init --root-dir .` running
23
+ 2. The `/setup` wizard completing (phases 1-5)
24
+ 3. `/sr:implement "add dark mode"` → agents working → PR created
25
+ Recommended tools: Loom or QuickTime to record; Kap (https://getkap.co) to export as GIF.
26
+ Then replace this comment with:
16
27
 
17
- ```
18
- Product Discovery → Architecture → Implementation → Review → Ship
19
- (sr-product-manager) (sr-architect) (sr-developer) (sr-reviewer) (PR)
20
- ```
28
+ ![specrails-core demo](./assets/demo.gif)
29
+ -->
21
30
 
22
- One command runs the full cycle:
31
+ ---
32
+
33
+ ## How it works
23
34
 
24
35
  ```
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
36
+ Idea → Architecture → Implementation → Review → PR
37
+ (sr-architect) (sr-developer) (sr-reviewer)
28
38
  ```
29
39
 
30
- Multiple features run in parallel using git worktrees. Single features run sequentially.
40
+ Run `/sr:implement "add dark mode"` the pipeline designs, builds, reviews, and ships a pull request. No hand-holding required.
41
+
42
+ Every artifact (agents, rules, personas) is generated **specifically for your project** by analyzing your actual codebase, tech stack, and CI setup. Not generic templates.
31
43
 
32
44
  ---
33
45
 
34
46
  ## Quick start
35
47
 
36
- **Step 1 Install into your project**
48
+ **1. Install**
37
49
 
38
50
  ```bash
39
- npx specrails-core@latest init --root-dir /path/to/your/repo
51
+ npx specrails-core@latest init --root-dir .
40
52
  ```
41
53
 
42
- The installer scaffolds temporary setup files into `.claude/` and checks prerequisites (Claude Code, git, npm, GitHub CLI).
43
-
44
- **Step 2 — Run the setup wizard inside Claude Code**
54
+ **2. Run setup inside Claude Code**
45
55
 
46
56
  ```bash
47
- cd /path/to/your/repo
48
- claude # open Claude Code
49
- > /setup # run the interactive setup wizard
57
+ claude # open Claude Code in your project
58
+ > /setup # run the 5-phase wizard (~5 min)
50
59
  ```
51
60
 
52
- Claude runs a 5-phase wizard that reads your actual codebase and generates everything tailored to your stack:
61
+ **3. Start building**
53
62
 
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 |
63
+ ```bash
64
+ > /sr:implement "add user authentication"
65
+ > /sr:implement #42, #43 # from GitHub Issues
66
+ > /sr:update-product-driven-backlog # discover new features with AI
67
+ ```
68
+
69
+ That's it. The pipeline takes over.
61
70
 
62
71
  ---
63
72
 
64
73
  ## What gets installed
65
74
 
66
- | Category | Location | Description |
67
- |----------|----------|-------------|
75
+ | Category | Files | Purpose |
76
+ |----------|-------|---------|
68
77
  | **Agents** | `.claude/agents/*.md` | 12 specialized AI agents |
69
- | **Personas** | `.claude/agents/personas/*.md` | VPC user profiles from competitive research |
78
+ | **Personas** | `.claude/agents/personas/*.md` | VPC user profiles, generated from your users |
70
79
  | **Commands** | `.claude/commands/sr/*.md` | `/sr:implement`, `/sr:product-backlog`, `/sr:update-product-driven-backlog` |
71
80
  | **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 |
81
+ | **Memory** | `.claude/agent-memory/` | Persistent knowledge — agents learn across sessions |
82
+ | **Config** | `.claude/settings.json`, `CLAUDE.md` | Permissions, architecture reference |
74
83
 
75
84
  ---
76
85
 
@@ -82,7 +91,6 @@ Claude runs a 5-phase wizard that reads your actual codebase and generates every
82
91
  | Adapts to your codebase | ✅ Reads your actual stack/CI | ⚠️ Prompts only | ❌ |
83
92
  | Product-driven backlog | ✅ VPC persona scoring | ❌ | ❌ |
84
93
  | Parallel feature builds | ✅ Git worktrees | ❌ | ❌ |
85
- | Dry-run / preview mode | ✅ Preview before committing | ❌ | ❌ |
86
94
  | Institutional memory | ✅ Agents learn across sessions | ❌ | ❌ |
87
95
  | Open source | ✅ MIT | N/A | ❌ |
88
96
 
@@ -94,37 +102,32 @@ SpecRails is not a chat interface. It's a **development pipeline** that coordina
94
102
 
95
103
  | Agent | Model | Role |
96
104
  |-------|-------|------|
97
- | **sr-architect** | Sonnet | Designs features proposal, technical design, task breakdown |
98
- | **sr-developer** | Sonnet | Full-stack implementation from architect artifacts |
105
+ | **sr-architect** | Sonnet | Designs features: proposal, technical design, task breakdown |
106
+ | **sr-developer** | Sonnet | Full-stack implementation |
99
107
  | **sr-backend-developer** | Sonnet | Backend-specialized implementation |
100
108
  | **sr-frontend-developer** | Sonnet | Frontend-specialized implementation |
101
- | **sr-reviewer** | Sonnet | Final quality gate runs CI, fixes issues, records learnings |
102
- | **sr-backend-reviewer** | Sonnet | API design, database patterns, performance review |
103
- | **sr-frontend-reviewer** | Sonnet | UX patterns, accessibility, component design review |
109
+ | **sr-reviewer** | Sonnet | Quality gate: runs CI, fixes issues, records learnings |
110
+ | **sr-backend-reviewer** | Sonnet | Backend code review: API design, DB patterns, performance |
111
+ | **sr-frontend-reviewer** | Sonnet | Frontend code review: UX, accessibility, component design |
104
112
  | **sr-test-writer** | Sonnet | Generates unit, integration, and e2e tests |
105
- | **sr-security-reviewer** | Sonnet | Secrets detection, OWASP checks, dependency audit |
106
- | **sr-doc-sync** | Sonnet | Changelogs, READMEs, API docs after every change |
107
- | **sr-product-manager** | Opus | Competitive analysis, VPC evaluation, feature ideation |
113
+ | **sr-security-reviewer** | Sonnet | Secrets detection, OWASP checks, dependency vulnerabilities |
114
+ | **sr-doc-sync** | Sonnet | Updates changelogs, READMEs, API docs |
115
+ | **sr-product-manager** | Opus | Product discovery: competitive analysis, VPC evaluation |
108
116
  | **sr-product-analyst** | Haiku | Read-only backlog analysis and prioritization |
109
117
 
110
- The `/sr:implement` pipeline routes tasks to the right agent automatically based on layer tags.
111
-
112
118
  ---
113
119
 
114
- ## Product discovery commands
120
+ ## Commands
115
121
 
116
- ### `/sr:product-backlog` — Prioritized backlog
122
+ ### `/sr:implement` — Build features
117
123
 
118
- Reads GitHub Issues labeled `product-driven-backlog`, scores them against your VPC personas, and recommends the top 3 for the next sprint.
119
-
120
- ```
121
- /sr:product-backlog # show all areas
122
- /sr:product-backlog UI, Decks # filter by area
124
+ ```bash
125
+ /sr:implement "add dark mode" # from a description
126
+ /sr:implement #85, #71 # from GitHub Issues
127
+ /sr:implement UI, Analytics # explore areas, pick the best ideas
123
128
  ```
124
129
 
125
- ### `/sr:update-product-driven-backlog` Discover new features
126
-
127
- Analyzes your codebase against each persona's jobs/pains/gains, generates new feature ideas, and creates GitHub Issues for the best ones.
130
+ Architect designs developer builds → reviewer validates → PR created. Multiple features run in parallel with git worktrees.
128
131
 
129
132
  #### Dry-run / preview mode
130
133
 
@@ -135,7 +138,7 @@ Not ready to commit? Run the full pipeline without touching git or GitHub:
135
138
  /sr:implement #85 --preview # --preview is an alias for --dry-run
136
139
  ```
137
140
 
138
- All agents run normally (architect, developer, tests, docs, review). Generated files land in `.claude/.dry-run/<feature-name>/` instead of your working tree. No branches, commits, PRs, or issue updates are created.
141
+ All agents run normally. Generated files land in `.claude/.dry-run/<feature-name>/` instead of your working tree. No branches, commits, PRs, or issue updates are created.
139
142
 
140
143
  When you're happy with the preview, apply the cached output:
141
144
 
@@ -151,27 +154,39 @@ rm -rf .claude/.dry-run/add-dark-mode/
151
154
 
152
155
  ### `/sr:product-backlog` — View prioritized backlog
153
156
 
157
+ ```bash
158
+ /sr:product-backlog # show all areas
159
+ /sr:product-backlog UI, Decks # filter by area
154
160
  ```
161
+
162
+ Reads your GitHub Issues, scores by VPC persona match, recommends top 3 for next sprint.
163
+
164
+ ### `/sr:update-product-driven-backlog` — Discover features
165
+
166
+ ```bash
155
167
  /sr:update-product-driven-backlog # explore all areas
156
168
  /sr:update-product-driven-backlog Analytics # focus on one area
157
169
  ```
158
170
 
171
+ AI product discovery using your personas. Evaluates ideas, creates GitHub Issues for the best ones.
172
+
159
173
  ---
160
174
 
161
- ## Value Proposition Canvas scoring
175
+ ## VPC persona scoring
162
176
 
163
- 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.
177
+ Features are scored against your user personas using the VPC framework:
164
178
 
165
179
  ```
166
180
  +-----------------------------+ +-----------------------------+
167
181
  | VALUE PROPOSITION | | CUSTOMER SEGMENT |
168
- | | | |
169
182
  | Products & Services <---+--->| Customer Jobs |
170
183
  | Pain Relievers <---+--->| Pains |
171
184
  | Gain Creators <---+--->| Gains |
172
185
  +-----------------------------+ +-----------------------------+
173
186
  ```
174
187
 
188
+ Each persona scores features 0-5. Features are ranked by score/effort ratio. No gut-feel product decisions.
189
+
175
190
  ---
176
191
 
177
192
  ## Prerequisites
@@ -179,27 +194,25 @@ Every feature is evaluated against your user personas before implementation. Fea
179
194
  | Tool | Required | Purpose |
180
195
  |------|----------|---------|
181
196
  | **Claude Code** | Yes | AI agent runtime — [install](https://docs.anthropic.com/en/docs/claude-code) |
182
- | **Git** | Yes | Repository detection |
183
- | **npm** | Recommended | Install OpenSpec CLI |
184
- | **OpenSpec CLI** | Recommended | Spec-driven design workflow |
185
- | **GitHub CLI** (`gh`) | Optional | Backlog sync and PR creation |
186
- | **JIRA CLI** | Optional | JIRA as backlog alternative |
187
-
188
- The installer checks for each tool and offers to install missing ones automatically.
197
+ | **git** | Yes | Repository detection |
198
+ | **npm / Node 18+** | Recommended | Needed for npx install and OpenSpec CLI |
199
+ | **OpenSpec CLI** | Recommended | Structured design artifacts for `/sr:implement` |
200
+ | **GitHub CLI** (`gh`) | Optional | Backlog sync to GitHub Issues, PR creation |
201
+ | **JIRA CLI** (`jira`) | Optional | Backlog sync to JIRA |
189
202
 
190
- > You only need one backlog provider. If you use neither, `/sr:implement "description"` still works.
203
+ The installer checks for each tool and offers to install missing ones.
191
204
 
192
205
  ---
193
206
 
194
207
  ## Supported stacks
195
208
 
196
- specrails-core is stack-agnostic the setup wizard reads your actual files and generates accurate conventions, not generic templates.
209
+ Stack-agnostic. The `/setup` wizard detects and adapts to whatever you're running:
197
210
 
198
- - **Backend**: Python/FastAPI, Node/Express, Go/Gin, Rust/Actix, Java/Spring, Ruby/Rails, .NET
199
- - **Frontend**: React, Vue, Angular, Svelte, Next.js, Nuxt
200
- - **Database**: PostgreSQL, MySQL, SQLite, MongoDB, Redis
201
- - **CI/CD**: GitHub Actions, GitLab CI, Jenkins, Makefile
202
- - **Testing**: pytest, vitest, jest, go test, cargo test, rspec
211
+ **Backend:** Python/FastAPI, Node/Express, Go/Gin, Rust/Actix, Java/Spring, Ruby/Rails, .NET
212
+ **Frontend:** React, Vue, Angular, Svelte, Next.js, Nuxt
213
+ **Database:** PostgreSQL, MySQL, SQLite, MongoDB, Redis
214
+ **CI/CD:** GitHub Actions, GitLab CI, Jenkins, Makefile
215
+ **Testing:** pytest, vitest, jest, go test, cargo test, rspec
203
216
 
204
217
  ---
205
218
 
@@ -217,34 +230,33 @@ specrails-core is stack-agnostic — the setup wizard reads your actual files an
217
230
  ## FAQ
218
231
 
219
232
  **Can I customize the agents after installation?**
220
- Yes. Files in `.claude/` are plain markdown edit agent personalities, adjust CI commands, add rules, create personas.
221
-
222
- **How do I customize an agent's personality?**
223
- Each agent template (`sr-architect`, `sr-developer`, `sr-reviewer`) includes a `## Personality` section with four configurable settings:
224
-
225
- | Setting | Options | What it controls |
226
- |---|---|---|
227
- | `tone` | `terse` / `verbose` | How much explanation the agent includes in its output |
228
- | `risk_tolerance` | `conservative` / `aggressive` | How cautious the agent is when making decisions |
229
- | `detail_level` | `summary` / `full` | Granularity of output artifacts and reports |
230
- | `focus_areas` | comma-separated keywords | Areas the agent prioritizes (e.g. `security, performance`) |
231
-
232
- After running `/setup`, edit `.claude/agents/sr-architect.md` (or `sr-developer.md` / `sr-reviewer.md`) and change the values inline. Existing setups without a `## Personality` section continue to work unchanged — defaults apply.
233
+ Yes. The generated files in `.claude/` are yours to edit — plain markdown. Edit agent personalities, adjust CI commands, add rules, create personas.
233
234
 
234
235
  **Can I re-run setup?**
235
236
  Run `npx specrails-core@latest init --root-dir <path>` again to re-scaffold, then `/setup`.
236
237
 
237
238
  **Does this work without OpenSpec?**
238
- Partially. `/sr:implement` and sr-architect use OpenSpec for structured design artifacts. Product discovery commands and individual agents work without it.
239
+ Partially. Product discovery commands and individual agents work. `/sr:implement` and sr-architect rely on OpenSpec for structured design artifacts.
239
240
 
240
241
  **Does this work without GitHub CLI?**
241
- 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.
242
+ Yes. Use JIRA instead, or skip backlog commands. `/sr:implement "description"` works without `gh` — it just skips automated PR creation.
243
+
244
+ **How much does it cost to run?**
245
+ A full `/sr:implement` cycle for one feature typically costs a few dollars in Claude API usage. The sr-product-manager uses Opus; all other agents use Sonnet or Haiku.
246
+
247
+ **Does it work with private repos?**
248
+ Yes. Everything runs locally through Claude Code. No external services beyond the Claude API.
249
+
250
+ ---
251
+
252
+ ## Also in the SpecRails ecosystem
242
253
 
243
- **How much does it cost?**
244
- 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.
254
+ - **[specrails-hub](https://github.com/fjpulidop/specrails-hub)** GUI for specrails-core. Manage your agents, run commands, and view pipeline results from a web interface.
255
+ - **[specrails.dev](https://specrails.dev)** Official website and documentation.
256
+ - **Product Hunt** — [Vote for SpecRails on launch day](https://www.producthunt.com) _(link goes live on launch day — star this repo to get notified)_
245
257
 
246
258
  ---
247
259
 
248
260
  ## License
249
261
 
250
- MIT
262
+ MIT — [fjpulidop](https://github.com/fjpulidop)
package/commands/setup.md CHANGED
@@ -801,11 +801,37 @@ For each selected command, read the template and adapt:
801
801
 
802
802
  Adapt:
803
803
  - CI commands to match detected stack
804
- - Persona references to match generated personas
804
+ - **Persona references** to match generated personas (see substitution rules below)
805
805
  - File paths to match project structure
806
806
  - Layer tags to match detected layers
807
807
  - **Backlog provider commands** based on `BACKLOG_PROVIDER`:
808
808
 
809
+ #### Backlog command persona placeholder substitution
810
+
811
+ When adapting `update-product-driven-backlog.md` and `product-backlog.md`, substitute the persona placeholders based on the full persona set (user-generated personas + Maintainer if `IS_OSS=true`):
812
+
813
+ | Placeholder | Substitution rule |
814
+ |-------------|------------------|
815
+ | `{{PERSONA_FILE_READ_LIST}}` | One bullet per persona file: `- Read \`.claude/agents/personas/{name}.md\`` |
816
+ | `{{PERSONA_SCORE_HEADERS}}` | Column headers for each persona nickname: e.g., `Alex \| Sara \| Kai` |
817
+ | `{{PERSONA_SCORE_SEPARATORS}}` | One `------` separator per persona column |
818
+ | `{{PERSONA_FIT_FORMAT}}` | Inline score display: e.g., `Alex: X/5, Sara: X/5, Kai: X/5` |
819
+ | `{{PERSONA_VPC_SECTIONS}}` | One VPC section block per persona (see format below) |
820
+ | `{{MAX_SCORE}}` | Total max score = 5 × number of personas (e.g., `15` for 3 personas) |
821
+ | `{{PERSONA_NAMES_WITH_ROLES}}` | Comma-separated: e.g., `Alex (Lead Dev), Sara (Product Founder), Kai (OSS Maintainer)` |
822
+
823
+ **`{{PERSONA_VPC_SECTIONS}}` format** — repeat for each persona in order:
824
+ ```
825
+ ### "{Nickname}" — The {Role} (X/5)
826
+ - **Jobs addressed**: {list}
827
+ - **Pains relieved**: {list with severity}
828
+ - **Gains created**: {list with impact}
829
+ ```
830
+
831
+ **Kai inclusion rule**: When `IS_OSS=true`, Kai (`sr-the-maintainer.md`) is always the last entry in persona lists and the rightmost column in scoring tables. Kai uses the evaluation criteria defined in `.claude/agents/personas/sr-the-maintainer.md` — features score high (4-5/5) for Kai when they reduce async review burden, enforce project-specific conventions, or automate release/dependency coordination; features score low (0-1/5) when they add configuration complexity or require paid tiers.
832
+
833
+ **When `IS_OSS=false`**: All Kai-related persona references are omitted. `{{MAX_SCORE}}` reduces by 5. Tables and inline scores contain only user-generated personas.
834
+
809
835
  #### GitHub Issues (`BACKLOG_PROVIDER=github`)
810
836
  - Issue fetch: `gh issue list --label "product-driven-backlog" --state open --limit 100 --json number,title,labels,body`
811
837
  - Issue create: `gh issue create --title "..." --label "..." --body "..."`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "specrails-core",
3
- "version": "1.3.0",
3
+ "version": "1.5.0",
4
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"
@@ -0,0 +1,259 @@
1
+ ---
2
+ name: "Agent Memory Inspector"
3
+ description: "Inspect and manage agent memory directories. Lists all sr-* agent memory stores, shows per-agent stats (file count, size, last modified), displays recent entries, and detects stale or orphaned files."
4
+ category: Workflow
5
+ tags: [workflow, memory, agents, maintenance, diagnostics]
6
+ ---
7
+
8
+ Inspect agent memory directories under `.claude/agent-memory/sr-*/` for **{{PROJECT_NAME}}**. Show per-agent stats, recent entries, and actionable recommendations.
9
+
10
+ **Input:** `$ARGUMENTS` — optional:
11
+ - `<agent-name>` — inspect a specific agent's memory (e.g. `sr-developer`, `sr-reviewer`)
12
+ - `--stale <days>` — flag files not modified in more than N days as stale (default: 30)
13
+ - `--prune` — delete stale files after confirmation (prints the list first, then asks)
14
+
15
+ ---
16
+
17
+ ## Phase 0: Argument Parsing
18
+
19
+ Parse `$ARGUMENTS` to set runtime variables.
20
+
21
+ **Variables to set:**
22
+
23
+ - `AGENT_FILTER` — string or empty string. Default: `""` (inspect all agents).
24
+ - `STALE_DAYS` — integer. Default: `30`.
25
+ - `PRUNE_MODE` — boolean. Default: `false`.
26
+
27
+ **Parsing rules:**
28
+
29
+ 1. Scan `$ARGUMENTS` for `--stale <N>`. If found, set `STALE_DAYS=<N>`. Validate that `<N>` is a positive integer; if not, print `Error: --stale requires a positive integer (e.g. --stale 14)` and stop. Strip from arguments.
30
+ 2. Scan for `--prune`. If found, set `PRUNE_MODE=true`. Strip from arguments.
31
+ 3. Remaining non-flag text (if any) is treated as `AGENT_FILTER`. Strip leading/trailing whitespace.
32
+
33
+ **Print active configuration:**
34
+
35
+ ```
36
+ Scanning: <all agents | agent: AGENT_FILTER> | Stale threshold: STALE_DAYS days | Prune: yes/no
37
+ ```
38
+
39
+ ---
40
+
41
+ ## Phase 1: Discover Memory Directories
42
+
43
+ Glob all directories matching `.claude/agent-memory/sr-*/`.
44
+
45
+ If no directories are found:
46
+ ```
47
+ No agent memory directories found under .claude/agent-memory/.
48
+
49
+ Agent memory is written by sr-* agents during the /sr:implement pipeline.
50
+ Run /sr:implement on a feature to generate your first memory entries.
51
+ ```
52
+ Then stop.
53
+
54
+ If `AGENT_FILTER` is set, filter to only the directory `.claude/agent-memory/<AGENT_FILTER>/`. If that directory does not exist:
55
+ ```
56
+ No memory directory found for agent: <AGENT_FILTER>
57
+
58
+ Available agents:
59
+ <list of discovered sr-* directory names>
60
+ ```
61
+ Then stop.
62
+
63
+ Set `AGENT_DIRS` = list of matching directories (full paths), sorted alphabetically.
64
+
65
+ ---
66
+
67
+ ## Phase 2: Collect Per-Agent Stats
68
+
69
+ For each directory in `AGENT_DIRS`, collect:
70
+
71
+ - `AGENT_NAME` — directory name (e.g. `sr-developer`)
72
+ - `FILE_COUNT` — total number of files (recursive, all types)
73
+ - `TOTAL_SIZE` — total size in bytes; display as human-readable (KB, MB)
74
+ - `LAST_MODIFIED` — ISO date of the most recently modified file
75
+ - `OLDEST_MODIFIED` — ISO date of the least recently modified file
76
+ - `STALE_FILES` — list of files not modified in more than `STALE_DAYS` days (full paths)
77
+ - `STALE_COUNT` — count of stale files
78
+
79
+ Use the current date to compute stale age. A file is stale if `(today - last_modified) > STALE_DAYS`.
80
+
81
+ Print a summary table after collecting all stats:
82
+
83
+ ```
84
+ ## Agent Memory Overview
85
+
86
+ | Agent | Files | Size | Last Modified | Stale (>STALE_DAYS days) |
87
+ |-------|-------|------|---------------|--------------------------|
88
+ | sr-developer | N | N KB | YYYY-MM-DD | N files |
89
+ | sr-reviewer | N | N KB | YYYY-MM-DD | N files |
90
+ | ... | ... | ... | ... | ... |
91
+
92
+ Total: N agents | N files | N KB
93
+ ```
94
+
95
+ ---
96
+
97
+ ## Phase 3: Display Recent Entries
98
+
99
+ For each agent in `AGENT_DIRS`, show the 5 most recently modified files.
100
+
101
+ Print per agent:
102
+
103
+ ```
104
+ ### <agent-name>
105
+
106
+ Recent entries (5 most recent):
107
+
108
+ | File | Size | Last Modified |
109
+ |------|------|---------------|
110
+ | common-fixes.md | 2.1 KB | 2026-03-18 |
111
+ | ... | ... | ... |
112
+ ```
113
+
114
+ If the agent directory has fewer than 5 files, show all of them.
115
+
116
+ If `AGENT_FILTER` is set (single-agent mode), show the full content of each file up to 50 lines. For files exceeding 50 lines, print the first 50 lines followed by:
117
+ ```
118
+ ... (N more lines — view full file at <relative-path>)
119
+ ```
120
+
121
+ ---
122
+
123
+ ## Phase 4: Orphan Detection
124
+
125
+ An **orphaned** memory directory is one whose agent name does not correspond to a known sr-agent persona.
126
+
127
+ Known sr-agent names (check for exact match):
128
+ `sr-architect`, `sr-developer`, `sr-test-writer`, `sr-reviewer`, `sr-frontend-reviewer`, `sr-backend-reviewer`, `sr-security-reviewer`, `sr-doc-sync`, `sr-product-manager`
129
+
130
+ For each directory in `AGENT_DIRS`, check whether its `AGENT_NAME` is in the known list. Collect non-matching directories as `ORPHANED_DIRS`.
131
+
132
+ If `ORPHANED_DIRS` is non-empty, print:
133
+
134
+ ```
135
+ ### Orphaned Memory Directories
136
+
137
+ The following directories do not match any known sr-agent name and may be leftover from renamed or removed agents:
138
+
139
+ | Directory | Files | Size | Recommendation |
140
+ |-----------|-------|------|----------------|
141
+ | sr-old-agent | N | N KB | Review and delete if no longer needed |
142
+ ```
143
+
144
+ If `ORPHANED_DIRS` is empty: skip this section entirely.
145
+
146
+ ---
147
+
148
+ ## Phase 5: Stale File Report
149
+
150
+ Collect all stale files across all agents (from Phase 2 `STALE_FILES` lists).
151
+
152
+ If no stale files exist:
153
+ ```
154
+ No stale files found (threshold: STALE_DAYS days). Memory is up to date.
155
+ ```
156
+ Skip the rest of Phase 5.
157
+
158
+ Otherwise, print:
159
+
160
+ ```
161
+ ### Stale Files (not modified in >STALE_DAYS days)
162
+
163
+ | Agent | File | Size | Last Modified | Age (days) |
164
+ |-------|------|------|---------------|------------|
165
+ | sr-developer | common-fixes.md | 1.2 KB | 2026-01-10 | 69 |
166
+ | ... | ... | ... | ... | ... |
167
+
168
+ N stale files total (N KB).
169
+ ```
170
+
171
+ ---
172
+
173
+ ## Phase 6: Prune (if --prune)
174
+
175
+ Skip this phase if `PRUNE_MODE=false`.
176
+
177
+ If `PRUNE_MODE=true` and there are no stale files and no orphaned directories:
178
+ ```
179
+ Nothing to prune. All memory files are within the STALE_DAYS-day threshold.
180
+ ```
181
+ Then stop.
182
+
183
+ Otherwise, print the full list of files and directories that will be deleted:
184
+
185
+ ```
186
+ ## Files to Delete
187
+
188
+ The following N files will be permanently deleted:
189
+
190
+ Stale files:
191
+ - .claude/agent-memory/sr-developer/common-fixes.md (69 days old)
192
+ - ...
193
+
194
+ Orphaned directories:
195
+ - .claude/agent-memory/sr-old-agent/ (N files, N KB)
196
+
197
+ Proceed? [y/N]:
198
+ ```
199
+
200
+ Wait for user input.
201
+
202
+ - If the user enters `y` or `Y`:
203
+ - Delete each stale file individually.
204
+ - Delete each orphaned directory recursively.
205
+ - Print a confirmation for each deletion: `Deleted: <path>`
206
+ - Print a summary:
207
+ ```
208
+ Pruned N files (N KB freed).
209
+ ```
210
+ - If the user enters anything else (or presses Enter):
211
+ - Print: `Prune cancelled. No files were deleted.`
212
+ - Stop.
213
+
214
+ ---
215
+
216
+ ## Phase 7: Recommendations
217
+
218
+ Print a final recommendations section based on findings:
219
+
220
+ ```
221
+ ## Recommendations
222
+
223
+ <one or more of the following, based on findings>
224
+ ```
225
+
226
+ **Recommendation rules (print only applicable ones):**
227
+
228
+ 1. **Prune stale data** — if `STALE_COUNT > 0` across any agent and `PRUNE_MODE=false`:
229
+ ```
230
+ - N stale files detected. Run `/sr:memory-inspect --prune` to remove them and free N KB.
231
+ ```
232
+
233
+ 2. **Investigate large memory** — if any single agent's `TOTAL_SIZE > 1 MB`:
234
+ ```
235
+ - <agent-name> memory exceeds 1 MB (TOTAL_SIZE). Consider reviewing large files:
236
+ <list files over 100 KB>
237
+ ```
238
+
239
+ 3. **Orphaned directories** — if `ORPHANED_DIRS` is non-empty:
240
+ ```
241
+ - N orphaned director(y|ies) found. Review and delete manually if no longer needed.
242
+ ```
243
+
244
+ 4. **Empty memory directories** — if any agent directory has `FILE_COUNT = 0`:
245
+ ```
246
+ - <agent-name> memory directory is empty. It may be safe to delete:
247
+ rm -rf .claude/agent-memory/<agent-name>/
248
+ ```
249
+
250
+ 5. **Gitignore advisory** — check whether `.claude/agent-memory` appears in `.gitignore`. If not:
251
+ ```
252
+ - Agent memory is local runtime state. Add to .gitignore:
253
+ echo '.claude/agent-memory/' >> .gitignore
254
+ ```
255
+
256
+ If no recommendations apply, print:
257
+ ```
258
+ All agent memory looks healthy. No action required.
259
+ ```