selfish-pipeline 1.1.1 → 1.2.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/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +1 -1
- package/README.md +1 -1
- package/commands/architect.md +10 -7
- package/commands/auto.md +62 -18
- package/commands/debug.md +10 -6
- package/commands/implement.md +17 -0
- package/commands/plan.md +25 -11
- package/commands/review.md +33 -5
- package/commands/spec.md +29 -15
- package/commands/tasks.md +23 -10
- package/commands/test.md +9 -5
- package/docs/critic-loop-rules.md +79 -4
- package/docs/nfr-templates.md +40 -0
- package/hooks/hooks.json +21 -10
- package/package.json +1 -1
- package/scripts/selfish-bash-guard.sh +11 -1
- package/scripts/selfish-parallel-validate.sh +158 -0
- package/scripts/selfish-pipeline-manage.sh +55 -2
- package/scripts/selfish-preflight-check.sh +102 -0
- package/scripts/selfish-timeline-log.sh +97 -0
|
@@ -6,14 +6,14 @@
|
|
|
6
6
|
},
|
|
7
7
|
"metadata": {
|
|
8
8
|
"description": "Automated pipeline for Claude Code — spec → plan → tasks → implement → review → clean",
|
|
9
|
-
"version": "1.
|
|
9
|
+
"version": "1.2.0"
|
|
10
10
|
},
|
|
11
11
|
"plugins": [
|
|
12
12
|
{
|
|
13
13
|
"name": "selfish",
|
|
14
14
|
"source": "./",
|
|
15
15
|
"description": "Automated pipeline for Claude Code. Automates the full development cycle: spec → plan → tasks → implement → review → clean.",
|
|
16
|
-
"version": "1.
|
|
16
|
+
"version": "1.2.0",
|
|
17
17
|
"category": "automation",
|
|
18
18
|
"tags": ["pipeline", "automation", "spec", "plan", "implement", "review", "critic-loop"]
|
|
19
19
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "selfish",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Automated pipeline for Claude Code. Automates the full development cycle: spec → plan → tasks → implement → review → clean.",
|
|
5
5
|
"author": { "name": "jhlee0409", "email": "relee6203@gmail.com" },
|
|
6
6
|
"homepage": "https://github.com/jhlee0409/selfish-pipeline",
|
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/selfish-pipeline)
|
|
6
6
|
[](./LICENSE)
|
|
7
|
-
[](#how-it-works)
|
|
8
8
|
[](#15-hook-events)
|
|
9
9
|
[](#18-slash-commands)
|
|
10
10
|
|
package/commands/architect.md
CHANGED
|
@@ -18,7 +18,7 @@ model: sonnet
|
|
|
18
18
|
# /selfish:architect — Architecture Analysis and Design Advice
|
|
19
19
|
|
|
20
20
|
> Analyzes the codebase architecture and records design decisions.
|
|
21
|
-
> Ensures design quality through
|
|
21
|
+
> Ensures design quality through convergence-based Critic Loop. **Read-only** — does not modify code.
|
|
22
22
|
|
|
23
23
|
## Arguments
|
|
24
24
|
|
|
@@ -89,10 +89,12 @@ Structure analysis results and **print to console**:
|
|
|
89
89
|
{config.architecture} rule violations, import direction validation
|
|
90
90
|
```
|
|
91
91
|
|
|
92
|
-
### 4. Critic Loop
|
|
92
|
+
### 4. Critic Loop
|
|
93
93
|
|
|
94
94
|
> **Always** read `docs/critic-loop-rules.md` first and follow it.
|
|
95
95
|
|
|
96
|
+
Run the critic loop until convergence. Safety cap: 7 passes.
|
|
97
|
+
|
|
96
98
|
| Criterion | Validation |
|
|
97
99
|
|-----------|------------|
|
|
98
100
|
| **FEASIBILITY** | Is the suggestion achievable in the current codebase? |
|
|
@@ -100,10 +102,11 @@ Structure analysis results and **print to console**:
|
|
|
100
102
|
| **COMPATIBILITY** | Is it compatible with existing code? Are there breaking changes? |
|
|
101
103
|
| **ARCHITECTURE** | Does it comply with {config.architecture} rules? |
|
|
102
104
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
105
|
+
**On FAIL**: auto-fix and continue to next pass.
|
|
106
|
+
**On ESCALATE**: pause, present options to user, apply choice, resume.
|
|
107
|
+
**On DEFER**: record reason, mark criterion clean, continue.
|
|
108
|
+
**On CONVERGE**: `✓ Critic converged ({N} passes, {M} fixes, {E} escalations)`
|
|
109
|
+
**On SAFETY CAP**: `⚠ Critic safety cap ({N} passes). Review recommended.`
|
|
107
110
|
|
|
108
111
|
### 5. Save ADR (for design decisions)
|
|
109
112
|
|
|
@@ -125,7 +128,7 @@ If ADR type, save to `memory/decisions/{YYYY-MM-DD}-{topic}.md`:
|
|
|
125
128
|
Architecture analysis complete
|
|
126
129
|
├─ Type: {structure analysis | design question | ADR | refactoring evaluation}
|
|
127
130
|
├─ Findings: {count}
|
|
128
|
-
├─ Critic: {N}
|
|
131
|
+
├─ Critic: converged ({N} passes, {M} fixes, {E} escalations)
|
|
129
132
|
├─ ADR: {saved | n/a}
|
|
130
133
|
└─ Suggestion: {key suggestion in one line}
|
|
131
134
|
```
|
package/commands/auto.md
CHANGED
|
@@ -35,7 +35,7 @@ If config file is missing: print "`.claude/selfish.config.md` not found. Create
|
|
|
35
35
|
## Critic Loop Rules (common to all phases)
|
|
36
36
|
|
|
37
37
|
> **Always** read `docs/critic-loop-rules.md` first and follow it.
|
|
38
|
-
> Core: minimum 1 concern per criterion + mandatory Adversarial failure scenario each pass + quantitative evidence required. "PASS" as a single word is prohibited.
|
|
38
|
+
> Core: minimum 1 concern per criterion + mandatory Adversarial failure scenario each pass + quantitative evidence required. "PASS" as a single word is prohibited. Uses convergence-based termination with 4 verdicts (PASS/FAIL/ESCALATE/DEFER). On ESCALATE: pause and present options to user even in auto mode.
|
|
39
39
|
|
|
40
40
|
---
|
|
41
41
|
|
|
@@ -46,6 +46,12 @@ If config file is missing: print "`.claude/selfish.config.md` not found. Create
|
|
|
46
46
|
1. If `$ARGUMENTS` is empty → print "Please enter a feature description." and abort
|
|
47
47
|
2. Check current branch → `BRANCH_NAME`
|
|
48
48
|
3. Determine feature name (2-3 keywords → kebab-case)
|
|
49
|
+
3.5. **Preflight Check**:
|
|
50
|
+
```bash
|
|
51
|
+
"${CLAUDE_PLUGIN_ROOT}/scripts/selfish-preflight-check.sh"
|
|
52
|
+
```
|
|
53
|
+
- If exit 1 (hard failure) → print error and **abort**
|
|
54
|
+
- If warnings only (exit 0) → print warnings and continue
|
|
49
55
|
4. **Activate Pipeline Flag** (hook integration):
|
|
50
56
|
```bash
|
|
51
57
|
"${CLAUDE_PLUGIN_ROOT}/scripts/selfish-pipeline-manage.sh" start {feature}
|
|
@@ -53,6 +59,7 @@ If config file is missing: print "`.claude/selfish.config.md` not found. Create
|
|
|
53
59
|
- Safety Snapshot created automatically (`selfish/pre-auto` git tag)
|
|
54
60
|
- Stop Gate Hook activated (blocks response termination on CI failure)
|
|
55
61
|
- File change tracking started
|
|
62
|
+
- Timeline log: `"${CLAUDE_PLUGIN_ROOT}/scripts/selfish-pipeline-manage.sh" log pipeline-start "Auto pipeline: {feature}"`
|
|
56
63
|
5. Create `specs/{feature}/` directory → **record path as `PIPELINE_ARTIFACT_DIR`** (for Clean scope)
|
|
57
64
|
6. Start notification:
|
|
58
65
|
```
|
|
@@ -71,13 +78,16 @@ Execute `/selfish:spec` logic inline:
|
|
|
71
78
|
2. Create `specs/{feature}/spec.md`
|
|
72
79
|
3. `[NEEDS CLARIFICATION]` items are **auto-resolved with best-guess** (clarify skipped)
|
|
73
80
|
- Tag auto-resolved items with `[AUTO-RESOLVED]`
|
|
74
|
-
4. **
|
|
81
|
+
4. **Retrospective check**: if `memory/retrospectives/` exists, load and check:
|
|
82
|
+
- Were there previous `[AUTO-RESOLVED]` items that turned out wrong? Flag similar patterns.
|
|
83
|
+
- Were there scope-related issues in past specs? Warn about similar ambiguities.
|
|
84
|
+
5. **Critic Loop until convergence** (safety cap: 5, follow Critic Loop rules):
|
|
75
85
|
- COMPLETENESS: does every User Story have acceptance scenarios? Any missing requirements?
|
|
76
86
|
- MEASURABILITY: are success criteria measurable, not subjective? **Is quantitative evidence provided for numerical targets?**
|
|
77
87
|
- INDEPENDENCE: are implementation details (code, library names) absent from the spec?
|
|
78
88
|
- EDGE_CASES: are at least 2 identified? Any missing boundary conditions?
|
|
79
|
-
- FAIL
|
|
80
|
-
|
|
89
|
+
- FAIL → auto-fix and continue. ESCALATE → pause, present options, resume after response. DEFER → record reason, mark clean.
|
|
90
|
+
6. Progress: `✓ 1/6 Spec complete (US: {N}, FR: {N}, Critic: converged ({N} passes, {M} fixes, {E} escalations))`
|
|
81
91
|
|
|
82
92
|
### Phase 2: Plan (2/6)
|
|
83
93
|
|
|
@@ -89,7 +99,7 @@ Execute `/selfish:plan` logic inline:
|
|
|
89
99
|
2. If technical uncertainties exist → auto-resolve via WebSearch/code exploration → create research.md
|
|
90
100
|
3. Create `specs/{feature}/plan.md`
|
|
91
101
|
- **If setting numerical targets (line counts etc.), include structure-analysis-based estimates** (e.g., "function A ~50 lines, component B ~80 lines → total ~130 lines")
|
|
92
|
-
4. **Critic Loop
|
|
102
|
+
4. **Critic Loop until convergence** (safety cap: 7, follow Critic Loop rules):
|
|
93
103
|
- Criteria: COMPLETENESS, FEASIBILITY, ARCHITECTURE, RISK, PRINCIPLES
|
|
94
104
|
- **RISK criterion mandatory checks**:
|
|
95
105
|
- Enumerate **at least 3** `{config.ci}` failure scenarios and describe mitigation
|
|
@@ -97,7 +107,8 @@ Execute `/selfish:plan` logic inline:
|
|
|
97
107
|
- Consider `{config.framework}` characteristics (server/client boundary etc.)
|
|
98
108
|
- **ARCHITECTURE criterion**: explicitly describe import paths for moved/created files and pre-validate against `{config.architecture}` rules
|
|
99
109
|
- Each pass must **explicitly explore what was missed in the previous pass** ("Pass 2: {X} was missed in pass 1. Further review: ...")
|
|
100
|
-
|
|
110
|
+
- FAIL → auto-fix and continue. ESCALATE → pause, present options, resume after response. DEFER → record reason, mark clean.
|
|
111
|
+
5. Progress: `✓ 2/6 Plan complete (Critic: converged ({N} passes, {M} fixes, {E} escalations), files: {N})`
|
|
101
112
|
|
|
102
113
|
### Phase 3: Tasks (3/6)
|
|
103
114
|
|
|
@@ -113,11 +124,15 @@ Execute `/selfish:tasks` logic inline:
|
|
|
113
124
|
- Validate dependency graph is a DAG (no circular references)
|
|
114
125
|
- [P] tasks **must be executed in parallel** in Phase 4 (declaring [P] then running sequentially is prohibited)
|
|
115
126
|
4. Coverage mapping (FR → Task)
|
|
116
|
-
5. **
|
|
127
|
+
5. **Retrospective check**: if `memory/retrospectives/` exists, load and check:
|
|
128
|
+
- Were there previous parallel conflict issues ([P] file overlaps)? Flag similar file patterns.
|
|
129
|
+
- Were there tasks that were over-decomposed or under-decomposed? Adjust granularity.
|
|
130
|
+
6. **Critic Loop until convergence** (safety cap: 5, follow Critic Loop rules):
|
|
117
131
|
- COVERAGE: is every FR/NFR mapped to at least 1 task?
|
|
118
132
|
- DEPENDENCIES: is the dependency graph a valid DAG? Do [P] tasks have no file overlaps?
|
|
119
|
-
|
|
120
|
-
7.
|
|
133
|
+
- FAIL → auto-fix and continue. ESCALATE → pause, present options, resume after response. DEFER → record reason, mark clean.
|
|
134
|
+
7. Create `specs/{feature}/tasks.md`
|
|
135
|
+
8. Progress: `✓ 3/6 Tasks complete (tasks: {N}, parallel: {N}, Critic: converged ({N} passes, {M} fixes, {E} escalations))`
|
|
121
136
|
|
|
122
137
|
### Phase 4: Implement (4/6)
|
|
123
138
|
|
|
@@ -157,6 +172,7 @@ Execute `/selfish:implement` logic inline with **dependency-aware orchestration*
|
|
|
157
172
|
```
|
|
158
173
|
|
|
159
174
|
6. Perform **3-step gate** on each Implementation Phase completion — **always** read `docs/phase-gate-protocol.md` first. Cannot advance to next phase without passing the gate.
|
|
175
|
+
- On gate pass: create phase rollback point `"${CLAUDE_PLUGIN_ROOT}/scripts/selfish-pipeline-manage.sh" phase-tag {phase_number}`
|
|
160
176
|
7. Real-time `[x]` updates in tasks.md
|
|
161
177
|
8. After full completion, run `{config.ci}` final verification
|
|
162
178
|
- On pass: `"${CLAUDE_PLUGIN_ROOT}/scripts/selfish-pipeline-manage.sh" ci-pass` (releases Stop Gate)
|
|
@@ -171,13 +187,17 @@ Execute `/selfish:review` logic inline:
|
|
|
171
187
|
|
|
172
188
|
1. Review implemented changed files (`git diff HEAD`)
|
|
173
189
|
2. Check code quality, `{config.architecture}` rules, security, performance, `{config.code_style}` pattern compliance
|
|
174
|
-
3. **
|
|
190
|
+
3. **Retrospective check**: if `memory/retrospectives/` exists, load and check:
|
|
191
|
+
- Were there recurring Critical finding categories in past reviews? Prioritize those perspectives.
|
|
192
|
+
- Were there false positives that wasted effort? Reduce sensitivity for those patterns.
|
|
193
|
+
4. **Critic Loop until convergence** (safety cap: 5, follow Critic Loop rules):
|
|
175
194
|
- COMPLETENESS: cross-check every SC (success criterion) from spec.md one by one. Provide specific metrics if falling short.
|
|
176
195
|
- PRECISION: are there unnecessary changes? Are there out-of-scope modifications?
|
|
177
|
-
|
|
196
|
+
- FAIL → auto-fix and continue. ESCALATE → pause, present options, resume after response. DEFER → record reason, mark clean.
|
|
197
|
+
5. **Handling SC shortfalls**:
|
|
178
198
|
- Fixable → attempt auto-fix → re-run `{config.ci}` verification
|
|
179
199
|
- Not fixable → state in final report with reason (no post-hoc rationalization; record as Plan-phase target-setting error)
|
|
180
|
-
|
|
200
|
+
6. Progress: `✓ 5/6 Review complete (Critical:{N} Warning:{N} Info:{N}, SC shortfalls: {N})`
|
|
181
201
|
|
|
182
202
|
### Phase 6: Clean (6/6)
|
|
183
203
|
|
|
@@ -199,24 +219,47 @@ Artifact cleanup and codebase hygiene check after implementation and review:
|
|
|
199
219
|
4. **Memory update** (if applicable):
|
|
200
220
|
- Reusable patterns found during pipeline → record in `memory/`
|
|
201
221
|
- If there were `[AUTO-RESOLVED]` items → record decisions in `memory/decisions/`
|
|
202
|
-
- **If retrospective.md exists** → record as patterns missed by the Plan phase Critic Loop in `memory/` (reuse as RISK checklist items in future runs)
|
|
203
|
-
|
|
222
|
+
- **If retrospective.md exists** → record as patterns missed by the Plan phase Critic Loop in `memory/retrospectives/` (reuse as RISK checklist items in future runs)
|
|
223
|
+
- **If review-report.md exists** → copy to `memory/reviews/{feature}-{date}.md` before specs/ deletion
|
|
224
|
+
5. **Quality report** (structured pipeline metrics):
|
|
225
|
+
- Generate `memory/quality-history/{feature}-{date}.json` with the following structure:
|
|
226
|
+
```json
|
|
227
|
+
{
|
|
228
|
+
"feature": "{feature}",
|
|
229
|
+
"date": "{YYYY-MM-DD}",
|
|
230
|
+
"phases": {
|
|
231
|
+
"spec": { "user_stories": N, "requirements": { "FR": N, "NFR": N }, "auto_resolved": N, "critic_passes": N, "critic_fixes": N, "escalations": N },
|
|
232
|
+
"plan": { "files_planned": N, "critic_passes": N, "critic_fixes": N, "escalations": N },
|
|
233
|
+
"tasks": { "total": N, "parallel": N, "phases": N, "critic_passes": N, "critic_fixes": N, "escalations": N },
|
|
234
|
+
"implement": { "completed": N, "total": N, "ci_passes": N, "ci_failures": N },
|
|
235
|
+
"review": { "critical": N, "warning": N, "info": N, "sc_shortfalls": N, "critic_passes": N, "critic_fixes": N, "escalations": N }
|
|
236
|
+
},
|
|
237
|
+
"totals": { "changed_files": N, "auto_resolved": N, "escalations": N }
|
|
238
|
+
}
|
|
239
|
+
```
|
|
240
|
+
- Create `memory/quality-history/` directory if it does not exist
|
|
241
|
+
6. **Checkpoint reset**:
|
|
204
242
|
- Clear `memory/checkpoint.md` (pipeline complete = session goal achieved)
|
|
205
|
-
|
|
243
|
+
7. **Timeline finalize**:
|
|
244
|
+
```bash
|
|
245
|
+
"${CLAUDE_PLUGIN_ROOT}/scripts/selfish-pipeline-manage.sh" log pipeline-end "Pipeline complete: {feature}"
|
|
246
|
+
```
|
|
247
|
+
8. **Release Pipeline Flag** (hook integration):
|
|
206
248
|
```bash
|
|
207
249
|
"${CLAUDE_PLUGIN_ROOT}/scripts/selfish-pipeline-manage.sh" end
|
|
208
250
|
```
|
|
209
251
|
- Stop Gate Hook deactivated
|
|
210
252
|
- Change tracking log deleted
|
|
211
253
|
- Safety tag removed (successful completion)
|
|
212
|
-
|
|
254
|
+
- Phase rollback tags removed (handled automatically by pipeline end)
|
|
255
|
+
9. Progress: `✓ 6/6 Clean complete (deleted: {N}, dead code: {N}, CI: ✓)`
|
|
213
256
|
|
|
214
257
|
### Final Output
|
|
215
258
|
|
|
216
259
|
```
|
|
217
260
|
Auto pipeline complete: {feature}
|
|
218
261
|
├─ Spec: US {N}, FR {N}
|
|
219
|
-
├─ Plan: Critic {
|
|
262
|
+
├─ Plan: Critic converged ({N} passes, {M} fixes, {E} escalations), research {present/absent}
|
|
220
263
|
├─ Tasks: {total} (parallel {N})
|
|
221
264
|
├─ Implement: {completed}/{total} tasks, CI ✓, Checkpoint ✓
|
|
222
265
|
├─ Review: Critical:{N} Warning:{N} Info:{N}, SC shortfalls: {N}
|
|
@@ -253,7 +296,8 @@ Pipeline aborted (Phase {N}/6)
|
|
|
253
296
|
- **Large feature warning**: warn before starting if more than 5 User Stories are expected.
|
|
254
297
|
- **Read existing code first**: always read existing files before modifying. Do not blindly generate code.
|
|
255
298
|
- **Follow project rules**: project rules in `selfish.config.md` and `CLAUDE.md` take priority.
|
|
256
|
-
- **Critic Loop is not a ritual**: a single "PASS" line is equivalent to not running Critic at all. Always follow the format in the Critic Loop rules section.
|
|
299
|
+
- **Critic Loop is not a ritual**: a single "PASS" line is equivalent to not running Critic at all. Always follow the format in the Critic Loop rules section. Critic uses convergence-based termination — it may finish in 1 pass or take several, depending on the output quality.
|
|
300
|
+
- **ESCALATE pauses auto mode**: when a Critic finds an ambiguous issue requiring user judgment, the pipeline pauses and presents options via AskUserQuestion. Auto mode automates clear decisions but escalates ambiguous ones.
|
|
257
301
|
- **[P] parallel is mandatory**: if a [P] marker is assigned in tasks.md, it must be executed in parallel. Orchestration mode (batch vs swarm) is selected automatically based on task count. Sequential substitution is prohibited.
|
|
258
302
|
- **Swarm mode is automatic**: when a phase has 6+ [P] tasks, swarm workers self-organize via TaskList/TaskUpdate. Do not manually batch.
|
|
259
303
|
- **No out-of-scope deletion**: do not delete files/directories in Clean that were not created by the current pipeline.
|
package/commands/debug.md
CHANGED
|
@@ -8,7 +8,7 @@ model: sonnet
|
|
|
8
8
|
# /selfish:debug — Bug Diagnosis and Fix
|
|
9
9
|
|
|
10
10
|
> Analyzes the root cause of a bug and fixes it.
|
|
11
|
-
> Validates the safety and accuracy of the fix with
|
|
11
|
+
> Validates the safety and accuracy of the fix with convergence-based Critic Loop.
|
|
12
12
|
|
|
13
13
|
## Arguments
|
|
14
14
|
|
|
@@ -59,18 +59,22 @@ Verify starting from highest probability.
|
|
|
59
59
|
2. **Impact analysis**: verify what effect the fix has on other code
|
|
60
60
|
3. **Apply fix**
|
|
61
61
|
|
|
62
|
-
### 5. Critic Loop
|
|
62
|
+
### 5. Critic Loop
|
|
63
63
|
|
|
64
64
|
> **Always** read `docs/critic-loop-rules.md` first and follow it.
|
|
65
65
|
|
|
66
|
+
Run the critic loop until convergence. Safety cap: 5 passes.
|
|
67
|
+
|
|
66
68
|
| Criterion | Validation |
|
|
67
69
|
|-----------|------------|
|
|
68
70
|
| **SAFETY** | Does the fix break any other functionality? Any side effects? |
|
|
69
71
|
| **CORRECTNESS** | Does it actually resolve the root cause? Or just mask the symptom? |
|
|
70
72
|
|
|
71
|
-
On FAIL
|
|
72
|
-
|
|
73
|
-
|
|
73
|
+
**On FAIL**: auto-fix and continue to next pass.
|
|
74
|
+
**On ESCALATE**: pause, present options to user, apply choice, resume.
|
|
75
|
+
**On DEFER**: record reason, mark criterion clean, continue.
|
|
76
|
+
**On CONVERGE**: `✓ Critic converged ({N} passes, {M} fixes, {E} escalations)`
|
|
77
|
+
**On SAFETY CAP**: `⚠ Critic safety cap ({N} passes). Review recommended.`
|
|
74
78
|
|
|
75
79
|
### 6. Verification
|
|
76
80
|
|
|
@@ -86,7 +90,7 @@ Retry after fixing on failure (max 3 attempts).
|
|
|
86
90
|
Debug complete
|
|
87
91
|
├─ Root cause: {one-line summary}
|
|
88
92
|
├─ Fixed files: {file list}
|
|
89
|
-
├─ Critic: {N} passes
|
|
93
|
+
├─ Critic: converged ({N} passes, {M} fixes, {E} escalations)
|
|
90
94
|
├─ Verified: typecheck + lint passed
|
|
91
95
|
└─ Impact scope: {affected components/features}
|
|
92
96
|
```
|
package/commands/implement.md
CHANGED
|
@@ -124,6 +124,17 @@ When a phase has more than 5 parallelizable tasks, use the **self-organizing swa
|
|
|
124
124
|
4. **Wait for all workers to exit** — workers naturally terminate when the pool is empty
|
|
125
125
|
5. **Verify**: check TaskList for any incomplete tasks → re-spawn workers if needed
|
|
126
126
|
|
|
127
|
+
#### Swarm Worker Failure Recovery
|
|
128
|
+
|
|
129
|
+
When a worker agent exits with error (non-zero return or timeout):
|
|
130
|
+
1. Scan TaskList for tasks with status `in_progress` that have no active worker
|
|
131
|
+
2. Reset each orphaned task: `TaskUpdate(taskId, status: "pending", owner: "")`
|
|
132
|
+
3. Track retry count per task (max 2 retries)
|
|
133
|
+
4. If a task fails 3 times → mark as `failed`, report to user: `"T{ID} failed after 3 attempts: {last error}"`
|
|
134
|
+
5. Re-spawn replacement workers for remaining tasks
|
|
135
|
+
|
|
136
|
+
> Workers should wrap their implement-complete loop in error handling so a single task failure doesn't crash the entire worker.
|
|
137
|
+
|
|
127
138
|
> Swarm workers self-balance: fast workers claim more tasks. No batch boundaries needed.
|
|
128
139
|
|
|
129
140
|
#### Dependency Resolution
|
|
@@ -137,6 +148,12 @@ When a phase has more than 5 parallelizable tasks, use the **self-organizing swa
|
|
|
137
148
|
> **Always** read `docs/phase-gate-protocol.md` first and perform the 3 steps (CI gate → Mini-Review → Auto-Checkpoint) in order.
|
|
138
149
|
> Cannot advance to the next phase without passing the gate. Abort and report to user after 3 consecutive CI failures.
|
|
139
150
|
|
|
151
|
+
After passing the gate, create a phase rollback point:
|
|
152
|
+
```bash
|
|
153
|
+
"${CLAUDE_PLUGIN_ROOT}/scripts/selfish-pipeline-manage.sh" phase-tag {phase_number}
|
|
154
|
+
```
|
|
155
|
+
This enables granular rollback: `git reset --hard selfish/phase-{N}` restores state after Phase N completed.
|
|
156
|
+
|
|
140
157
|
### 4. Task Execution Pattern
|
|
141
158
|
|
|
142
159
|
For each task:
|
package/commands/plan.md
CHANGED
|
@@ -7,7 +7,7 @@ model: sonnet
|
|
|
7
7
|
# /selfish:plan — Implementation Design
|
|
8
8
|
|
|
9
9
|
> Generates an implementation plan (plan.md) based on the feature specification (spec.md).
|
|
10
|
-
> Ensures quality with
|
|
10
|
+
> Ensures quality with convergence-based Critic Loop and runs research in parallel when needed.
|
|
11
11
|
|
|
12
12
|
## Arguments
|
|
13
13
|
|
|
@@ -110,6 +110,21 @@ Create `specs/{feature}/plan.md`. **Must** follow the structure below:
|
|
|
110
110
|
|------|--------|------------|
|
|
111
111
|
| {risk} | {H/M/L} | {approach} |
|
|
112
112
|
|
|
113
|
+
## Alternative Design
|
|
114
|
+
### Approach A: {chosen approach name}
|
|
115
|
+
{Brief description — this is the approach detailed above}
|
|
116
|
+
|
|
117
|
+
### Approach B: {alternative approach name}
|
|
118
|
+
{Brief description of a meaningfully different approach}
|
|
119
|
+
|
|
120
|
+
| Criterion | Approach A | Approach B |
|
|
121
|
+
|-----------|-----------|-----------|
|
|
122
|
+
| Complexity | {evaluation} | {evaluation} |
|
|
123
|
+
| Risk | {evaluation} | {evaluation} |
|
|
124
|
+
| Maintainability | {evaluation} | {evaluation} |
|
|
125
|
+
|
|
126
|
+
**Decision**: Approach {A/B} — {1-sentence rationale}
|
|
127
|
+
|
|
113
128
|
## Phase Breakdown
|
|
114
129
|
### Phase 1: Setup
|
|
115
130
|
{project structure, type definitions, configuration}
|
|
@@ -124,26 +139,25 @@ Create `specs/{feature}/plan.md`. **Must** follow the structure below:
|
|
|
124
139
|
{error handling, performance optimization, tests}
|
|
125
140
|
```
|
|
126
141
|
|
|
127
|
-
### 5. Critic Loop
|
|
142
|
+
### 5. Critic Loop
|
|
128
143
|
|
|
129
144
|
> **Always** read `docs/critic-loop-rules.md` first and follow it.
|
|
130
145
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
Validate against these 5 criteria each pass:
|
|
146
|
+
Run the critic loop until convergence. Safety cap: 7 passes.
|
|
134
147
|
|
|
135
148
|
| Criterion | Validation |
|
|
136
149
|
|-----------|------------|
|
|
137
150
|
| **COMPLETENESS** | Are all requirements (FR-*) from spec.md reflected in the plan? |
|
|
138
151
|
| **FEASIBILITY** | Is it compatible with the existing codebase? Are dependencies available? |
|
|
139
152
|
| **ARCHITECTURE** | Does it comply with {config.architecture} rules? |
|
|
140
|
-
| **RISK** | Are there any unidentified risks? |
|
|
153
|
+
| **RISK** | Are there any unidentified risks? Additionally, if `memory/retrospectives/` directory contains files from previous pipeline runs, load each file and check whether the current plan addresses the patterns recorded there. Tag matched patterns with `[RETRO-CHECKED]`. |
|
|
141
154
|
| **PRINCIPLES** | Does it not violate the MUST principles in principles.md? |
|
|
142
155
|
|
|
143
|
-
**
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
156
|
+
**On FAIL**: auto-fix and continue to next pass.
|
|
157
|
+
**On ESCALATE**: pause, present options to user, apply choice, resume.
|
|
158
|
+
**On DEFER**: record reason, mark criterion clean, continue.
|
|
159
|
+
**On CONVERGE**: `✓ Critic converged ({N} passes, {M} fixes, {E} escalations)`
|
|
160
|
+
**On SAFETY CAP**: `⚠ Critic safety cap ({N} passes). Review recommended.`
|
|
147
161
|
|
|
148
162
|
### 6. Agent Teams (if needed)
|
|
149
163
|
|
|
@@ -161,7 +175,7 @@ Task("Research: {topic2}", subagent_type: "general-purpose")
|
|
|
161
175
|
Plan generated
|
|
162
176
|
├─ specs/{feature}/plan.md
|
|
163
177
|
├─ specs/{feature}/research.md (if research was performed)
|
|
164
|
-
├─ Critic: {N} passes,
|
|
178
|
+
├─ Critic: converged ({N} passes, {M} fixes, {E} escalations)
|
|
165
179
|
└─ Next step: /selfish:tasks
|
|
166
180
|
```
|
|
167
181
|
|
package/commands/review.md
CHANGED
|
@@ -14,7 +14,7 @@ model: sonnet
|
|
|
14
14
|
# /selfish:review — Code Review
|
|
15
15
|
|
|
16
16
|
> Performs a comprehensive review of changed code (quality, security, performance, architecture compliance).
|
|
17
|
-
> Validates completeness of the review itself with
|
|
17
|
+
> Validates completeness of the review itself with convergence-based Critic Loop.
|
|
18
18
|
|
|
19
19
|
## Arguments
|
|
20
20
|
|
|
@@ -131,24 +131,52 @@ For each changed file, examine from the following perspectives:
|
|
|
131
131
|
- {1-2 things done well}
|
|
132
132
|
```
|
|
133
133
|
|
|
134
|
-
### 5.
|
|
134
|
+
### 5. Retrospective Check
|
|
135
|
+
|
|
136
|
+
If `memory/retrospectives/` directory exists, load retrospective files and check:
|
|
137
|
+
- Were there recurring Critical finding categories in past reviews? Prioritize those perspectives.
|
|
138
|
+
- Were there false positives that wasted effort? Reduce sensitivity for those patterns.
|
|
139
|
+
|
|
140
|
+
### 6. Critic Loop
|
|
135
141
|
|
|
136
142
|
> **Always** read `docs/critic-loop-rules.md` first and follow it.
|
|
137
143
|
|
|
144
|
+
Run the critic loop until convergence. Safety cap: 5 passes.
|
|
145
|
+
|
|
138
146
|
| Criterion | Validation |
|
|
139
147
|
|-----------|------------|
|
|
140
148
|
| **COMPLETENESS** | Were all changed files reviewed? Are there any missed perspectives? |
|
|
141
149
|
| **PRECISION** | Are the findings actual issues, not false positives? |
|
|
142
150
|
|
|
143
|
-
On FAIL
|
|
151
|
+
**On FAIL**: auto-fix and continue to next pass.
|
|
152
|
+
**On ESCALATE**: pause, present options to user, apply choice, resume.
|
|
153
|
+
**On DEFER**: record reason, mark criterion clean, continue.
|
|
154
|
+
**On CONVERGE**: `✓ Critic converged ({N} passes, {M} fixes, {E} escalations)`
|
|
155
|
+
**On SAFETY CAP**: `⚠ Critic safety cap ({N} passes). Review recommended.`
|
|
156
|
+
|
|
157
|
+
### 7. Archive Review Report
|
|
158
|
+
|
|
159
|
+
When running inside a pipeline (specs/{feature}/ exists), persist the review results:
|
|
160
|
+
|
|
161
|
+
1. Write full review output (Summary table + Detailed Findings + Positives) to `specs/{feature}/review-report.md`
|
|
162
|
+
2. Include metadata header:
|
|
163
|
+
```markdown
|
|
164
|
+
# Review Report: {feature name}
|
|
165
|
+
> Date: {YYYY-MM-DD}
|
|
166
|
+
> Files reviewed: {count}
|
|
167
|
+
> Findings: Critical {N} / Warning {N} / Info {N}
|
|
168
|
+
```
|
|
169
|
+
3. This file survives Clean phase (copied to `memory/reviews/{feature}-{date}.md` before specs/ deletion)
|
|
170
|
+
|
|
171
|
+
When running standalone (no active pipeline), skip archiving — display results in console only.
|
|
144
172
|
|
|
145
|
-
###
|
|
173
|
+
### 8. Final Output
|
|
146
174
|
|
|
147
175
|
```
|
|
148
176
|
Review complete
|
|
149
177
|
├─ Files: {changed file count}
|
|
150
178
|
├─ Found: Critical {N} / Warning {N} / Info {N}
|
|
151
|
-
├─ Critic:
|
|
179
|
+
├─ Critic: converged ({N} passes, {M} fixes, {E} escalations)
|
|
152
180
|
└─ Conclusion: {one-line summary}
|
|
153
181
|
```
|
|
154
182
|
|
package/commands/spec.md
CHANGED
|
@@ -7,7 +7,7 @@ model: sonnet
|
|
|
7
7
|
# /selfish:spec — Generate Feature Specification
|
|
8
8
|
|
|
9
9
|
> Converts a natural language feature description into a structured specification (spec.md).
|
|
10
|
-
> Operates on pure prompts without external scripts.
|
|
10
|
+
> Validates completeness with convergence-based Critic Loop. Operates on pure prompts without external scripts.
|
|
11
11
|
|
|
12
12
|
## Arguments
|
|
13
13
|
|
|
@@ -77,6 +77,13 @@ Create `specs/{feature-name}/spec.md`:
|
|
|
77
77
|
### Non-Functional Requirements
|
|
78
78
|
- **NFR-001**: {performance/security/accessibility etc.}
|
|
79
79
|
|
|
80
|
+
### Auto-Suggested NFRs
|
|
81
|
+
{Load `docs/nfr-templates.md` and select 3-5 relevant NFRs based on the project type detected from selfish.config.md}
|
|
82
|
+
- **NFR-A01** [AUTO-SUGGESTED]: {suggestion from matching project type template}
|
|
83
|
+
- **NFR-A02** [AUTO-SUGGESTED]: {suggestion}
|
|
84
|
+
- **NFR-A03** [AUTO-SUGGESTED]: {suggestion}
|
|
85
|
+
{Tag each with [AUTO-SUGGESTED]. Users may accept, modify, or remove.}
|
|
86
|
+
|
|
80
87
|
### Key Entities
|
|
81
88
|
| Entity | Description | Related Existing Code |
|
|
82
89
|
|--------|-------------|-----------------------|
|
|
@@ -97,26 +104,32 @@ Create `specs/{feature-name}/spec.md`:
|
|
|
97
104
|
- {uncertain items — record if any, remove section if none}
|
|
98
105
|
```
|
|
99
106
|
|
|
100
|
-
### 4.
|
|
107
|
+
### 4. Retrospective Check
|
|
108
|
+
|
|
109
|
+
If `memory/retrospectives/` directory exists, load retrospective files and check:
|
|
110
|
+
- Were there previous `[AUTO-RESOLVED]` items that turned out wrong? Flag similar patterns.
|
|
111
|
+
- Were there scope-related issues in past specs? Warn about similar ambiguities.
|
|
112
|
+
|
|
113
|
+
### 5. Critic Loop
|
|
101
114
|
|
|
102
115
|
> **Always** read `docs/critic-loop-rules.md` first and follow it.
|
|
103
116
|
|
|
104
|
-
|
|
117
|
+
Run the critic loop until convergence. Safety cap: 5 passes.
|
|
105
118
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
```
|
|
119
|
+
| Criterion | Validation |
|
|
120
|
+
|-----------|------------|
|
|
121
|
+
| **COMPLETENESS** | Does every User Story have acceptance scenarios? Are any requirements missing? |
|
|
122
|
+
| **MEASURABILITY** | Are the success criteria measurable, not subjective? |
|
|
123
|
+
| **INDEPENDENCE** | Are implementation details (code, library names) absent from the spec? |
|
|
124
|
+
| **EDGE_CASES** | Are at least 2 edge cases identified? Any missing boundary conditions? |
|
|
113
125
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
126
|
+
**On FAIL**: auto-fix and continue to next pass.
|
|
127
|
+
**On ESCALATE**: pause, present options to user, apply choice, resume.
|
|
128
|
+
**On DEFER**: record reason, mark criterion clean, continue.
|
|
129
|
+
**On CONVERGE**: `✓ Critic converged ({N} passes, {M} fixes, {E} escalations)`
|
|
130
|
+
**On SAFETY CAP**: `⚠ Critic safety cap ({N} passes). Review recommended.`
|
|
118
131
|
|
|
119
|
-
###
|
|
132
|
+
### 6. Final Output
|
|
120
133
|
|
|
121
134
|
```
|
|
122
135
|
Spec generated
|
|
@@ -133,3 +146,4 @@ Spec generated
|
|
|
133
146
|
- Specify **actual paths** for entities related to existing code.
|
|
134
147
|
- If `$ARGUMENTS` is empty, ask user for a feature description.
|
|
135
148
|
- Do not pack too many features into one spec. Suggest splitting if User Stories exceed 5.
|
|
149
|
+
- When running `/selfish:auto`, `[AUTO-SUGGESTED]` NFRs are included automatically. Review after completion is recommended.
|
package/commands/tasks.md
CHANGED
|
@@ -8,7 +8,7 @@ model: sonnet
|
|
|
8
8
|
# /selfish:tasks — Task Decomposition
|
|
9
9
|
|
|
10
10
|
> Generates an executable task list (tasks.md) based on plan.md.
|
|
11
|
-
> Validates coverage with
|
|
11
|
+
> Validates coverage with convergence-based Critic Loop.
|
|
12
12
|
|
|
13
13
|
## Arguments
|
|
14
14
|
|
|
@@ -73,22 +73,35 @@ Decompose tasks per Phase defined in plan.md.
|
|
|
73
73
|
1. **1 task = 1 file** principle (where possible)
|
|
74
74
|
2. **Same file = sequential**, **different files = [P] candidate**
|
|
75
75
|
3. **Explicit dependencies**: Use `depends: [T001, T002]` to declare blocking dependencies. Tasks without `depends:` and with [P] marker are immediately parallelizable.
|
|
76
|
-
4. **
|
|
77
|
-
5. **
|
|
78
|
-
6. **
|
|
76
|
+
4. **[P] physical validation**: Before finalizing tasks.md, run `"${CLAUDE_PLUGIN_ROOT}/scripts/selfish-parallel-validate.sh" specs/{feature}/tasks.md` to verify no file path overlaps exist among [P] tasks within the same phase. Fix any conflicts before proceeding.
|
|
77
|
+
5. **Dependency graph must be a DAG**: no circular dependencies allowed. Validate before output.
|
|
78
|
+
6. **Test tasks**: Include a verification task for each testable unit
|
|
79
|
+
7. **Phase gate**: Add a `{config.gate}` validation task at the end of each Phase
|
|
79
80
|
|
|
80
|
-
### 3.
|
|
81
|
+
### 3. Retrospective Check
|
|
82
|
+
|
|
83
|
+
If `memory/retrospectives/` directory exists, load retrospective files and check:
|
|
84
|
+
- Were there previous parallel conflict issues ([P] file overlaps)? Flag similar file patterns.
|
|
85
|
+
- Were there tasks that were over-decomposed or under-decomposed? Adjust granularity.
|
|
86
|
+
|
|
87
|
+
### 4. Critic Loop
|
|
81
88
|
|
|
82
89
|
> **Always** read `docs/critic-loop-rules.md` first and follow it.
|
|
83
90
|
|
|
91
|
+
Run the critic loop until convergence. Safety cap: 5 passes.
|
|
92
|
+
|
|
84
93
|
| Criterion | Validation |
|
|
85
94
|
|-----------|------------|
|
|
86
95
|
| **COVERAGE** | Are all files in plan.md's File Change Map included in tasks? Are all FR-* in spec.md covered? |
|
|
87
|
-
| **DEPENDENCIES** | Is the dependency graph a valid DAG? Do [P] tasks within the same phase have no file overlaps? Are all `depends:` targets valid task IDs? |
|
|
96
|
+
| **DEPENDENCIES** | Is the dependency graph a valid DAG? Do [P] tasks within the same phase have no file overlaps? Are all `depends:` targets valid task IDs? For physical validation of [P] file overlaps, reference the validation script: `"${CLAUDE_PLUGIN_ROOT}/scripts/selfish-parallel-validate.sh"` can be called with the tasks.md path to verify no conflicts exist. |
|
|
88
97
|
|
|
89
|
-
On FAIL
|
|
98
|
+
**On FAIL**: auto-fix and continue to next pass.
|
|
99
|
+
**On ESCALATE**: pause, present options to user, apply choice, resume.
|
|
100
|
+
**On DEFER**: record reason, mark criterion clean, continue.
|
|
101
|
+
**On CONVERGE**: `✓ Critic converged ({N} passes, {M} fixes, {E} escalations)`
|
|
102
|
+
**On SAFETY CAP**: `⚠ Critic safety cap ({N} passes). Review recommended.`
|
|
90
103
|
|
|
91
|
-
###
|
|
104
|
+
### 5. Coverage Mapping
|
|
92
105
|
|
|
93
106
|
```markdown
|
|
94
107
|
## Coverage Mapping
|
|
@@ -101,7 +114,7 @@ On FAIL: add missing items and re-check.
|
|
|
101
114
|
|
|
102
115
|
Every FR-*/NFR-* must be mapped to at least one task.
|
|
103
116
|
|
|
104
|
-
###
|
|
117
|
+
### 6. Final Output
|
|
105
118
|
|
|
106
119
|
Save to `specs/{feature}/tasks.md`, then:
|
|
107
120
|
|
|
@@ -111,7 +124,7 @@ Tasks generated
|
|
|
111
124
|
├─ Tasks: {total count} ({[P] count} parallelizable)
|
|
112
125
|
├─ Phases: {phase count}
|
|
113
126
|
├─ Coverage: FR {coverage}%, NFR {coverage}%
|
|
114
|
-
├─ Critic:
|
|
127
|
+
├─ Critic: converged ({N} passes, {M} fixes, {E} escalations)
|
|
115
128
|
└─ Next step: /selfish:analyze (optional) or /selfish:implement
|
|
116
129
|
```
|
|
117
130
|
|