@lvlup-sw/exarchos 2.0.1
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 +22 -0
- package/.claude-plugin/plugin.json +17 -0
- package/.mcp.json +17 -0
- package/AGENTS.md +59 -0
- package/CLAUDE.md.template +62 -0
- package/LICENSE +202 -0
- package/README.md +258 -0
- package/commands/autocompact.md +37 -0
- package/commands/checkpoint.md +85 -0
- package/commands/cleanup.md +99 -0
- package/commands/debug.md +145 -0
- package/commands/delegate.md +56 -0
- package/commands/ideate.md +82 -0
- package/commands/plan.md +150 -0
- package/commands/refactor.md +139 -0
- package/commands/reload.md +37 -0
- package/commands/resume.md +130 -0
- package/commands/review.md +51 -0
- package/commands/sync-schemas.md +74 -0
- package/commands/synthesize.md +122 -0
- package/commands/tdd.md +58 -0
- package/dist/exarchos-cli.js +8828 -0
- package/dist/exarchos-mcp.js +50 -0
- package/hooks/hooks.json +53 -0
- package/package.json +59 -0
- package/rules/coding-standards.md +46 -0
- package/rules/mcp-tool-guidance.md +26 -0
- package/rules/pr-descriptions.md +12 -0
- package/rules/rm-safety.md +9 -0
- package/rules/skill-path-resolution.md +10 -0
- package/rules/tdd.md +41 -0
- package/rules/telemetry-awareness.md +9 -0
- package/scripts/assess-refactor-scope.sh +239 -0
- package/scripts/check-benchmark-regression.sh +229 -0
- package/scripts/check-coderabbit.sh +288 -0
- package/scripts/check-coverage-thresholds.sh +194 -0
- package/scripts/check-polish-scope.sh +245 -0
- package/scripts/check-property-tests.sh +167 -0
- package/scripts/check-tdd-compliance.sh +265 -0
- package/scripts/coderabbit-review-gate.sh +518 -0
- package/scripts/debug-review-gate.sh +201 -0
- package/scripts/extract-fix-tasks.sh +179 -0
- package/scripts/extract-task.sh +67 -0
- package/scripts/generate-traceability.sh +209 -0
- package/scripts/investigation-timer.sh +171 -0
- package/scripts/needs-schema-sync.sh +174 -0
- package/scripts/new-project.sh +103 -0
- package/scripts/post-delegation-check.sh +317 -0
- package/scripts/pre-synthesis-check.sh +440 -0
- package/scripts/reconcile-state.sh +346 -0
- package/scripts/reconstruct-stack.sh +432 -0
- package/scripts/review-diff.sh +63 -0
- package/scripts/review-verdict.sh +169 -0
- package/scripts/security-scan.sh +248 -0
- package/scripts/select-debug-track.sh +186 -0
- package/scripts/setup-worktree.sh +323 -0
- package/scripts/spec-coverage-check.sh +230 -0
- package/scripts/static-analysis-gate.sh +236 -0
- package/scripts/sync-labels.sh +122 -0
- package/scripts/validate-companion.sh +161 -0
- package/scripts/validate-dotnet-standards.sh +267 -0
- package/scripts/validate-installation.sh +101 -0
- package/scripts/validate-plugin.sh +223 -0
- package/scripts/validate-refactor.sh +234 -0
- package/scripts/validate-rm.sh +93 -0
- package/scripts/verify-delegation-saga.sh +240 -0
- package/scripts/verify-doc-links.sh +211 -0
- package/scripts/verify-ideate-artifacts.sh +296 -0
- package/scripts/verify-plan-coverage.sh +228 -0
- package/scripts/verify-review-triage.sh +219 -0
- package/scripts/verify-worktree-baseline.sh +159 -0
- package/scripts/verify-worktree.sh +84 -0
- package/settings.json +47 -0
- package/skills/brainstorming/SKILL.md +127 -0
- package/skills/brainstorming/references/design-template.md +65 -0
- package/skills/cleanup/SKILL.md +147 -0
- package/skills/cleanup/references/merge-verification.md +40 -0
- package/skills/debug/SKILL.md +204 -0
- package/skills/debug/references/hotfix-track.md +134 -0
- package/skills/debug/references/investigation-checklist.md +217 -0
- package/skills/debug/references/rca-template.md +150 -0
- package/skills/debug/references/state-schema.md +294 -0
- package/skills/debug/references/thorough-track.md +194 -0
- package/skills/debug/references/triage-questions.md +155 -0
- package/skills/debug/references/troubleshooting.md +47 -0
- package/skills/delegation/SKILL.md +150 -0
- package/skills/delegation/references/adaptive-orchestration.md +31 -0
- package/skills/delegation/references/agent-teams-saga.md +248 -0
- package/skills/delegation/references/fix-mode.md +74 -0
- package/skills/delegation/references/fixer-prompt.md +162 -0
- package/skills/delegation/references/implementer-prompt.md +322 -0
- package/skills/delegation/references/parallel-strategy.md +124 -0
- package/skills/delegation/references/pbt-patterns.md +172 -0
- package/skills/delegation/references/pr-fixes-mode.md +154 -0
- package/skills/delegation/references/state-management.md +51 -0
- package/skills/delegation/references/testing-patterns.md +129 -0
- package/skills/delegation/references/troubleshooting.md +33 -0
- package/skills/delegation/references/workflow-steps.md +127 -0
- package/skills/delegation/references/worktree-enforcement.md +64 -0
- package/skills/dotnet-standards/SKILL.md +269 -0
- package/skills/dotnet-standards/references/csharp-standards.md +120 -0
- package/skills/dotnet-standards/templates/.editorconfig +366 -0
- package/skills/dotnet-standards/templates/Directory.Build.props +56 -0
- package/skills/dotnet-standards/templates/Directory.Packages.props +69 -0
- package/skills/dotnet-standards/templates/global.json +6 -0
- package/skills/dotnet-standards/templates/nuget.config +9 -0
- package/skills/dotnet-standards/templates/stylecop.json +37 -0
- package/skills/git-worktrees/SKILL.md +255 -0
- package/skills/implementation-planning/SKILL.md +233 -0
- package/skills/implementation-planning/references/plan-document-template.md +42 -0
- package/skills/implementation-planning/references/spec-tracing-guide.md +51 -0
- package/skills/implementation-planning/references/task-template.md +43 -0
- package/skills/implementation-planning/references/testing-strategy-guide.md +88 -0
- package/skills/quality-review/SKILL.md +278 -0
- package/skills/quality-review/references/code-quality-checklist.md +159 -0
- package/skills/quality-review/references/review-report-template.md +65 -0
- package/skills/quality-review/references/security-checklist.md +79 -0
- package/skills/quality-review/references/typescript-standards.md +24 -0
- package/skills/refactor/COMMAND.md +67 -0
- package/skills/refactor/SKILL.md +198 -0
- package/skills/refactor/phases/auto-chain.md +262 -0
- package/skills/refactor/phases/brief.md +176 -0
- package/skills/refactor/phases/explore.md +132 -0
- package/skills/refactor/phases/overhaul-delegate.md +136 -0
- package/skills/refactor/phases/overhaul-plan.md +312 -0
- package/skills/refactor/phases/overhaul-review.md +304 -0
- package/skills/refactor/phases/polish-implement.md +349 -0
- package/skills/refactor/phases/polish-validate.md +218 -0
- package/skills/refactor/phases/update-docs.md +234 -0
- package/skills/refactor/references/brief-template.md +81 -0
- package/skills/refactor/references/doc-update-checklist.md +110 -0
- package/skills/refactor/references/explore-checklist.md +73 -0
- package/skills/refactor/references/overhaul-track.md +215 -0
- package/skills/refactor/references/polish-track.md +170 -0
- package/skills/shared/prompts/context-reading.md +58 -0
- package/skills/shared/prompts/report-format.md +54 -0
- package/skills/shared/prompts/tdd-requirements.md +39 -0
- package/skills/shepherd/SKILL.md +264 -0
- package/skills/shepherd/references/assess-checklist.md +124 -0
- package/skills/shepherd/references/fix-strategies.md +191 -0
- package/skills/spec-review/SKILL.md +229 -0
- package/skills/spec-review/references/review-checklist.md +60 -0
- package/skills/sync-schemas/SKILL.md +114 -0
- package/skills/sync-schemas/references/configuration.md +73 -0
- package/skills/synthesis/SKILL.md +129 -0
- package/skills/synthesis/references/pr-descriptions.md +87 -0
- package/skills/synthesis/references/synthesis-steps.md +109 -0
- package/skills/synthesis/references/troubleshooting.md +115 -0
- package/skills/validate-all-skills.sh +57 -0
- package/skills/validate-frontmatter.sh +237 -0
- package/skills/workflow-state/SKILL.md +210 -0
- package/skills/workflow-state/references/mcp-tool-reference.md +111 -0
- package/skills/workflow-state/references/phase-transitions.md +141 -0
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
# Explore Phase
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
Assess refactoring scope to determine appropriate track (polish vs overhaul).
|
|
6
|
+
|
|
7
|
+
## Entry Conditions
|
|
8
|
+
|
|
9
|
+
- Refactor workflow initiated via `/exarchos:refactor`
|
|
10
|
+
- Target area identified (file, directory, or module)
|
|
11
|
+
|
|
12
|
+
## Process
|
|
13
|
+
|
|
14
|
+
### Step 1: Scope Discovery
|
|
15
|
+
|
|
16
|
+
Use exploration tools to understand the impact:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
# Find files that will be affected
|
|
20
|
+
# Use Glob to find files in target area
|
|
21
|
+
# Use Grep to find references to target code
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Questions to answer:
|
|
25
|
+
1. How many files will be modified?
|
|
26
|
+
2. How many modules/packages are affected?
|
|
27
|
+
3. Are there cross-module dependencies?
|
|
28
|
+
4. What's the test coverage of affected code?
|
|
29
|
+
|
|
30
|
+
### Step 2: Concern Analysis
|
|
31
|
+
|
|
32
|
+
Identify what types of changes are needed:
|
|
33
|
+
|
|
34
|
+
- [ ] Renaming (variables, functions, files)
|
|
35
|
+
- [ ] Extracting (new functions, classes, modules)
|
|
36
|
+
- [ ] Moving (relocating code between files/modules)
|
|
37
|
+
- [ ] Restructuring (changing architecture)
|
|
38
|
+
- [ ] Cleaning (removing dead code, improving style)
|
|
39
|
+
|
|
40
|
+
Count distinct concerns - multiple indicates overhaul track.
|
|
41
|
+
|
|
42
|
+
### Step 3: Test Assessment
|
|
43
|
+
|
|
44
|
+
Evaluate existing test coverage:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
# Check for test files covering affected code
|
|
48
|
+
# Review test coverage if available
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
| Coverage Level | Implication |
|
|
52
|
+
|----------------|-------------|
|
|
53
|
+
| Good (>80%) | Either track viable |
|
|
54
|
+
| Gaps (50-80%) | Overhaul recommended (need test additions) |
|
|
55
|
+
| Poor (<50%) | Overhaul required (significant test work) |
|
|
56
|
+
|
|
57
|
+
### Step 4: Documentation Check
|
|
58
|
+
|
|
59
|
+
Identify docs that reference affected code:
|
|
60
|
+
|
|
61
|
+
- Architecture documentation
|
|
62
|
+
- API documentation
|
|
63
|
+
- README files
|
|
64
|
+
- Inline comments with explanations
|
|
65
|
+
|
|
66
|
+
Significant doc updates → overhaul track indicator.
|
|
67
|
+
|
|
68
|
+
## Track Decision Matrix
|
|
69
|
+
|
|
70
|
+
| Criterion | Polish | Overhaul |
|
|
71
|
+
|-----------|--------|----------|
|
|
72
|
+
| Files affected | <=5 | >5 |
|
|
73
|
+
| Concerns | 1 | >1 |
|
|
74
|
+
| Cross-module | No | Yes |
|
|
75
|
+
| Test gaps | No | Yes |
|
|
76
|
+
| Doc updates | Minor | Significant |
|
|
77
|
+
|
|
78
|
+
**Rule**: If ANY criterion indicates overhaul, use overhaul track.
|
|
79
|
+
|
|
80
|
+
## Output
|
|
81
|
+
|
|
82
|
+
**Save assessment and advance to brief:**
|
|
83
|
+
|
|
84
|
+
```
|
|
85
|
+
action: "set", featureId: "refactor-<slug>", updates: {
|
|
86
|
+
"explore": {
|
|
87
|
+
"filesAffected": <count>,
|
|
88
|
+
"filesList": ["<path1>", "<path2>"],
|
|
89
|
+
"modulesAffected": ["<module1>"],
|
|
90
|
+
"concerns": ["<concern1>", "<concern2>"],
|
|
91
|
+
"crossModule": <true|false>,
|
|
92
|
+
"testCoverage": "<good|gaps|none>",
|
|
93
|
+
"docsImpacted": ["<doc1>"],
|
|
94
|
+
"recommendedTrack": "<polish|overhaul>",
|
|
95
|
+
"completedAt": "<ISO8601>"
|
|
96
|
+
}
|
|
97
|
+
}, phase: "brief"
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Exit Conditions
|
|
101
|
+
|
|
102
|
+
- Scope assessment complete
|
|
103
|
+
- Track recommendation recorded
|
|
104
|
+
- State updated with findings
|
|
105
|
+
- Ready to proceed to brief phase
|
|
106
|
+
|
|
107
|
+
## If --explore-only Flag
|
|
108
|
+
|
|
109
|
+
When `--explore-only` is specified:
|
|
110
|
+
|
|
111
|
+
1. Complete assessment as normal
|
|
112
|
+
2. Output summary to user
|
|
113
|
+
3. Do NOT transition to brief phase
|
|
114
|
+
4. Keep phase as "explore" in state
|
|
115
|
+
|
|
116
|
+
```markdown
|
|
117
|
+
## Exploration Summary
|
|
118
|
+
|
|
119
|
+
**Target:** <target path>
|
|
120
|
+
**Recommended Track:** <polish|overhaul>
|
|
121
|
+
|
|
122
|
+
### Scope Assessment
|
|
123
|
+
- Files: <count>
|
|
124
|
+
- Modules: <list>
|
|
125
|
+
- Concerns: <list>
|
|
126
|
+
- Cross-module: <yes|no>
|
|
127
|
+
- Test coverage: <good|gaps|none>
|
|
128
|
+
- Docs to update: <list>
|
|
129
|
+
|
|
130
|
+
### Rationale
|
|
131
|
+
<explanation of track recommendation>
|
|
132
|
+
```
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
# Overhaul Track: Delegate/Review
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
Execute large refactors using worktree-isolated subagents with the standard delegation workflow.
|
|
6
|
+
|
|
7
|
+
## Entry Conditions
|
|
8
|
+
|
|
9
|
+
- Track is `overhaul`
|
|
10
|
+
- Plan created with tasks defined
|
|
11
|
+
- Tasks defined in plan document
|
|
12
|
+
|
|
13
|
+
## Phase Flow
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
delegate → review → [update-docs OR delegate --fixes]
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Delegation Phase
|
|
20
|
+
|
|
21
|
+
Invoke the delegation skill with explicit Skill tool call:
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
Skill({ skill: "exarchos:delegate", args: "~/.claude/workflow-state/<feature>.state.json" })
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
The `/exarchos:delegate` skill handles:
|
|
28
|
+
- Creating worktrees for each task
|
|
29
|
+
- Dispatching subagents via Task tool with `model: "opus"`
|
|
30
|
+
- Using the implementer prompt template
|
|
31
|
+
- Tracking task completion in state
|
|
32
|
+
|
|
33
|
+
### Refactor-Specific Task Guidance
|
|
34
|
+
|
|
35
|
+
Each delegated task should emphasize:
|
|
36
|
+
|
|
37
|
+
1. **Working State**: Code must compile and tests pass after task
|
|
38
|
+
2. **Atomic Changes**: One logical change per commit
|
|
39
|
+
3. **Test-First**: New code should have tests
|
|
40
|
+
|
|
41
|
+
Example task prompt addition:
|
|
42
|
+
```
|
|
43
|
+
IMPORTANT: After this task, code MUST:
|
|
44
|
+
- Build successfully
|
|
45
|
+
- Pass all tests
|
|
46
|
+
- Not break existing functionality
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Task Dependencies
|
|
50
|
+
|
|
51
|
+
Refactors often have strict ordering:
|
|
52
|
+
```
|
|
53
|
+
Create new class → Move methods → Update callers → Remove old code
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Ensure dependencies are respected in delegation.
|
|
57
|
+
|
|
58
|
+
## Review Phase
|
|
59
|
+
|
|
60
|
+
```
|
|
61
|
+
/review ~/.claude/workflow-state/<feature>.state.json
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Refactor Review Criteria
|
|
65
|
+
|
|
66
|
+
When type is "refactor", apply additional scrutiny:
|
|
67
|
+
|
|
68
|
+
| Criterion | Description |
|
|
69
|
+
|-----------|-------------|
|
|
70
|
+
| Behavior preserved | Same inputs produce same outputs |
|
|
71
|
+
| No regressions | Existing functionality works |
|
|
72
|
+
| Goals achieved | Brief goals are met |
|
|
73
|
+
| Performance OK | No degradation |
|
|
74
|
+
|
|
75
|
+
See `overhaul-review.md` for detailed criteria.
|
|
76
|
+
|
|
77
|
+
## State Updates
|
|
78
|
+
|
|
79
|
+
**After delegation complete:**
|
|
80
|
+
|
|
81
|
+
```
|
|
82
|
+
action: "set", featureId: "refactor-<slug>", phase: "review"
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
**After review passes:**
|
|
86
|
+
|
|
87
|
+
```
|
|
88
|
+
action: "set", featureId: "refactor-<slug>", phase: "update-docs"
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
**After review fails (dispatch fix tasks, loop back):**
|
|
92
|
+
|
|
93
|
+
```
|
|
94
|
+
action: "set", featureId: "refactor-<slug>", updates: {
|
|
95
|
+
"reviews.<id>.status": "failed",
|
|
96
|
+
"reviews.<id>.findings": ["<issue1>"]
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Auto-Chain Behavior
|
|
101
|
+
|
|
102
|
+
No human checkpoints in this chain. Automatic progression:
|
|
103
|
+
|
|
104
|
+
| From | To | Condition |
|
|
105
|
+
|------|-----|-----------|
|
|
106
|
+
| delegate | review | All tasks complete |
|
|
107
|
+
| review | update-docs | Review passes |
|
|
108
|
+
| review | delegate --fixes | Review fails (loop) |
|
|
109
|
+
|
|
110
|
+
## Transition to Review
|
|
111
|
+
|
|
112
|
+
After all tasks complete, auto-continue to review:
|
|
113
|
+
|
|
114
|
+
1. Update state: `.phase = "review"`
|
|
115
|
+
2. Output: "All tasks complete. Auto-continuing to review..."
|
|
116
|
+
3. Invoke immediately:
|
|
117
|
+
```typescript
|
|
118
|
+
Skill({ skill: "exarchos:review", args: "~/.claude/workflow-state/<feature>.state.json" })
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
This is NOT a human checkpoint - workflow continues autonomously.
|
|
122
|
+
|
|
123
|
+
## Exit Conditions
|
|
124
|
+
|
|
125
|
+
**Success Path:**
|
|
126
|
+
- All tasks delegated and completed
|
|
127
|
+
- Review passes
|
|
128
|
+
- Ready for update-docs phase
|
|
129
|
+
|
|
130
|
+
**Failure Path:**
|
|
131
|
+
- Review failures documented
|
|
132
|
+
- Fix tasks dispatched via `--fixes`:
|
|
133
|
+
```typescript
|
|
134
|
+
Skill({ skill: "exarchos:delegate", args: "--fixes ~/.claude/workflow-state/<feature>.state.json" })
|
|
135
|
+
```
|
|
136
|
+
- Loop until review passes
|
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
# Overhaul Track: Plan Phase
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
Create detailed implementation plans for large refactors with emphasis on incremental, working-state changes. This phase integrates with the existing `/exarchos:plan` skill while adding refactor-specific constraints that ensure safety and reversibility.
|
|
6
|
+
|
|
7
|
+
**Key principle:** Every task leaves the codebase in a working state. No task should break tests or functionality.
|
|
8
|
+
|
|
9
|
+
## Entry Conditions
|
|
10
|
+
|
|
11
|
+
- Track is `overhaul`
|
|
12
|
+
- Brief phase complete with scope assessment
|
|
13
|
+
- State file has `.track = "overhaul"` and `.phase = "brief"` complete
|
|
14
|
+
- Refactoring goals documented in brief
|
|
15
|
+
|
|
16
|
+
## Integration with /exarchos:plan
|
|
17
|
+
|
|
18
|
+
The overhaul track leverages the existing `/exarchos:plan` skill with additional refactor context.
|
|
19
|
+
|
|
20
|
+
### Invocation
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
# Auto-invocation from brief phase
|
|
24
|
+
Skill({ skill: "exarchos:plan", args: "--refactor ~/.claude/workflow-state/<feature>.state.json" })
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Context Passing
|
|
28
|
+
|
|
29
|
+
The `/exarchos:plan` skill receives refactor context from the brief:
|
|
30
|
+
|
|
31
|
+
1. **Scope boundaries** - Which files/modules are affected
|
|
32
|
+
2. **Refactoring goals** - What improvements are targeted
|
|
33
|
+
3. **Constraints** - Working state requirements, rollback needs
|
|
34
|
+
4. **Test baseline** - Current test status to maintain
|
|
35
|
+
|
|
36
|
+
### Plan Modifications
|
|
37
|
+
|
|
38
|
+
When `/exarchos:plan` receives refactor context, it applies these additional rules:
|
|
39
|
+
|
|
40
|
+
| Standard Plan | Refactor Plan |
|
|
41
|
+
|---------------|---------------|
|
|
42
|
+
| Tasks can be feature-incomplete | Each task must leave code functional |
|
|
43
|
+
| Tests verify new behavior | Tests verify existing + new behavior |
|
|
44
|
+
| Dependencies between tasks | Explicit rollback points identified |
|
|
45
|
+
| Parallel execution focus | Sequential safety emphasis |
|
|
46
|
+
|
|
47
|
+
## Refactor-Specific Emphasis
|
|
48
|
+
|
|
49
|
+
### 1. Incremental Changes (Working State Guarantee)
|
|
50
|
+
|
|
51
|
+
**Every task MUST leave code in a working state.**
|
|
52
|
+
|
|
53
|
+
Requirements per task:
|
|
54
|
+
- [ ] Code compiles after task completion
|
|
55
|
+
- [ ] All existing tests pass
|
|
56
|
+
- [ ] New tests (if added) pass
|
|
57
|
+
- [ ] No temporary broken states
|
|
58
|
+
|
|
59
|
+
Anti-patterns to avoid:
|
|
60
|
+
- "Part 1 of 3" tasks that break until Part 3
|
|
61
|
+
- Renaming without updating all references
|
|
62
|
+
- Interface changes without adapter layers
|
|
63
|
+
- Deleting before replacing
|
|
64
|
+
|
|
65
|
+
**Incremental Strategy Examples:**
|
|
66
|
+
|
|
67
|
+
| Refactor Type | Safe Approach |
|
|
68
|
+
|---------------|---------------|
|
|
69
|
+
| Rename | Add alias -> Update references -> Remove old |
|
|
70
|
+
| Extract | Create new -> Duplicate logic -> Redirect calls -> Delete original |
|
|
71
|
+
| Replace | Add new alongside -> Toggle between -> Verify -> Remove old |
|
|
72
|
+
| Restructure | Scaffold new -> Copy behavior -> Redirect -> Clean up |
|
|
73
|
+
|
|
74
|
+
### 2. Rollback Points
|
|
75
|
+
|
|
76
|
+
Identify explicit points where the refactor can be safely paused or abandoned.
|
|
77
|
+
|
|
78
|
+
**Rollback Point Criteria:**
|
|
79
|
+
- All tests pass
|
|
80
|
+
- No temporary code remains
|
|
81
|
+
- Could ship to production if needed
|
|
82
|
+
- Clear documentation of state
|
|
83
|
+
|
|
84
|
+
**Template:**
|
|
85
|
+
|
|
86
|
+
```markdown
|
|
87
|
+
## Rollback Points
|
|
88
|
+
|
|
89
|
+
### After Task 003
|
|
90
|
+
**State:** Old API deprecated, new API available
|
|
91
|
+
**Can ship:** Yes
|
|
92
|
+
**To resume:** Continue with Task 004
|
|
93
|
+
**To abandon:** Remove deprecation warnings, new API becomes optional
|
|
94
|
+
|
|
95
|
+
### After Task 007
|
|
96
|
+
**State:** Migration complete, old code marked for deletion
|
|
97
|
+
**Can ship:** Yes
|
|
98
|
+
**To resume:** Continue with Task 008 (cleanup)
|
|
99
|
+
**To abandon:** Keep both implementations, document tech debt
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### 3. Test Strategy Per Task
|
|
103
|
+
|
|
104
|
+
Each task specifies verification requirements:
|
|
105
|
+
|
|
106
|
+
```markdown
|
|
107
|
+
### Task 005: Extract validation logic to shared module
|
|
108
|
+
|
|
109
|
+
**Test Requirements:**
|
|
110
|
+
1. **Existing tests:** All unit tests in `auth.test.ts` must pass unchanged
|
|
111
|
+
2. **New tests:** Add `validation.test.ts` with same coverage
|
|
112
|
+
3. **Integration:** Run `npm run test:integration` to verify no regressions
|
|
113
|
+
4. **Manual verification:** N/A (pure refactor)
|
|
114
|
+
|
|
115
|
+
**Verification Command:**
|
|
116
|
+
npm run test:run -- --coverage
|
|
117
|
+
# Coverage must not decrease
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### 4. Working State Guarantee
|
|
121
|
+
|
|
122
|
+
After every task completion, verify:
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
# Compilation check
|
|
126
|
+
npm run build
|
|
127
|
+
|
|
128
|
+
# Unit tests
|
|
129
|
+
npm run test:run
|
|
130
|
+
|
|
131
|
+
# Integration tests (if applicable)
|
|
132
|
+
npm run test:integration
|
|
133
|
+
|
|
134
|
+
# Lint (code quality)
|
|
135
|
+
npm run lint
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
**State tracking in workflow file:**
|
|
139
|
+
|
|
140
|
+
```json
|
|
141
|
+
{
|
|
142
|
+
"tasks": [
|
|
143
|
+
{
|
|
144
|
+
"id": "001",
|
|
145
|
+
"title": "Add new interface",
|
|
146
|
+
"status": "complete",
|
|
147
|
+
"working_state_verified": true,
|
|
148
|
+
"test_results": {
|
|
149
|
+
"passed": 145,
|
|
150
|
+
"failed": 0,
|
|
151
|
+
"coverage": "87%"
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
]
|
|
155
|
+
}
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## Plan Structure Template
|
|
159
|
+
|
|
160
|
+
Save to: `docs/plans/YYYY-MM-DD-<refactor-name>.md`
|
|
161
|
+
|
|
162
|
+
```markdown
|
|
163
|
+
# Implementation Plan: [Refactor Name]
|
|
164
|
+
|
|
165
|
+
## Source
|
|
166
|
+
- **Brief:** `~/.claude/workflow-state/<feature>.state.json`
|
|
167
|
+
- **Track:** Overhaul
|
|
168
|
+
- **Affected scope:** [Files/modules from brief]
|
|
169
|
+
|
|
170
|
+
## Goals Mapping
|
|
171
|
+
|
|
172
|
+
| Brief Goal | Task ID(s) | Verification |
|
|
173
|
+
|------------|------------|--------------|
|
|
174
|
+
| [Goal 1] | 001, 002 | [How verified] |
|
|
175
|
+
| [Goal 2] | 003-005 | [How verified] |
|
|
176
|
+
| [Goal 3] | 006 | [How verified] |
|
|
177
|
+
|
|
178
|
+
## Working State Strategy
|
|
179
|
+
|
|
180
|
+
**Approach:** [Describe overall incremental approach]
|
|
181
|
+
|
|
182
|
+
**Key constraints:**
|
|
183
|
+
- [Constraint 1 from brief]
|
|
184
|
+
- [Constraint 2 from brief]
|
|
185
|
+
|
|
186
|
+
## Task Breakdown
|
|
187
|
+
|
|
188
|
+
### Task 001: [Title]
|
|
189
|
+
|
|
190
|
+
**Phase:** [RED | GREEN | REFACTOR]
|
|
191
|
+
|
|
192
|
+
**TDD Steps:**
|
|
193
|
+
1. [RED] Write test: `TestName_Scenario_ExpectedOutcome`
|
|
194
|
+
- File: `path/to/test.ts`
|
|
195
|
+
- Expected failure: [Reason]
|
|
196
|
+
- Run: `npm run test:run` - MUST FAIL
|
|
197
|
+
|
|
198
|
+
2. [GREEN] Implement minimum code
|
|
199
|
+
- File: `path/to/implementation.ts`
|
|
200
|
+
- Changes: [Description]
|
|
201
|
+
- Run: `npm run test:run` - MUST PASS
|
|
202
|
+
|
|
203
|
+
3. [REFACTOR] Clean up (if needed)
|
|
204
|
+
- Apply: [Improvement]
|
|
205
|
+
- Run: `npm run test:run` - MUST STAY GREEN
|
|
206
|
+
|
|
207
|
+
**Working State Check:**
|
|
208
|
+
- [ ] Code compiles
|
|
209
|
+
- [ ] All tests pass (existing + new)
|
|
210
|
+
- [ ] No temporary hacks remain
|
|
211
|
+
|
|
212
|
+
**Rollback point:** [Yes/No - if Yes, document in Rollback section]
|
|
213
|
+
|
|
214
|
+
**Dependencies:** [Task IDs or "None"]
|
|
215
|
+
|
|
216
|
+
---
|
|
217
|
+
|
|
218
|
+
[Repeat for each task]
|
|
219
|
+
|
|
220
|
+
## Rollback Points
|
|
221
|
+
|
|
222
|
+
### After Task [N]
|
|
223
|
+
**State:** [Description of codebase state]
|
|
224
|
+
**Can ship:** [Yes/No]
|
|
225
|
+
**To resume:** [Instructions]
|
|
226
|
+
**To abandon:** [Cleanup instructions]
|
|
227
|
+
|
|
228
|
+
## Verification Checklist
|
|
229
|
+
|
|
230
|
+
After all tasks complete:
|
|
231
|
+
- [ ] All original tests still pass
|
|
232
|
+
- [ ] New tests added for new code
|
|
233
|
+
- [ ] Code coverage maintained or improved
|
|
234
|
+
- [ ] No TODO/FIXME comments left behind
|
|
235
|
+
- [ ] Brief goals all achieved
|
|
236
|
+
- [ ] Ready for review
|
|
237
|
+
|
|
238
|
+
## Deferred Items
|
|
239
|
+
|
|
240
|
+
[Any scope items explicitly deferred, with rationale]
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
## State Updates
|
|
244
|
+
|
|
245
|
+
### On Plan Completion
|
|
246
|
+
|
|
247
|
+
**Save plan artifact and tasks:**
|
|
248
|
+
|
|
249
|
+
```
|
|
250
|
+
action: "set", featureId: "refactor-<slug>", updates: {
|
|
251
|
+
"artifacts.plan": "docs/plans/YYYY-MM-DD-<refactor>.md",
|
|
252
|
+
"tasks": [
|
|
253
|
+
{"id": "001", "title": "Task description", "status": "pending", "working_state_verified": false},
|
|
254
|
+
{"id": "002", "title": "Task 2 description", "status": "pending", "working_state_verified": false}
|
|
255
|
+
]
|
|
256
|
+
}
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
**Advance to delegate:**
|
|
260
|
+
|
|
261
|
+
```
|
|
262
|
+
action: "set", featureId: "refactor-<slug>", phase: "delegate"
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
### Task State Structure
|
|
266
|
+
|
|
267
|
+
```json
|
|
268
|
+
{
|
|
269
|
+
"id": "001",
|
|
270
|
+
"title": "Extract validation to shared module",
|
|
271
|
+
"status": "pending",
|
|
272
|
+
"working_state_verified": false,
|
|
273
|
+
"rollback_point": true,
|
|
274
|
+
"dependencies": [],
|
|
275
|
+
"branch": "refactor/001-extract-validation"
|
|
276
|
+
}
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
## Exit Conditions
|
|
280
|
+
|
|
281
|
+
Transition to `delegate` phase when:
|
|
282
|
+
|
|
283
|
+
- [ ] Plan document created at `docs/plans/`
|
|
284
|
+
- [ ] All brief goals mapped to tasks
|
|
285
|
+
- [ ] Every task has working state verification criteria
|
|
286
|
+
- [ ] Rollback points identified (minimum 1)
|
|
287
|
+
- [ ] Test strategy defined per task
|
|
288
|
+
- [ ] State file updated with plan path and tasks
|
|
289
|
+
- [ ] Phase set to `delegate`
|
|
290
|
+
|
|
291
|
+
## Transition to Delegate
|
|
292
|
+
|
|
293
|
+
After plan completion, auto-continue to delegate:
|
|
294
|
+
|
|
295
|
+
1. Update state with plan path and tasks (see State Updates above)
|
|
296
|
+
2. Output: "Refactor plan created with [N] tasks and [M] rollback points. Auto-continuing to delegation..."
|
|
297
|
+
3. Invoke immediately:
|
|
298
|
+
```typescript
|
|
299
|
+
Skill({ skill: "exarchos:delegate", args: "~/.claude/workflow-state/<feature>.state.json" })
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
This is NOT a human checkpoint - workflow continues autonomously.
|
|
303
|
+
|
|
304
|
+
## Anti-Patterns
|
|
305
|
+
|
|
306
|
+
| Avoid | Instead |
|
|
307
|
+
|-------|---------|
|
|
308
|
+
| Big-bang refactors | Break into working-state increments |
|
|
309
|
+
| Skipping tests | Each task verifies existing + new |
|
|
310
|
+
| Hidden dependencies | Explicit rollback points |
|
|
311
|
+
| "Will fix later" tasks | Every task self-contained |
|
|
312
|
+
| Assuming tests pass | Verify after each task |
|