selfish-pipeline 1.2.1 → 1.3.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/MIGRATION.md +5 -2
- package/agents/selfish-architect.md +1 -0
- package/commands/analyze.md +2 -2
- package/commands/architect.md +6 -5
- package/commands/auto.md +22 -22
- package/commands/checkpoint.md +2 -2
- package/commands/clarify.md +1 -1
- package/commands/debug.md +17 -2
- package/commands/doctor.md +4 -4
- package/commands/implement.md +6 -2
- package/commands/init.md +3 -0
- package/commands/plan.md +39 -31
- package/commands/principles.md +3 -3
- package/commands/research.md +5 -5
- package/commands/resume.md +3 -3
- package/commands/review.md +24 -8
- package/commands/spec.md +6 -6
- package/commands/tasks.md +6 -6
- package/commands/test.md +1 -1
- package/docs/critic-loop-rules.md +10 -3
- package/docs/phase-gate-protocol.md +1 -1
- package/package.json +1 -1
- package/scripts/pre-compact-checkpoint.sh +3 -3
- package/scripts/selfish-preflight-check.sh +107 -14
- package/scripts/session-start-context.sh +1 -1
|
@@ -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.3.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.3.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.3.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/MIGRATION.md
CHANGED
|
@@ -82,12 +82,15 @@ For new projects, you can auto-generate it with `/selfish:init`.
|
|
|
82
82
|
## What Stays the Same
|
|
83
83
|
|
|
84
84
|
- `.claude/selfish.config.md` file format and path
|
|
85
|
-
- `specs/{feature}/` artifact paths
|
|
86
|
-
- `memory/` references (checkpoint, principles, research, decisions)
|
|
87
85
|
- `.selfish-*` state file paths
|
|
88
86
|
- `git tag selfish/pre-*` safety tags
|
|
89
87
|
- Internal logic of hook scripts
|
|
90
88
|
|
|
89
|
+
## What Changed (v1.2.2+)
|
|
90
|
+
|
|
91
|
+
- `specs/{feature}/` → `.claude/selfish/specs/{feature}/`
|
|
92
|
+
- `memory/` → `.claude/selfish/memory/` (checkpoint, principles, research, decisions)
|
|
93
|
+
|
|
91
94
|
## FAQ
|
|
92
95
|
|
|
93
96
|
**Q: Do I need to recreate `.claude/selfish.config.md` for existing projects?**
|
package/commands/analyze.md
CHANGED
|
@@ -34,7 +34,7 @@ config.architecture = the architecture pattern used in the project
|
|
|
34
34
|
|
|
35
35
|
### 1. Load Artifacts
|
|
36
36
|
|
|
37
|
-
From
|
|
37
|
+
From `.claude/selfish/specs/{feature}/`:
|
|
38
38
|
- **spec.md** (required)
|
|
39
39
|
- **plan.md** (required)
|
|
40
40
|
- **tasks.md** (if present)
|
|
@@ -66,7 +66,7 @@ Validate across 6 categories:
|
|
|
66
66
|
- Mismatches between technical decisions in plan and execution in tasks
|
|
67
67
|
|
|
68
68
|
#### E. Principles Compliance (PRINCIPLES)
|
|
69
|
-
- Validate against MUST principles in memory/principles.md if present
|
|
69
|
+
- Validate against MUST principles in .claude/selfish/memory/principles.md if present
|
|
70
70
|
- Potential violations of {config.architecture} rules
|
|
71
71
|
|
|
72
72
|
#### F. Unidentified Risks (RISK)
|
package/commands/architect.md
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: selfish:architect
|
|
3
|
-
description: "Architecture analysis and design advice
|
|
3
|
+
description: "Architecture analysis and design advice"
|
|
4
4
|
argument-hint: "[analysis target or design question]"
|
|
5
5
|
disable-model-invocation: true
|
|
6
6
|
context: fork
|
|
7
7
|
agent: selfish-architect
|
|
8
8
|
allowed-tools:
|
|
9
9
|
- Read
|
|
10
|
+
- Write
|
|
10
11
|
- Grep
|
|
11
12
|
- Glob
|
|
12
13
|
- Bash
|
|
@@ -18,7 +19,7 @@ model: sonnet
|
|
|
18
19
|
# /selfish:architect — Architecture Analysis and Design Advice
|
|
19
20
|
|
|
20
21
|
> Analyzes the codebase architecture and records design decisions.
|
|
21
|
-
> Ensures design quality through convergence-based Critic Loop.
|
|
22
|
+
> Ensures design quality through convergence-based Critic Loop. Does not modify source code. May write ADR files to `.claude/selfish/memory/decisions/`.
|
|
22
23
|
|
|
23
24
|
## Arguments
|
|
24
25
|
|
|
@@ -91,7 +92,7 @@ Structure analysis results and **print to console**:
|
|
|
91
92
|
|
|
92
93
|
### 4. Critic Loop
|
|
93
94
|
|
|
94
|
-
> **Always** read
|
|
95
|
+
> **Always** read `${CLAUDE_PLUGIN_ROOT}/docs/critic-loop-rules.md` first and follow it.
|
|
95
96
|
|
|
96
97
|
Run the critic loop until convergence. Safety cap: 7 passes.
|
|
97
98
|
|
|
@@ -110,7 +111,7 @@ Run the critic loop until convergence. Safety cap: 7 passes.
|
|
|
110
111
|
|
|
111
112
|
### 5. Save ADR (for design decisions)
|
|
112
113
|
|
|
113
|
-
If ADR type, save to
|
|
114
|
+
If ADR type, save to `.claude/selfish/memory/decisions/{YYYY-MM-DD}-{topic}.md`:
|
|
114
115
|
|
|
115
116
|
```markdown
|
|
116
117
|
# ADR: {title}
|
|
@@ -135,7 +136,7 @@ Architecture analysis complete
|
|
|
135
136
|
|
|
136
137
|
## Notes
|
|
137
138
|
|
|
138
|
-
- **
|
|
139
|
+
- **No source modification**: Does not modify project source code. May write ADR files to `.claude/selfish/memory/decisions/`.
|
|
139
140
|
- **Based on actual code**: Explore the actual codebase, not assumptions.
|
|
140
141
|
- **Architecture first**: All suggestions respect {config.architecture} rules.
|
|
141
142
|
- **Incremental changes**: Prefer incremental improvements over big-bang refactoring.
|
package/commands/auto.md
CHANGED
|
@@ -34,7 +34,7 @@ If config file is missing: print "`.claude/selfish.config.md` not found. Create
|
|
|
34
34
|
|
|
35
35
|
## Critic Loop Rules (common to all phases)
|
|
36
36
|
|
|
37
|
-
> **Always** read
|
|
37
|
+
> **Always** read `${CLAUDE_PLUGIN_ROOT}/docs/critic-loop-rules.md` first and follow it.
|
|
38
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
|
---
|
|
@@ -60,7 +60,7 @@ If config file is missing: print "`.claude/selfish.config.md` not found. Create
|
|
|
60
60
|
- Stop Gate Hook activated (blocks response termination on CI failure)
|
|
61
61
|
- File change tracking started
|
|
62
62
|
- Timeline log: `"${CLAUDE_PLUGIN_ROOT}/scripts/selfish-pipeline-manage.sh" log pipeline-start "Auto pipeline: {feature}"`
|
|
63
|
-
5. Create
|
|
63
|
+
5. Create `.claude/selfish/specs/{feature}/` directory → **record path as `PIPELINE_ARTIFACT_DIR`** (for Clean scope)
|
|
64
64
|
6. Start notification:
|
|
65
65
|
```
|
|
66
66
|
Auto pipeline started: {feature}
|
|
@@ -75,10 +75,10 @@ If config file is missing: print "`.claude/selfish.config.md` not found. Create
|
|
|
75
75
|
Execute `/selfish:spec` logic inline:
|
|
76
76
|
|
|
77
77
|
1. Explore codebase for related code (Glob, Grep) — explore by `{config.architecture}` layer
|
|
78
|
-
2. Create
|
|
78
|
+
2. Create `.claude/selfish/specs/{feature}/spec.md`
|
|
79
79
|
3. `[NEEDS CLARIFICATION]` items are **auto-resolved with best-guess** (clarify skipped)
|
|
80
80
|
- Tag auto-resolved items with `[AUTO-RESOLVED]`
|
|
81
|
-
4. **Retrospective check**: if
|
|
81
|
+
4. **Retrospective check**: if `.claude/selfish/memory/retrospectives/` exists, load and check:
|
|
82
82
|
- Were there previous `[AUTO-RESOLVED]` items that turned out wrong? Flag similar patterns.
|
|
83
83
|
- Were there scope-related issues in past specs? Warn about similar ambiguities.
|
|
84
84
|
5. **Critic Loop until convergence** (safety cap: 5, follow Critic Loop rules):
|
|
@@ -97,7 +97,7 @@ Execute `/selfish:plan` logic inline:
|
|
|
97
97
|
|
|
98
98
|
1. Load spec.md
|
|
99
99
|
2. If technical uncertainties exist → auto-resolve via WebSearch/code exploration → create research.md
|
|
100
|
-
3. Create
|
|
100
|
+
3. Create `.claude/selfish/specs/{feature}/plan.md`
|
|
101
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")
|
|
102
102
|
4. **Critic Loop until convergence** (safety cap: 7, follow Critic Loop rules):
|
|
103
103
|
- Criteria: COMPLETENESS, FEASIBILITY, ARCHITECTURE, RISK, PRINCIPLES
|
|
@@ -124,14 +124,14 @@ Execute `/selfish:tasks` logic inline:
|
|
|
124
124
|
- Validate dependency graph is a DAG (no circular references)
|
|
125
125
|
- [P] tasks **must be executed in parallel** in Phase 4 (declaring [P] then running sequentially is prohibited)
|
|
126
126
|
4. Coverage mapping (FR → Task)
|
|
127
|
-
5. **Retrospective check**: if
|
|
127
|
+
5. **Retrospective check**: if `.claude/selfish/memory/retrospectives/` exists, load and check:
|
|
128
128
|
- Were there previous parallel conflict issues ([P] file overlaps)? Flag similar file patterns.
|
|
129
129
|
- Were there tasks that were over-decomposed or under-decomposed? Adjust granularity.
|
|
130
130
|
6. **Critic Loop until convergence** (safety cap: 5, follow Critic Loop rules):
|
|
131
131
|
- COVERAGE: is every FR/NFR mapped to at least 1 task?
|
|
132
132
|
- DEPENDENCIES: is the dependency graph a valid DAG? Do [P] tasks have no file overlaps?
|
|
133
133
|
- FAIL → auto-fix and continue. ESCALATE → pause, present options, resume after response. DEFER → record reason, mark clean.
|
|
134
|
-
7. Create
|
|
134
|
+
7. Create `.claude/selfish/specs/{feature}/tasks.md`
|
|
135
135
|
8. Progress: `✓ 3/6 Tasks complete (tasks: {N}, parallel: {N}, Critic: converged ({N} passes, {M} fixes, {E} escalations))`
|
|
136
136
|
|
|
137
137
|
### Phase 4: Implement (4/6)
|
|
@@ -171,12 +171,12 @@ Execute `/selfish:implement` logic inline with **dependency-aware orchestration*
|
|
|
171
171
|
// 5. Read all worker results before proceeding to gate
|
|
172
172
|
```
|
|
173
173
|
|
|
174
|
-
6. Perform **3-step gate** on each Implementation Phase completion — **always** read
|
|
174
|
+
6. Perform **3-step gate** on each Implementation Phase completion — **always** read `${CLAUDE_PLUGIN_ROOT}/docs/phase-gate-protocol.md` first. Cannot advance to next phase without passing the gate.
|
|
175
175
|
- On gate pass: create phase rollback point `"${CLAUDE_PLUGIN_ROOT}/scripts/selfish-pipeline-manage.sh" phase-tag {phase_number}`
|
|
176
176
|
7. Real-time `[x]` updates in tasks.md
|
|
177
177
|
8. After full completion, run `{config.ci}` final verification
|
|
178
178
|
- On pass: `"${CLAUDE_PLUGIN_ROOT}/scripts/selfish-pipeline-manage.sh" ci-pass` (releases Stop Gate)
|
|
179
|
-
9. **Implement retrospective**: if unexpected problems arose that weren't predicted in Plan, record in
|
|
179
|
+
9. **Implement retrospective**: if unexpected problems arose that weren't predicted in Plan, record in `.claude/selfish/specs/{feature}/retrospective.md` (for memory update in Clean)
|
|
180
180
|
10. Progress: `✓ 4/6 Implement complete ({completed}/{total} tasks, CI: ✓, Mini-Review: ✓, Checkpoint: ✓)`
|
|
181
181
|
|
|
182
182
|
### Phase 5: Review (5/6)
|
|
@@ -187,7 +187,7 @@ Execute `/selfish:review` logic inline:
|
|
|
187
187
|
|
|
188
188
|
1. Review implemented changed files (`git diff HEAD`)
|
|
189
189
|
2. Check code quality, `{config.architecture}` rules, security, performance, `{config.code_style}` pattern compliance
|
|
190
|
-
3. **Retrospective check**: if
|
|
190
|
+
3. **Retrospective check**: if `.claude/selfish/memory/retrospectives/` exists, load and check:
|
|
191
191
|
- Were there recurring Critical finding categories in past reviews? Prioritize those perspectives.
|
|
192
192
|
- Were there false positives that wasted effort? Reduce sensitivity for those patterns.
|
|
193
193
|
4. **Critic Loop until convergence** (safety cap: 5, follow Critic Loop rules):
|
|
@@ -206,8 +206,8 @@ Execute `/selfish:review` logic inline:
|
|
|
206
206
|
Artifact cleanup and codebase hygiene check after implementation and review:
|
|
207
207
|
|
|
208
208
|
1. **Artifact cleanup** (scope-limited):
|
|
209
|
-
- **Delete only the
|
|
210
|
-
- If other
|
|
209
|
+
- **Delete only the `.claude/selfish/specs/{feature}/` directory created by the current pipeline**
|
|
210
|
+
- If other `.claude/selfish/specs/` subdirectories exist, **do not delete them** (only inform the user of their existence)
|
|
211
211
|
- Do not leave pipeline intermediate artifacts in the codebase
|
|
212
212
|
2. **Dead code scan**:
|
|
213
213
|
- Detect unused imports from the implementation process (check with `{config.ci}`)
|
|
@@ -217,12 +217,12 @@ Artifact cleanup and codebase hygiene check after implementation and review:
|
|
|
217
217
|
- Run `{config.ci}` final execution
|
|
218
218
|
- Auto-fix on failure (max 2 attempts)
|
|
219
219
|
4. **Memory update** (if applicable):
|
|
220
|
-
- Reusable patterns found during pipeline → record in
|
|
221
|
-
- If there were `[AUTO-RESOLVED]` items → record decisions in
|
|
222
|
-
- **If retrospective.md exists** → record as patterns missed by the Plan phase Critic Loop in
|
|
223
|
-
- **If review-report.md exists** → copy to
|
|
220
|
+
- Reusable patterns found during pipeline → record in `.claude/selfish/memory/`
|
|
221
|
+
- If there were `[AUTO-RESOLVED]` items → record decisions in `.claude/selfish/memory/decisions/`
|
|
222
|
+
- **If retrospective.md exists** → record as patterns missed by the Plan phase Critic Loop in `.claude/selfish/memory/retrospectives/` (reuse as RISK checklist items in future runs)
|
|
223
|
+
- **If review-report.md exists** → copy to `.claude/selfish/memory/reviews/{feature}-{date}.md` before .claude/selfish/specs/ deletion
|
|
224
224
|
5. **Quality report** (structured pipeline metrics):
|
|
225
|
-
- Generate
|
|
225
|
+
- Generate `.claude/selfish/memory/quality-history/{feature}-{date}.json` with the following structure:
|
|
226
226
|
```json
|
|
227
227
|
{
|
|
228
228
|
"feature": "{feature}",
|
|
@@ -237,9 +237,9 @@ Artifact cleanup and codebase hygiene check after implementation and review:
|
|
|
237
237
|
"totals": { "changed_files": N, "auto_resolved": N, "escalations": N }
|
|
238
238
|
}
|
|
239
239
|
```
|
|
240
|
-
- Create
|
|
240
|
+
- Create `.claude/selfish/memory/quality-history/` directory if it does not exist
|
|
241
241
|
6. **Checkpoint reset**:
|
|
242
|
-
- Clear
|
|
242
|
+
- Clear `.claude/selfish/memory/checkpoint.md` (pipeline complete = session goal achieved)
|
|
243
243
|
7. **Timeline finalize**:
|
|
244
244
|
```bash
|
|
245
245
|
"${CLAUDE_PLUGIN_ROOT}/scripts/selfish-pipeline-manage.sh" log pipeline-end "Pipeline complete: {feature}"
|
|
@@ -267,7 +267,7 @@ Auto pipeline complete: {feature}
|
|
|
267
267
|
├─ Changed files: {N}
|
|
268
268
|
├─ Auto-resolved: {N} (review recommended)
|
|
269
269
|
├─ Retrospective: {present/absent}
|
|
270
|
-
└─ specs/{feature}/ cleaned up
|
|
270
|
+
└─ .claude/selfish/specs/{feature}/ cleaned up
|
|
271
271
|
```
|
|
272
272
|
|
|
273
273
|
## Abort Conditions
|
|
@@ -284,8 +284,8 @@ Pipeline aborted (Phase {N}/6)
|
|
|
284
284
|
├─ Reason: {abort cause}
|
|
285
285
|
├─ Completed phases: {completed list}
|
|
286
286
|
├─ Rollback: git reset --hard selfish/pre-auto (restores state before implementation)
|
|
287
|
-
├─ Checkpoint: memory/checkpoint.md (last phase gate passed)
|
|
288
|
-
├─ Artifacts: specs/{feature}/ (partial completion, manual deletion needed if Clean did not run)
|
|
287
|
+
├─ Checkpoint: .claude/selfish/memory/checkpoint.md (last phase gate passed)
|
|
288
|
+
├─ Artifacts: .claude/selfish/specs/{feature}/ (partial completion, manual deletion needed if Clean did not run)
|
|
289
289
|
└─ Resume: /selfish:resume → /selfish:implement (checkpoint-based)
|
|
290
290
|
```
|
|
291
291
|
|
package/commands/checkpoint.md
CHANGED
|
@@ -13,7 +13,7 @@ allowed-tools:
|
|
|
13
13
|
|
|
14
14
|
# /selfish:checkpoint — Save Session State
|
|
15
15
|
|
|
16
|
-
> Saves the current work state to memory/checkpoint.md.
|
|
16
|
+
> Saves the current work state to .claude/selfish/memory/checkpoint.md.
|
|
17
17
|
> Preserves progress even if the session is interrupted.
|
|
18
18
|
|
|
19
19
|
## Arguments
|
|
@@ -41,7 +41,7 @@ Collect automatically:
|
|
|
41
41
|
|
|
42
42
|
### 2. Save Checkpoint
|
|
43
43
|
|
|
44
|
-
**Overwrite**
|
|
44
|
+
**Overwrite** `.claude/selfish/memory/checkpoint.md` (keep only the latest state):
|
|
45
45
|
|
|
46
46
|
````markdown
|
|
47
47
|
# Session Checkpoint
|
package/commands/clarify.md
CHANGED
|
@@ -22,7 +22,7 @@ model: sonnet
|
|
|
22
22
|
|
|
23
23
|
### 1. Load Spec
|
|
24
24
|
|
|
25
|
-
1. Read
|
|
25
|
+
1. Read `.claude/selfish/specs/{feature}/spec.md` — stop if not found
|
|
26
26
|
2. If a `[NEEDS CLARIFICATION]` section exists, process it first
|
|
27
27
|
3. Quickly check existing codebase for related patterns
|
|
28
28
|
|
package/commands/debug.md
CHANGED
|
@@ -61,7 +61,7 @@ Verify starting from highest probability.
|
|
|
61
61
|
|
|
62
62
|
### 5. Critic Loop
|
|
63
63
|
|
|
64
|
-
> **Always** read
|
|
64
|
+
> **Always** read `${CLAUDE_PLUGIN_ROOT}/docs/critic-loop-rules.md` first and follow it.
|
|
65
65
|
|
|
66
66
|
Run the critic loop until convergence. Safety cap: 5 passes.
|
|
67
67
|
|
|
@@ -84,7 +84,22 @@ Run the critic loop until convergence. Safety cap: 5 passes.
|
|
|
84
84
|
|
|
85
85
|
Retry after fixing on failure (max 3 attempts).
|
|
86
86
|
|
|
87
|
-
### 7.
|
|
87
|
+
### 7. Retrospective Entry (if new pattern found)
|
|
88
|
+
|
|
89
|
+
If this debug session reveals a pattern not previously documented in `.claude/selfish/memory/retrospectives/`:
|
|
90
|
+
|
|
91
|
+
Append to `.claude/selfish/memory/retrospectives/{YYYY-MM-DD}.md`:
|
|
92
|
+
```markdown
|
|
93
|
+
## Pattern: {category}
|
|
94
|
+
**What happened**: {concrete description}
|
|
95
|
+
**Root cause**: {why this bug occurred}
|
|
96
|
+
**Prevention rule**: {actionable rule — usable in future plan/implement phases}
|
|
97
|
+
**Severity**: Critical | Warning
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Only write if the pattern is new and actionable. Generic observations are prohibited.
|
|
101
|
+
|
|
102
|
+
### 8. Final Output
|
|
88
103
|
|
|
89
104
|
```
|
|
90
105
|
Debug complete
|
package/commands/doctor.md
CHANGED
|
@@ -60,7 +60,7 @@ Run ALL checks regardless of earlier failures. Do not short-circuit.
|
|
|
60
60
|
|-------|-----|------|------|
|
|
61
61
|
| Global CLAUDE.md exists | Read `~/.claude/CLAUDE.md` | File exists | ⚠ Warning: no global CLAUDE.md. Selfish skills won't auto-trigger from intent. Fix: run `/selfish:init` |
|
|
62
62
|
| SELFISH block present | Grep for `<!-- SELFISH:START -->` and `<!-- SELFISH:END -->` in `~/.claude/CLAUDE.md` | Both markers found | Fix: run `/selfish:init` to inject SELFISH block |
|
|
63
|
-
| SELFISH block version | Extract version from `<!-- SELFISH:VERSION:X.Y.Z -->`
|
|
63
|
+
| SELFISH block version | Extract version from `<!-- SELFISH:VERSION:X.Y.Z -->` in CLAUDE.md. Then read `${CLAUDE_PLUGIN_ROOT}/package.json` to get the actual plugin version. Compare the two. | Block version ≥ plugin version | ⚠ Warning: SELFISH block is outdated (found {block_version}, current {plugin_version}). Fix: run `/selfish:init` to update |
|
|
64
64
|
| No conflicting routing | Grep for conflicting agent patterns (`executor`, `deep-executor`, `debugger`, `code-reviewer`) outside SELFISH block that could intercept selfish intents | No conflicts or conflicts are inside other tool blocks | ⚠ Warning: found agent routing that may conflict with selfish skills. Review `~/.claude/CLAUDE.md` |
|
|
65
65
|
|
|
66
66
|
### Category 4: Pipeline State
|
|
@@ -68,9 +68,9 @@ Run ALL checks regardless of earlier failures. Do not short-circuit.
|
|
|
68
68
|
| Check | How | Pass | Fail |
|
|
69
69
|
|-------|-----|------|------|
|
|
70
70
|
| No stale pipeline flag | Check `.claude/.selfish-active` | File does not exist (no active pipeline) | ⚠ Warning: stale pipeline flag found (feature: {name}). This may block normal operations. Fix: `rm .claude/.selfish-active .claude/.selfish-phase .claude/.selfish-ci-passed` or run `/selfish:resume` |
|
|
71
|
-
| No orphaned artifacts | Glob
|
|
71
|
+
| No orphaned artifacts | Glob `.claude/selfish/specs/*/spec.md` | No specs directories, or all are from active pipeline | ⚠ Warning: orphaned `.claude/selfish/specs/{name}/` found. Left over from a previous pipeline. Fix: `rm -rf .claude/selfish/specs/{name}/` |
|
|
72
72
|
| No lingering safety tags | `git tag -l 'selfish/pre-*'` | No tags, or tags match active pipeline | ⚠ Warning: lingering safety tag `selfish/pre-{x}` found. Fix: `git tag -d selfish/pre-{x}` |
|
|
73
|
-
| Checkpoint state | Read
|
|
73
|
+
| Checkpoint state | Read `.claude/selfish/memory/checkpoint.md` if exists | No checkpoint (clean), or checkpoint is from current session | ⚠ Warning: stale checkpoint from {date}. Fix: run `/selfish:resume` to continue or delete `.claude/selfish/memory/checkpoint.md` |
|
|
74
74
|
|
|
75
75
|
### Category 5: Hook Health
|
|
76
76
|
|
|
@@ -149,7 +149,7 @@ Pipeline State
|
|
|
149
149
|
|
|
150
150
|
Hook Health
|
|
151
151
|
✓ hooks.json valid
|
|
152
|
-
✓ All
|
|
152
|
+
✓ All scripts exist
|
|
153
153
|
✓ All scripts executable
|
|
154
154
|
|
|
155
155
|
─────────────────────────
|
package/commands/implement.md
CHANGED
|
@@ -38,7 +38,7 @@ git tag -f selfish/pre-implement
|
|
|
38
38
|
### 1. Load Context
|
|
39
39
|
|
|
40
40
|
1. **Current branch** → `BRANCH_NAME`
|
|
41
|
-
2. Load the following files from
|
|
41
|
+
2. Load the following files from `.claude/selfish/specs/{feature}/`:
|
|
42
42
|
- **tasks.md** (required) — abort if missing: "tasks.md not found. Run `/selfish:tasks` first."
|
|
43
43
|
- **plan.md** (required) — abort if missing
|
|
44
44
|
- **spec.md** (for reference)
|
|
@@ -48,6 +48,10 @@ git tag -f selfish/pre-implement
|
|
|
48
48
|
- Group by phase
|
|
49
49
|
- Build dependency graph (validate DAG — abort if circular)
|
|
50
50
|
- Identify already-completed `[x]` tasks
|
|
51
|
+
4. **Recent changes**: run `git log --oneline -20` to understand what changed recently (context for implementation)
|
|
52
|
+
5. **Smoke test**: run `{config.gate}` before starting implementation:
|
|
53
|
+
- If it fails → diagnose before implementing (existing code is broken — fix first or report to user)
|
|
54
|
+
- If it passes → baseline confirmed, proceed to implementation
|
|
51
55
|
|
|
52
56
|
### 2. Check Progress
|
|
53
57
|
|
|
@@ -145,7 +149,7 @@ When a worker agent exits with error (non-zero return or timeout):
|
|
|
145
149
|
|
|
146
150
|
#### Phase Completion Gate (3 steps)
|
|
147
151
|
|
|
148
|
-
> **Always** read
|
|
152
|
+
> **Always** read `${CLAUDE_PLUGIN_ROOT}/docs/phase-gate-protocol.md` first and perform the 3 steps (CI gate → Mini-Review → Auto-Checkpoint) in order.
|
|
149
153
|
> Cannot advance to the next phase without passing the gate. Abort and report to user after 3 consecutive CI failures.
|
|
150
154
|
|
|
151
155
|
After passing the gate, create a phase rollback point:
|
package/commands/init.md
CHANGED
|
@@ -188,6 +188,9 @@ User-only (not auto-triggered — inform user on request):
|
|
|
188
188
|
- `selfish:doctor` — inform user when health check is requested
|
|
189
189
|
- `selfish:architect` — inform user when architecture review is requested
|
|
190
190
|
- `selfish:security` — inform user when security scan is requested
|
|
191
|
+
- `selfish:checkpoint` — inform user when session save is requested
|
|
192
|
+
- `selfish:resume` — inform user when session restore is requested
|
|
193
|
+
- `selfish:principles` — inform user when project principles management is requested
|
|
191
194
|
|
|
192
195
|
## Pipeline
|
|
193
196
|
|
package/commands/plan.md
CHANGED
|
@@ -26,11 +26,11 @@ model: sonnet
|
|
|
26
26
|
### 1. Load Context
|
|
27
27
|
|
|
28
28
|
1. Check **current branch** → `BRANCH_NAME`
|
|
29
|
-
2. Find
|
|
30
|
-
- Search under
|
|
29
|
+
2. Find **.claude/selfish/specs/{feature}/spec.md**:
|
|
30
|
+
- Search under `.claude/selfish/specs/` for a directory matching the current branch name or `$ARGUMENTS`
|
|
31
31
|
- If not found: print "spec.md not found. Run `/selfish:spec` first." then **abort**
|
|
32
32
|
3. Read full **spec.md**
|
|
33
|
-
4. Read
|
|
33
|
+
4. Read **.claude/selfish/memory/principles.md** (if present)
|
|
34
34
|
5. Read **CLAUDE.md** project context
|
|
35
35
|
|
|
36
36
|
### 2. Clarification Check
|
|
@@ -39,7 +39,7 @@ model: sonnet
|
|
|
39
39
|
- Warn user: "There are unresolved clarification items. Do you want to continue?"
|
|
40
40
|
- If user chooses to stop → guide to `/selfish:clarify` then **abort**
|
|
41
41
|
|
|
42
|
-
### 3. Phase 0 — Research (if needed)
|
|
42
|
+
### 3. Phase 0 — Research (ReWOO pattern, if needed)
|
|
43
43
|
|
|
44
44
|
Extract technical uncertainties from spec.md:
|
|
45
45
|
|
|
@@ -47,22 +47,40 @@ Extract technical uncertainties from spec.md:
|
|
|
47
47
|
2. Are performance requirements unverified?
|
|
48
48
|
3. Is the integration approach with the existing codebase unclear?
|
|
49
49
|
|
|
50
|
-
**If
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
50
|
+
**If no uncertain items**: skip Phase 0.
|
|
51
|
+
|
|
52
|
+
**If there are uncertain items**, follow the 3-step ReWOO flow:
|
|
53
|
+
|
|
54
|
+
#### Step 1: Plan (enumerate all topics — NO execution yet)
|
|
55
|
+
List all research topics as a numbered list:
|
|
56
|
+
```
|
|
57
|
+
1. {topic1} — {what we need to know}
|
|
58
|
+
2. {topic2} — {what we need to know}
|
|
59
|
+
3. {topic3} — {what we need to know}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
#### Step 2: Execute (parallel for independent topics)
|
|
63
|
+
- If topics are independent (no result dependency): launch parallel Task() calls in a **single message**:
|
|
59
64
|
```
|
|
65
|
+
Task("Research: {topic1}", subagent_type: "general-purpose")
|
|
66
|
+
Task("Research: {topic2}", subagent_type: "general-purpose")
|
|
67
|
+
```
|
|
68
|
+
- If a topic depends on another's result: execute sequentially after the dependency resolves
|
|
69
|
+
- For 1-2 topics: resolve directly via WebSearch/codebase exploration (no delegation needed)
|
|
60
70
|
|
|
61
|
-
|
|
71
|
+
#### Step 3: Solve (consolidate all results)
|
|
72
|
+
Collect all results and record in `.claude/selfish/specs/{feature}/research.md`:
|
|
73
|
+
```markdown
|
|
74
|
+
## {topic}
|
|
75
|
+
**Decision**: {chosen approach}
|
|
76
|
+
**Rationale**: {reason}
|
|
77
|
+
**Alternatives**: {other approaches considered}
|
|
78
|
+
**Source**: {URL or file path}
|
|
79
|
+
```
|
|
62
80
|
|
|
63
81
|
### 4. Phase 1 — Write Design
|
|
64
82
|
|
|
65
|
-
Create
|
|
83
|
+
Create `.claude/selfish/specs/{feature}/plan.md`. **Must** follow the structure below:
|
|
66
84
|
|
|
67
85
|
```markdown
|
|
68
86
|
# Implementation Plan: {feature name}
|
|
@@ -81,7 +99,7 @@ Create `specs/{feature}/plan.md`. **Must** follow the structure below:
|
|
|
81
99
|
- **Constraints**: {constraints extracted from spec}
|
|
82
100
|
|
|
83
101
|
## Principles Check
|
|
84
|
-
{if memory/principles.md exists: validation results against MUST principles}
|
|
102
|
+
{if .claude/selfish/memory/principles.md exists: validation results against MUST principles}
|
|
85
103
|
{if violations possible: state explicitly + justification}
|
|
86
104
|
|
|
87
105
|
## Architecture Decision
|
|
@@ -141,7 +159,7 @@ Create `specs/{feature}/plan.md`. **Must** follow the structure below:
|
|
|
141
159
|
|
|
142
160
|
### 5. Critic Loop
|
|
143
161
|
|
|
144
|
-
> **Always** read
|
|
162
|
+
> **Always** read `${CLAUDE_PLUGIN_ROOT}/docs/critic-loop-rules.md` first and follow it.
|
|
145
163
|
|
|
146
164
|
Run the critic loop until convergence. Safety cap: 7 passes.
|
|
147
165
|
|
|
@@ -150,7 +168,7 @@ Run the critic loop until convergence. Safety cap: 7 passes.
|
|
|
150
168
|
| **COMPLETENESS** | Are all requirements (FR-*) from spec.md reflected in the plan? |
|
|
151
169
|
| **FEASIBILITY** | Is it compatible with the existing codebase? Are dependencies available? |
|
|
152
170
|
| **ARCHITECTURE** | Does it comply with {config.architecture} rules? |
|
|
153
|
-
| **RISK** | Are there any unidentified risks? Additionally, if
|
|
171
|
+
| **RISK** | Are there any unidentified risks? Additionally, if `.claude/selfish/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]`. |
|
|
154
172
|
| **PRINCIPLES** | Does it not violate the MUST principles in principles.md? |
|
|
155
173
|
|
|
156
174
|
**On FAIL**: auto-fix and continue to next pass.
|
|
@@ -159,22 +177,12 @@ Run the critic loop until convergence. Safety cap: 7 passes.
|
|
|
159
177
|
**On CONVERGE**: `✓ Critic converged ({N} passes, {M} fixes, {E} escalations)`
|
|
160
178
|
**On SAFETY CAP**: `⚠ Critic safety cap ({N} passes). Review recommended.`
|
|
161
179
|
|
|
162
|
-
### 6.
|
|
163
|
-
|
|
164
|
-
If research items are 3 or more, delegate to parallel research agents via Task tool:
|
|
165
|
-
|
|
166
|
-
```
|
|
167
|
-
Task("Research: {topic1}", subagent_type: "general-purpose")
|
|
168
|
-
Task("Research: {topic2}", subagent_type: "general-purpose")
|
|
169
|
-
→ collect results → consolidate into research.md
|
|
170
|
-
```
|
|
171
|
-
|
|
172
|
-
### 7. Final Output
|
|
180
|
+
### 6. Final Output
|
|
173
181
|
|
|
174
182
|
```
|
|
175
183
|
Plan generated
|
|
176
|
-
├─ specs/{feature}/plan.md
|
|
177
|
-
├─ specs/{feature}/research.md (if research was performed)
|
|
184
|
+
├─ .claude/selfish/specs/{feature}/plan.md
|
|
185
|
+
├─ .claude/selfish/specs/{feature}/research.md (if research was performed)
|
|
178
186
|
├─ Critic: converged ({N} passes, {M} fixes, {E} escalations)
|
|
179
187
|
└─ Next step: /selfish:tasks
|
|
180
188
|
```
|
package/commands/principles.md
CHANGED
|
@@ -14,7 +14,7 @@ model: haiku
|
|
|
14
14
|
# /selfish:principles — Manage Project Principles
|
|
15
15
|
|
|
16
16
|
> Creates and manages the project's core principles (constitution).
|
|
17
|
-
> Stored in memory/principles.md and referenced across all sessions.
|
|
17
|
+
> Stored in .claude/selfish/memory/principles.md and referenced across all sessions.
|
|
18
18
|
|
|
19
19
|
## Arguments
|
|
20
20
|
|
|
@@ -32,7 +32,7 @@ model: haiku
|
|
|
32
32
|
|
|
33
33
|
### 1. Check Current State
|
|
34
34
|
|
|
35
|
-
Read
|
|
35
|
+
Read `.claude/selfish/memory/principles.md`:
|
|
36
36
|
- If present: load existing principles
|
|
37
37
|
- If absent: empty state (show `init` instructions)
|
|
38
38
|
|
|
@@ -101,7 +101,7 @@ Collect principles interactively:
|
|
|
101
101
|
|
|
102
102
|
## Notes
|
|
103
103
|
|
|
104
|
-
- **Persistent storage**: Saved to memory/principles.md and maintained across sessions.
|
|
104
|
+
- **Persistent storage**: Saved to .claude/selfish/memory/principles.md and maintained across sessions.
|
|
105
105
|
- **Auto-referenced**: Automatically loaded and validated by /selfish:plan and /selfish:architect.
|
|
106
106
|
- **Keep it concise**: Maintain no more than 10 principles. Too many reduces effectiveness.
|
|
107
107
|
- **Avoid duplication with CLAUDE.md**: Do not re-register rules already present in CLAUDE.md as principles.
|
package/commands/research.md
CHANGED
|
@@ -16,7 +16,7 @@ model: sonnet
|
|
|
16
16
|
# /selfish:research — Technical Research
|
|
17
17
|
|
|
18
18
|
> Investigates technical questions and summarizes conclusions.
|
|
19
|
-
> Results are persisted to memory/research/{topic}.md.
|
|
19
|
+
> Results are persisted to .claude/selfish/memory/research/{topic}.md.
|
|
20
20
|
|
|
21
21
|
## Arguments
|
|
22
22
|
|
|
@@ -33,7 +33,7 @@ Extract from `$ARGUMENTS`:
|
|
|
33
33
|
|
|
34
34
|
### 2. Check Existing Research
|
|
35
35
|
|
|
36
|
-
Check
|
|
36
|
+
Check `.claude/selfish/memory/research/` directory for related prior research:
|
|
37
37
|
- If found: load existing content and decide whether an update is needed
|
|
38
38
|
- If not found: proceed with new research
|
|
39
39
|
|
|
@@ -88,7 +88,7 @@ Source priority:
|
|
|
88
88
|
|
|
89
89
|
### 5. Save
|
|
90
90
|
|
|
91
|
-
- Save to
|
|
91
|
+
- Save to `.claude/selfish/memory/research/{topic-kebab-case}.md`
|
|
92
92
|
- If the file already exists, update it (refresh the date)
|
|
93
93
|
|
|
94
94
|
### 6. Final Output
|
|
@@ -96,7 +96,7 @@ Source priority:
|
|
|
96
96
|
```
|
|
97
97
|
Research complete
|
|
98
98
|
├─ Topic: {topic}
|
|
99
|
-
├─ Saved: memory/research/{filename}.md
|
|
99
|
+
├─ Saved: .claude/selfish/memory/research/{filename}.md
|
|
100
100
|
├─ Conclusion: {one-line summary}
|
|
101
101
|
└─ Sources: {number of key sources}
|
|
102
102
|
```
|
|
@@ -106,4 +106,4 @@ Research complete
|
|
|
106
106
|
- **Current date basis**: Use WebSearch to verify up-to-date information rather than relying on knowledge cutoff.
|
|
107
107
|
- **Sources required**: Cite sources for all technical claims.
|
|
108
108
|
- **Project context**: Derive conclusions applicable to this project, not generic research.
|
|
109
|
-
- **Persistent storage**: Save to memory/research/ for reuse across sessions.
|
|
109
|
+
- **Persistent storage**: Save to .claude/selfish/memory/research/ for reuse across sessions.
|
package/commands/resume.md
CHANGED
|
@@ -12,7 +12,7 @@ allowed-tools:
|
|
|
12
12
|
|
|
13
13
|
# /selfish:resume — Restore Session
|
|
14
14
|
|
|
15
|
-
> Restores the previous session state from memory/checkpoint.md and resumes work.
|
|
15
|
+
> Restores the previous session state from .claude/selfish/memory/checkpoint.md and resumes work.
|
|
16
16
|
|
|
17
17
|
## Arguments
|
|
18
18
|
|
|
@@ -22,7 +22,7 @@ allowed-tools:
|
|
|
22
22
|
|
|
23
23
|
### 1. Load Checkpoint
|
|
24
24
|
|
|
25
|
-
Read
|
|
25
|
+
Read `.claude/selfish/memory/checkpoint.md`:
|
|
26
26
|
- If not found: output "No saved checkpoint found." then **stop**
|
|
27
27
|
- If found: parse the full contents
|
|
28
28
|
|
|
@@ -34,7 +34,7 @@ Compare the checkpoint state against the current environment:
|
|
|
34
34
|
- If different: warn + suggest switching
|
|
35
35
|
2. **File state**: Have any files changed since the checkpoint?
|
|
36
36
|
- Check for new commits with `git log {checkpoint hash}..HEAD --oneline`
|
|
37
|
-
3. **Feature directory**: Does specs/{feature}/ still exist?
|
|
37
|
+
3. **Feature directory**: Does .claude/selfish/specs/{feature}/ still exist?
|
|
38
38
|
|
|
39
39
|
### 3. Report State
|
|
40
40
|
|
package/commands/review.md
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: selfish:review
|
|
3
|
-
description: "Code review
|
|
3
|
+
description: "Code review"
|
|
4
4
|
argument-hint: "[scope: file path, PR number, or staged]"
|
|
5
5
|
allowed-tools:
|
|
6
6
|
- Read
|
|
7
|
+
- Write
|
|
7
8
|
- Grep
|
|
8
9
|
- Glob
|
|
9
10
|
- Bash
|
|
@@ -133,13 +134,13 @@ For each changed file, examine from the following perspectives:
|
|
|
133
134
|
|
|
134
135
|
### 5. Retrospective Check
|
|
135
136
|
|
|
136
|
-
If
|
|
137
|
+
If `.claude/selfish/memory/retrospectives/` directory exists, load retrospective files and check:
|
|
137
138
|
- Were there recurring Critical finding categories in past reviews? Prioritize those perspectives.
|
|
138
139
|
- Were there false positives that wasted effort? Reduce sensitivity for those patterns.
|
|
139
140
|
|
|
140
141
|
### 6. Critic Loop
|
|
141
142
|
|
|
142
|
-
> **Always** read
|
|
143
|
+
> **Always** read `${CLAUDE_PLUGIN_ROOT}/docs/critic-loop-rules.md` first and follow it.
|
|
143
144
|
|
|
144
145
|
Run the critic loop until convergence. Safety cap: 5 passes.
|
|
145
146
|
|
|
@@ -154,11 +155,26 @@ Run the critic loop until convergence. Safety cap: 5 passes.
|
|
|
154
155
|
**On CONVERGE**: `✓ Critic converged ({N} passes, {M} fixes, {E} escalations)`
|
|
155
156
|
**On SAFETY CAP**: `⚠ Critic safety cap ({N} passes). Review recommended.`
|
|
156
157
|
|
|
157
|
-
### 7.
|
|
158
|
+
### 7. Retrospective Entry (if new pattern found)
|
|
158
159
|
|
|
159
|
-
|
|
160
|
+
If this review reveals a recurring pattern not previously documented in `.claude/selfish/memory/retrospectives/`:
|
|
160
161
|
|
|
161
|
-
|
|
162
|
+
Append to `.claude/selfish/memory/retrospectives/{YYYY-MM-DD}.md`:
|
|
163
|
+
```markdown
|
|
164
|
+
## Pattern: {category}
|
|
165
|
+
**What happened**: {concrete description}
|
|
166
|
+
**Root cause**: {why this keeps occurring}
|
|
167
|
+
**Prevention rule**: {actionable rule — usable in future plan/implement phases}
|
|
168
|
+
**Severity**: Critical | Warning
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
Only write if the pattern is new and actionable. Generic observations are prohibited.
|
|
172
|
+
|
|
173
|
+
### 8. Archive Review Report
|
|
174
|
+
|
|
175
|
+
When running inside a pipeline (.claude/selfish/specs/{feature}/ exists), persist the review results:
|
|
176
|
+
|
|
177
|
+
1. Write full review output (Summary table + Detailed Findings + Positives) to `.claude/selfish/specs/{feature}/review-report.md`
|
|
162
178
|
2. Include metadata header:
|
|
163
179
|
```markdown
|
|
164
180
|
# Review Report: {feature name}
|
|
@@ -166,11 +182,11 @@ When running inside a pipeline (specs/{feature}/ exists), persist the review res
|
|
|
166
182
|
> Files reviewed: {count}
|
|
167
183
|
> Findings: Critical {N} / Warning {N} / Info {N}
|
|
168
184
|
```
|
|
169
|
-
3. This file survives Clean phase (copied to
|
|
185
|
+
3. This file survives Clean phase (copied to `.claude/selfish/memory/reviews/{feature}-{date}.md` before .claude/selfish/specs/ deletion)
|
|
170
186
|
|
|
171
187
|
When running standalone (no active pipeline), skip archiving — display results in console only.
|
|
172
188
|
|
|
173
|
-
###
|
|
189
|
+
### 9. Final Output
|
|
174
190
|
|
|
175
191
|
```
|
|
176
192
|
Review complete
|
package/commands/spec.md
CHANGED
|
@@ -29,7 +29,7 @@ model: sonnet
|
|
|
29
29
|
2. Determine **feature name**:
|
|
30
30
|
- Extract 2-3 key keywords from `$ARGUMENTS`
|
|
31
31
|
- Convert to kebab-case (e.g., "add user authentication" → `user-auth`)
|
|
32
|
-
3. **Create directory**:
|
|
32
|
+
3. **Create directory**: `.claude/selfish/specs/{feature-name}/` (create parent `.claude/selfish/specs/` directory if it does not exist)
|
|
33
33
|
4. If already exists, confirm with user: "Overwrite existing spec?"
|
|
34
34
|
|
|
35
35
|
### 2. Explore Codebase
|
|
@@ -42,7 +42,7 @@ Before writing the spec, understand the current project structure:
|
|
|
42
42
|
|
|
43
43
|
### 3. Write Spec
|
|
44
44
|
|
|
45
|
-
Create
|
|
45
|
+
Create `.claude/selfish/specs/{feature-name}/spec.md`:
|
|
46
46
|
|
|
47
47
|
```markdown
|
|
48
48
|
# Feature Spec: {feature name}
|
|
@@ -78,7 +78,7 @@ Create `specs/{feature-name}/spec.md`:
|
|
|
78
78
|
- **NFR-001**: {performance/security/accessibility etc.}
|
|
79
79
|
|
|
80
80
|
### Auto-Suggested NFRs
|
|
81
|
-
{Load
|
|
81
|
+
{Load `${CLAUDE_PLUGIN_ROOT}/docs/nfr-templates.md` and select 3-5 relevant NFRs based on the project type detected from selfish.config.md}
|
|
82
82
|
- **NFR-A01** [AUTO-SUGGESTED]: {suggestion from matching project type template}
|
|
83
83
|
- **NFR-A02** [AUTO-SUGGESTED]: {suggestion}
|
|
84
84
|
- **NFR-A03** [AUTO-SUGGESTED]: {suggestion}
|
|
@@ -106,13 +106,13 @@ Create `specs/{feature-name}/spec.md`:
|
|
|
106
106
|
|
|
107
107
|
### 4. Retrospective Check
|
|
108
108
|
|
|
109
|
-
If
|
|
109
|
+
If `.claude/selfish/memory/retrospectives/` directory exists, load retrospective files and check:
|
|
110
110
|
- Were there previous `[AUTO-RESOLVED]` items that turned out wrong? Flag similar patterns.
|
|
111
111
|
- Were there scope-related issues in past specs? Warn about similar ambiguities.
|
|
112
112
|
|
|
113
113
|
### 5. Critic Loop
|
|
114
114
|
|
|
115
|
-
> **Always** read
|
|
115
|
+
> **Always** read `${CLAUDE_PLUGIN_ROOT}/docs/critic-loop-rules.md` first and follow it.
|
|
116
116
|
|
|
117
117
|
Run the critic loop until convergence. Safety cap: 5 passes.
|
|
118
118
|
|
|
@@ -133,7 +133,7 @@ Run the critic loop until convergence. Safety cap: 5 passes.
|
|
|
133
133
|
|
|
134
134
|
```
|
|
135
135
|
Spec generated
|
|
136
|
-
├─ specs/{feature-name}/spec.md
|
|
136
|
+
├─ .claude/selfish/specs/{feature-name}/spec.md
|
|
137
137
|
├─ User Stories: {count}
|
|
138
138
|
├─ Requirements: FR {count}, NFR {count}
|
|
139
139
|
├─ Unresolved: {[NEEDS CLARIFICATION] count}
|
package/commands/tasks.md
CHANGED
|
@@ -22,7 +22,7 @@ model: sonnet
|
|
|
22
22
|
|
|
23
23
|
### 1. Load Context
|
|
24
24
|
|
|
25
|
-
1. Load from
|
|
25
|
+
1. Load from `.claude/selfish/specs/{feature}/`:
|
|
26
26
|
- **plan.md** (required) — stop if missing: "Run /selfish:plan first."
|
|
27
27
|
- **spec.md** (required)
|
|
28
28
|
- **research.md** (if present)
|
|
@@ -73,20 +73,20 @@ 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. **[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.
|
|
76
|
+
4. **[P] physical validation**: Before finalizing tasks.md, run `"${CLAUDE_PLUGIN_ROOT}/scripts/selfish-parallel-validate.sh" .claude/selfish/specs/{feature}/tasks.md` to verify no file path overlaps exist among [P] tasks within the same phase. Fix any conflicts before proceeding.
|
|
77
77
|
5. **Dependency graph must be a DAG**: no circular dependencies allowed. Validate before output.
|
|
78
78
|
6. **Test tasks**: Include a verification task for each testable unit
|
|
79
79
|
7. **Phase gate**: Add a `{config.gate}` validation task at the end of each Phase
|
|
80
80
|
|
|
81
81
|
### 3. Retrospective Check
|
|
82
82
|
|
|
83
|
-
If
|
|
83
|
+
If `.claude/selfish/memory/retrospectives/` directory exists, load retrospective files and check:
|
|
84
84
|
- Were there previous parallel conflict issues ([P] file overlaps)? Flag similar file patterns.
|
|
85
85
|
- Were there tasks that were over-decomposed or under-decomposed? Adjust granularity.
|
|
86
86
|
|
|
87
87
|
### 4. Critic Loop
|
|
88
88
|
|
|
89
|
-
> **Always** read
|
|
89
|
+
> **Always** read `${CLAUDE_PLUGIN_ROOT}/docs/critic-loop-rules.md` first and follow it.
|
|
90
90
|
|
|
91
91
|
Run the critic loop until convergence. Safety cap: 5 passes.
|
|
92
92
|
|
|
@@ -116,11 +116,11 @@ Every FR-*/NFR-* must be mapped to at least one task.
|
|
|
116
116
|
|
|
117
117
|
### 6. Final Output
|
|
118
118
|
|
|
119
|
-
Save to
|
|
119
|
+
Save to `.claude/selfish/specs/{feature}/tasks.md`, then:
|
|
120
120
|
|
|
121
121
|
```
|
|
122
122
|
Tasks generated
|
|
123
|
-
├─ specs/{feature}/tasks.md
|
|
123
|
+
├─ .claude/selfish/specs/{feature}/tasks.md
|
|
124
124
|
├─ Tasks: {total count} ({[P] count} parallelizable)
|
|
125
125
|
├─ Phases: {phase count}
|
|
126
126
|
├─ Coverage: FR {coverage}%, NFR {coverage}%
|
package/commands/test.md
CHANGED
|
@@ -75,7 +75,7 @@ Confirm strategy with user before proceeding.
|
|
|
75
75
|
|
|
76
76
|
### 4. Critic Loop
|
|
77
77
|
|
|
78
|
-
> **Always** read
|
|
78
|
+
> **Always** read `${CLAUDE_PLUGIN_ROOT}/docs/critic-loop-rules.md` first and follow it.
|
|
79
79
|
|
|
80
80
|
Run the critic loop until convergence. Safety cap: 5 passes.
|
|
81
81
|
|
|
@@ -6,7 +6,11 @@
|
|
|
6
6
|
|
|
7
7
|
1. **Minimum findings**: In each Critic round, **at least 1 concern, improvement point, or verification rationale per criterion** must be stated. If there are no issues, explain specifically "why there are no issues."
|
|
8
8
|
2. **Checklist responses**: For each criterion, output takes the form of answering specific questions. Single-word "PASS" is prohibited.
|
|
9
|
-
3. **Adversarial Pass**: At the end of every round,
|
|
9
|
+
3. **Adversarial Pass**: At the end of every round, apply **3 progressive critic perspectives**:
|
|
10
|
+
- **Skeptic**: "Which assumption here is most likely wrong?"
|
|
11
|
+
- **Devil's Advocate**: "How could this design be misused or fail unexpectedly?"
|
|
12
|
+
- **Edge-case Hunter**: "What input would cause this to fail silently?"
|
|
13
|
+
State one failure scenario per perspective. If any scenario is realistic → convert to FAIL and fix. If all are unrealistic → state quantitative rationale for each.
|
|
10
14
|
4. **Quantitative rationale**: Instead of qualitative judgments like "none" or "compliant," present quantitative data such as "M of N confirmed," "Y of X lines applicable."
|
|
11
15
|
|
|
12
16
|
## Verdict System (4 types)
|
|
@@ -75,8 +79,11 @@ Options:
|
|
|
75
79
|
[Criterion1] {question} → {answer + quantitative rationale}
|
|
76
80
|
Verdict: PASS | FAIL ({fix description}) | ESCALATE | DEFER ({reason})
|
|
77
81
|
[Criterion2] ...
|
|
78
|
-
[ADVERSARIAL]
|
|
79
|
-
|
|
82
|
+
[ADVERSARIAL]
|
|
83
|
+
Skeptic: {assumption most likely wrong}
|
|
84
|
+
Devil's Advocate: {misuse or unexpected failure}
|
|
85
|
+
Edge-case Hunter: {input causing silent failure}
|
|
86
|
+
→ Realistic? {Y → FAIL + fix / N → state quantitative rationale per perspective}
|
|
80
87
|
=== Result: {CONVERGED ({N} passes, {M} fixes, {E} escalations) | CONTINUE ({N} fixed) | ESCALATE ({N} items) | SAFETY CAP} ===
|
|
81
88
|
```
|
|
82
89
|
|
|
@@ -34,7 +34,7 @@ Quantitatively inspect `{config.mini_review}` items for files changed within the
|
|
|
34
34
|
After passing the Phase gate, automatically save session state:
|
|
35
35
|
|
|
36
36
|
```markdown
|
|
37
|
-
# memory/checkpoint.md auto-update
|
|
37
|
+
# .claude/selfish/memory/checkpoint.md auto-update
|
|
38
38
|
Current Phase: {N}/{total}
|
|
39
39
|
Completed tasks: {list of completed IDs}
|
|
40
40
|
Changed files: {file list}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "selfish-pipeline",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Claude Code plugin that automates the full dev cycle — spec, plan, tasks, implement, review, clean. 18 commands, 15 hooks, 5 presets.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"selfish-pipeline": "./bin/cli.mjs"
|
|
@@ -59,8 +59,8 @@ fi
|
|
|
59
59
|
# Check tasks.md progress status
|
|
60
60
|
TASKS_DONE=0
|
|
61
61
|
TASKS_TOTAL=0
|
|
62
|
-
if [ -n "$PIPELINE_FEATURE" ] && [ -d "$PROJECT_DIR/specs/$PIPELINE_FEATURE" ]; then
|
|
63
|
-
TASKS_FILE="$PROJECT_DIR/specs/$PIPELINE_FEATURE/tasks.md"
|
|
62
|
+
if [ -n "$PIPELINE_FEATURE" ] && [ -d "$PROJECT_DIR/.claude/selfish/specs/$PIPELINE_FEATURE" ]; then
|
|
63
|
+
TASKS_FILE="$PROJECT_DIR/.claude/selfish/specs/$PIPELINE_FEATURE/tasks.md"
|
|
64
64
|
if [ -f "$TASKS_FILE" ]; then
|
|
65
65
|
TASKS_DONE=$(grep -cE '\[x\]' "$TASKS_FILE" 2>/dev/null || echo 0)
|
|
66
66
|
TASKS_TOTAL=$(grep -cE '\[(x| )\]' "$TASKS_FILE" 2>/dev/null || echo 0)
|
|
@@ -107,6 +107,6 @@ $STAGED_LIST
|
|
|
107
107
|
EOF
|
|
108
108
|
|
|
109
109
|
# Inject context via stdout (Claude can see this info after compaction)
|
|
110
|
-
echo "Auto-checkpoint saved to memory/checkpoint.md (branch: $BRANCH, pipeline: ${PIPELINE_FEATURE:-inactive})"
|
|
110
|
+
echo "Auto-checkpoint saved to .claude/selfish/memory/checkpoint.md (branch: $BRANCH, pipeline: ${PIPELINE_FEATURE:-inactive})"
|
|
111
111
|
|
|
112
112
|
exit 0
|
|
@@ -14,33 +14,122 @@ WARN_COUNT=0
|
|
|
14
14
|
FAIL_COUNT=0
|
|
15
15
|
|
|
16
16
|
CI_COMMAND=""
|
|
17
|
+
CI_SOURCE=""
|
|
18
|
+
|
|
19
|
+
# ── Helpers ──────────────────────────────────────────────
|
|
20
|
+
|
|
21
|
+
# shellcheck disable=SC2317
|
|
22
|
+
_detect_pm() {
|
|
23
|
+
local dir="$1"
|
|
24
|
+
if [[ -f "$dir/pnpm-lock.yaml" ]]; then printf 'pnpm'
|
|
25
|
+
elif [[ -f "$dir/yarn.lock" ]]; then printf 'yarn'
|
|
26
|
+
elif [[ -f "$dir/bun.lock" || -f "$dir/bun.lockb" ]]; then printf 'bun'
|
|
27
|
+
elif [[ -f "$dir/package-lock.json" ]]; then printf 'npm'
|
|
28
|
+
elif [[ -f "$dir/package.json" ]] && command -v jq > /dev/null 2>&1; then
|
|
29
|
+
local pm_field
|
|
30
|
+
pm_field=$(jq -r '.packageManager // empty' "$dir/package.json" 2>/dev/null)
|
|
31
|
+
if [[ -n "$pm_field" ]]; then
|
|
32
|
+
printf '%s' "${pm_field%%@*}"
|
|
33
|
+
else
|
|
34
|
+
printf 'npm'
|
|
35
|
+
fi
|
|
36
|
+
else
|
|
37
|
+
printf 'npm'
|
|
38
|
+
fi
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
# shellcheck disable=SC2317
|
|
42
|
+
_has_script() {
|
|
43
|
+
local pkg="$1" script="$2"
|
|
44
|
+
if command -v jq > /dev/null 2>&1; then
|
|
45
|
+
jq -e ".scripts[\"$script\"]" "$pkg" > /dev/null 2>&1
|
|
46
|
+
else
|
|
47
|
+
grep -qE "\"$script\"[[:space:]]*:" "$pkg" 2>/dev/null
|
|
48
|
+
fi
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
# ── PM Detection (lockfile-first, Turborepo pattern) ─────
|
|
52
|
+
|
|
53
|
+
PM=$(_detect_pm "$PROJECT_DIR")
|
|
17
54
|
|
|
18
55
|
printf 'Preflight Check:\n'
|
|
19
56
|
|
|
20
|
-
# Check 1: CI command
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
57
|
+
# ── Check 1: CI command (4-tier cascade) ─────────────────
|
|
58
|
+
|
|
59
|
+
# 1a. selfish.config.md — most explicit, user-configured
|
|
60
|
+
CONFIG_FILE="$PROJECT_DIR/.claude/selfish.config.md"
|
|
61
|
+
if [[ -z "$CI_COMMAND" && -f "$CONFIG_FILE" ]]; then
|
|
62
|
+
CI_COMMAND=$(grep -E '^\s*ci:\s*"[^"]*"' "$CONFIG_FILE" 2>/dev/null | head -1 | sed 's/.*ci: *"\([^"]*\)".*/\1/' || true)
|
|
63
|
+
if [[ -z "$CI_COMMAND" ]]; then
|
|
64
|
+
CI_COMMAND=$(grep -E '^\s*gate:\s*"[^"]*"' "$CONFIG_FILE" 2>/dev/null | head -1 | sed 's/.*gate: *"\([^"]*\)".*/\1/' || true)
|
|
26
65
|
fi
|
|
66
|
+
[[ -n "$CI_COMMAND" ]] && CI_SOURCE="selfish.config.md"
|
|
27
67
|
fi
|
|
28
68
|
|
|
69
|
+
# 1b. Monorepo tools (turbo, nx, pnpm workspaces)
|
|
70
|
+
if [[ -z "$CI_COMMAND" ]]; then
|
|
71
|
+
if [[ -f "$PROJECT_DIR/turbo.json" ]]; then
|
|
72
|
+
if [[ "$PM" == "pnpm" || "$PM" == "yarn" || "$PM" == "bun" ]]; then
|
|
73
|
+
CI_COMMAND="$PM turbo test"
|
|
74
|
+
else
|
|
75
|
+
CI_COMMAND="npx turbo test"
|
|
76
|
+
fi
|
|
77
|
+
CI_SOURCE="turbo.json"
|
|
78
|
+
elif [[ -f "$PROJECT_DIR/nx.json" ]]; then
|
|
79
|
+
CI_COMMAND="npx nx run-many --target=test"
|
|
80
|
+
CI_SOURCE="nx.json"
|
|
81
|
+
elif [[ -f "$PROJECT_DIR/pnpm-workspace.yaml" ]] && ! _has_script "$PROJECT_DIR/package.json" "test" 2>/dev/null; then
|
|
82
|
+
CI_COMMAND="pnpm -r test"
|
|
83
|
+
CI_SOURCE="pnpm-workspace.yaml"
|
|
84
|
+
fi
|
|
85
|
+
fi
|
|
86
|
+
|
|
87
|
+
# 1c. package.json scripts (PM-aware)
|
|
88
|
+
if [[ -z "$CI_COMMAND" && -f "$PROJECT_DIR/package.json" ]]; then
|
|
89
|
+
for script in "test:all" "test" "ci" "check"; do
|
|
90
|
+
if _has_script "$PROJECT_DIR/package.json" "$script"; then
|
|
91
|
+
if [[ "$script" == "test" ]]; then
|
|
92
|
+
CI_COMMAND="$PM test"
|
|
93
|
+
else
|
|
94
|
+
CI_COMMAND="$PM run $script"
|
|
95
|
+
fi
|
|
96
|
+
CI_SOURCE="package.json"
|
|
97
|
+
break
|
|
98
|
+
fi
|
|
99
|
+
done
|
|
100
|
+
fi
|
|
101
|
+
|
|
102
|
+
# 1d. Makefile
|
|
103
|
+
if [[ -z "$CI_COMMAND" && -f "$PROJECT_DIR/Makefile" ]]; then
|
|
104
|
+
MAKE_TARGET=$(grep -E '^(test|check|ci):' "$PROJECT_DIR/Makefile" 2>/dev/null | head -1 | cut -d: -f1 || true)
|
|
105
|
+
if [[ -n "$MAKE_TARGET" ]]; then
|
|
106
|
+
CI_COMMAND="make $MAKE_TARGET"
|
|
107
|
+
CI_SOURCE="Makefile"
|
|
108
|
+
fi
|
|
109
|
+
fi
|
|
110
|
+
|
|
111
|
+
# Report CI command result
|
|
29
112
|
if [[ -n "$CI_COMMAND" ]]; then
|
|
30
|
-
printf ' \xe2\x9c\x93 CI command: %s\n' "$CI_COMMAND"
|
|
113
|
+
printf ' \xe2\x9c\x93 CI command: %s [%s]\n' "$CI_COMMAND" "$CI_SOURCE"
|
|
31
114
|
PASS_COUNT=$((PASS_COUNT + 1))
|
|
32
|
-
|
|
115
|
+
elif [[ -f "$PROJECT_DIR/package.json" ]]; then
|
|
116
|
+
# package.json exists but no CI script — configuration error
|
|
33
117
|
printf ' \xe2\x9c\x97 CI command: no test script found in package.json\n'
|
|
34
118
|
FAIL_COUNT=$((FAIL_COUNT + 1))
|
|
119
|
+
else
|
|
120
|
+
# No recognizable ecosystem — warn instead of fail
|
|
121
|
+
printf ' \xe2\x9a\xa0 CI command: not detected (configure ci: in selfish.config.md)\n'
|
|
122
|
+
WARN_COUNT=$((WARN_COUNT + 1))
|
|
35
123
|
fi
|
|
36
124
|
|
|
37
|
-
# Check 2: Dependencies installed
|
|
125
|
+
# ── Check 2: Dependencies installed ──────────────────────
|
|
126
|
+
|
|
38
127
|
if [[ -f "$PROJECT_DIR/package.json" ]]; then
|
|
39
128
|
if [[ -d "$PROJECT_DIR/node_modules" ]]; then
|
|
40
129
|
printf ' \xe2\x9c\x93 Dependencies: node_modules present\n'
|
|
41
130
|
PASS_COUNT=$((PASS_COUNT + 1))
|
|
42
131
|
else
|
|
43
|
-
printf ' \xe2\x9a\xa0 Dependencies: node_modules not found (run
|
|
132
|
+
printf ' \xe2\x9a\xa0 Dependencies: node_modules not found (run %s install)\n' "$PM"
|
|
44
133
|
WARN_COUNT=$((WARN_COUNT + 1))
|
|
45
134
|
fi
|
|
46
135
|
else
|
|
@@ -48,7 +137,8 @@ else
|
|
|
48
137
|
PASS_COUNT=$((PASS_COUNT + 1))
|
|
49
138
|
fi
|
|
50
139
|
|
|
51
|
-
# Check 3: Shellcheck available
|
|
140
|
+
# ── Check 3: Shellcheck available ────────────────────────
|
|
141
|
+
|
|
52
142
|
if command -v shellcheck > /dev/null 2>&1; then
|
|
53
143
|
printf ' \xe2\x9c\x93 Shellcheck: installed\n'
|
|
54
144
|
PASS_COUNT=$((PASS_COUNT + 1))
|
|
@@ -57,7 +147,8 @@ else
|
|
|
57
147
|
WARN_COUNT=$((WARN_COUNT + 1))
|
|
58
148
|
fi
|
|
59
149
|
|
|
60
|
-
# Check 4: Git state
|
|
150
|
+
# ── Check 4: Git state ───────────────────────────────────
|
|
151
|
+
|
|
61
152
|
if git -C "$PROJECT_DIR" rev-parse --is-inside-work-tree > /dev/null 2>&1; then
|
|
62
153
|
DIRTY_COUNT=$(git -C "$PROJECT_DIR" status --porcelain 2>/dev/null | wc -l | tr -d ' ')
|
|
63
154
|
if [[ "$DIRTY_COUNT" -eq 0 ]]; then
|
|
@@ -72,7 +163,8 @@ else
|
|
|
72
163
|
WARN_COUNT=$((WARN_COUNT + 1))
|
|
73
164
|
fi
|
|
74
165
|
|
|
75
|
-
# Check 5: No active pipeline
|
|
166
|
+
# ── Check 5: No active pipeline ──────────────────────────
|
|
167
|
+
|
|
76
168
|
ACTIVE_FILE="$PROJECT_DIR/.claude/.selfish-active"
|
|
77
169
|
if [[ -f "$ACTIVE_FILE" ]]; then
|
|
78
170
|
ACTIVE_NAME=$(head -1 "$ACTIVE_FILE" 2>/dev/null | tr -d '\n\r' | cut -c1-100 || printf 'unknown')
|
|
@@ -83,7 +175,8 @@ else
|
|
|
83
175
|
PASS_COUNT=$((PASS_COUNT + 1))
|
|
84
176
|
fi
|
|
85
177
|
|
|
86
|
-
# Result
|
|
178
|
+
# ── Result ────────────────────────────────────────────────
|
|
179
|
+
|
|
87
180
|
printf '\n'
|
|
88
181
|
if [[ "$FAIL_COUNT" -gt 0 ]]; then
|
|
89
182
|
if [[ "$WARN_COUNT" -gt 0 ]]; then
|
|
@@ -36,7 +36,7 @@ if [ -f "$PIPELINE_FLAG" ]; then
|
|
|
36
36
|
OUTPUT="[SELFISH PIPELINE ACTIVE] Feature: $FEATURE"
|
|
37
37
|
|
|
38
38
|
# tasks.md progress
|
|
39
|
-
TASKS_FILE="$PROJECT_DIR/specs/$FEATURE/tasks.md"
|
|
39
|
+
TASKS_FILE="$PROJECT_DIR/.claude/selfish/specs/$FEATURE/tasks.md"
|
|
40
40
|
if [ -f "$TASKS_FILE" ]; then
|
|
41
41
|
DONE=$(grep -cE '\[x\]' "$TASKS_FILE" 2>/dev/null || echo 0)
|
|
42
42
|
TOTAL=$(grep -cE '\[(x| )\]' "$TASKS_FILE" 2>/dev/null || echo 0)
|