@nklisch/pi-agile-workflow 0.15.3
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/plugin.json +10 -0
- package/.codex-plugin/plugin.json +28 -0
- package/CHANGELOG.md +591 -0
- package/README.md +107 -0
- package/docs/ARCHITECTURE.md +716 -0
- package/docs/MIGRATION.md +419 -0
- package/docs/PRINCIPLES.md +464 -0
- package/docs/ROADMAP.md +95 -0
- package/docs/SPEC.md +855 -0
- package/docs/VISION.md +106 -0
- package/extensions/agile-workflow.test.ts +419 -0
- package/extensions/agile-workflow.ts +467 -0
- package/hooks/hooks.json +52 -0
- package/hooks/scripts/prompt-context.py +628 -0
- package/hooks/scripts/substrate-maintainer.py +359 -0
- package/hooks/scripts/test_prompt_context.py +757 -0
- package/package.json +30 -0
- package/scripts/install-work-view.sh +165 -0
- package/scripts/tests/agent-metadata.test.sh +75 -0
- package/scripts/tests/bump-version.test.sh +552 -0
- package/scripts/tests/channel-parity.test.sh +117 -0
- package/scripts/tests/convert-content-integrity.test.sh +246 -0
- package/scripts/tests/convert-install-routing.test.sh +159 -0
- package/scripts/tests/install-work-view.test.sh +411 -0
- package/scripts/tests/pi-package-metadata.test.sh +119 -0
- package/scripts/tests/work-board-shim.test.sh +239 -0
- package/scripts/tests/work-view-dist-version.test.sh +105 -0
- package/scripts/work-board.sh +64 -0
- package/scripts/work-view.sh +423 -0
- package/skills/autopilot/SKILL.md +330 -0
- package/skills/autopilot/agents/openai.yaml +6 -0
- package/skills/board/SKILL.md +62 -0
- package/skills/board/agents/openai.yaml +6 -0
- package/skills/bold-refactor/SKILL.md +244 -0
- package/skills/bold-refactor/agents/openai.yaml +6 -0
- package/skills/bug-scan/SKILL.md +378 -0
- package/skills/bug-scan/agents/openai.yaml +6 -0
- package/skills/bug-scan/references/async-promises.md +119 -0
- package/skills/bug-scan/references/concurrency-races.md +148 -0
- package/skills/bug-scan/references/data-layer.md +167 -0
- package/skills/bug-scan/references/error-handling.md +197 -0
- package/skills/bug-scan/references/gate-item-template.md +94 -0
- package/skills/bug-scan/references/language-footguns.md +219 -0
- package/skills/bug-scan/references/parked-item-template.md +103 -0
- package/skills/bug-scan/references/report-template.md +115 -0
- package/skills/bug-scan/references/resource-leaks.md +199 -0
- package/skills/bug-scan/references/state-closures.md +148 -0
- package/skills/bug-scan/references/time-numbers.md +158 -0
- package/skills/convert/SKILL.md +1463 -0
- package/skills/convert/agents/openai.yaml +6 -0
- package/skills/convert/references/legacy-overlap-migration.md +179 -0
- package/skills/deep-code-scan/SKILL.md +378 -0
- package/skills/deep-code-scan/agents/openai.yaml +6 -0
- package/skills/deep-code-scan/references/artifact-ledger.md +148 -0
- package/skills/deep-code-scan/references/consolidation.md +91 -0
- package/skills/deep-code-scan/references/decomposition.md +127 -0
- package/skills/deep-code-scan/references/item-templates.md +263 -0
- package/skills/deep-code-scan/references/lane-catalog.md +129 -0
- package/skills/deep-code-scan/references/review-gauntlet.md +108 -0
- package/skills/deep-code-scan/references/scanner-brief.md +152 -0
- package/skills/e2e-test-design/SKILL.md +517 -0
- package/skills/e2e-test-design/references/anti-tautology.md +261 -0
- package/skills/e2e-test-design/references/service-mocks.md +234 -0
- package/skills/e2e-test-design/references/test-taxonomy.md +211 -0
- package/skills/epic-design/SKILL.md +476 -0
- package/skills/epicize/SKILL.md +210 -0
- package/skills/epicize/agents/openai.yaml +6 -0
- package/skills/feature-design/SKILL.md +472 -0
- package/skills/fix/SKILL.md +173 -0
- package/skills/gate-cruft/SKILL.md +258 -0
- package/skills/gate-docs/SKILL.md +278 -0
- package/skills/gate-patterns/SKILL.md +389 -0
- package/skills/gate-refactor/SKILL.md +408 -0
- package/skills/gate-security/SKILL.md +275 -0
- package/skills/gate-tests/SKILL.md +367 -0
- package/skills/groom/SKILL.md +162 -0
- package/skills/groom/agents/openai.yaml +6 -0
- package/skills/ideate/SKILL.md +185 -0
- package/skills/ideate/agents/openai.yaml +6 -0
- package/skills/implement/SKILL.md +288 -0
- package/skills/implement-orchestrator/SKILL.md +604 -0
- package/skills/park/SKILL.md +111 -0
- package/skills/perf-design/SKILL.md +427 -0
- package/skills/perf-scout/SKILL.md +404 -0
- package/skills/perf-scout/agents/openai.yaml +6 -0
- package/skills/perf-scout/references/algorithmic-and-data-structures.md +126 -0
- package/skills/perf-scout/references/approximation-and-precomputation.md +136 -0
- package/skills/perf-scout/references/caching-and-memoization.md +123 -0
- package/skills/perf-scout/references/compiler-runtime-and-language.md +136 -0
- package/skills/perf-scout/references/database-and-storage-internals.md +144 -0
- package/skills/perf-scout/references/distributed-systems.md +150 -0
- package/skills/perf-scout/references/game-engine-and-realtime.md +136 -0
- package/skills/perf-scout/references/gpu-and-accelerators.md +130 -0
- package/skills/perf-scout/references/idea-ranking.md +75 -0
- package/skills/perf-scout/references/io-and-batching.md +135 -0
- package/skills/perf-scout/references/memory-and-data-locality.md +137 -0
- package/skills/perf-scout/references/parallelism-and-vectorization.md +126 -0
- package/skills/perf-scout/references/parked-item-template.md +117 -0
- package/skills/perf-scout/references/peer-review-pass.md +150 -0
- package/skills/perf-scout/references/report-template.md +148 -0
- package/skills/principles/SKILL.md +678 -0
- package/skills/principles/references/models.md +191 -0
- package/skills/principles/references/subagents.md +158 -0
- package/skills/prose-author/SKILL.md +185 -0
- package/skills/refactor-conventions-creator/SKILL.md +359 -0
- package/skills/refactor-conventions-creator/agents/openai.yaml +6 -0
- package/skills/refactor-conventions-creator/references/common-structures.md +91 -0
- package/skills/refactor-conventions-creator/references/common-styles.md +90 -0
- package/skills/refactor-design/SKILL.md +384 -0
- package/skills/release-deploy/SKILL.md +667 -0
- package/skills/release-deploy/agents/openai.yaml +6 -0
- package/skills/research/SKILL.md +166 -0
- package/skills/research/agents/openai.yaml +6 -0
- package/skills/review/SKILL.md +267 -0
- package/skills/review/references/deep-review.md +98 -0
- package/skills/review/references/review-lenses.md +68 -0
- package/skills/review/references/substrate-side-effects.md +161 -0
- package/skills/review/references/target-resolution.md +52 -0
- package/skills/scope/SKILL.md +486 -0
- package/work-view/Cargo.lock +486 -0
- package/work-view/Cargo.toml +9 -0
- package/work-view/crates/cli/.work-view-version +1 -0
- package/work-view/crates/cli/Cargo.toml +18 -0
- package/work-view/crates/cli/src/actionable.rs +500 -0
- package/work-view/crates/cli/src/args.rs +792 -0
- package/work-view/crates/cli/src/board/assets/board.css +855 -0
- package/work-view/crates/cli/src/board/assets/board.js +259 -0
- package/work-view/crates/cli/src/board/assets/card.js +139 -0
- package/work-view/crates/cli/src/board/assets/components.css +290 -0
- package/work-view/crates/cli/src/board/assets/dependency.js +1193 -0
- package/work-view/crates/cli/src/board/assets/detail.js +256 -0
- package/work-view/crates/cli/src/board/assets/filters.js +389 -0
- package/work-view/crates/cli/src/board/assets/index.html +77 -0
- package/work-view/crates/cli/src/board/assets/kanban.js +231 -0
- package/work-view/crates/cli/src/board/assets/markdown.js +260 -0
- package/work-view/crates/cli/src/board/assets/motion.css +131 -0
- package/work-view/crates/cli/src/board/assets/state.js +245 -0
- package/work-view/crates/cli/src/board/assets/table.js +304 -0
- package/work-view/crates/cli/src/board/assets/tokens.css +602 -0
- package/work-view/crates/cli/src/board/assets/views.js +41 -0
- package/work-view/crates/cli/src/board/assets.rs +162 -0
- package/work-view/crates/cli/src/board/feed.rs +204 -0
- package/work-view/crates/cli/src/board/mod.rs +246 -0
- package/work-view/crates/cli/src/board/open.rs +144 -0
- package/work-view/crates/cli/src/board/server.rs +407 -0
- package/work-view/crates/cli/src/main.rs +195 -0
- package/work-view/crates/cli/src/render.rs +354 -0
- package/work-view/crates/cli/src/scope.rs +157 -0
- package/work-view/crates/cli/src/stale.rs +581 -0
- package/work-view/crates/cli/tests/board-js/dependency-table.test.mjs +64 -0
- package/work-view/crates/cli/tests/board-js/expanded-browsing.test.mjs +79 -0
- package/work-view/crates/cli/tests/board-js/harness-smoke.test.mjs +11 -0
- package/work-view/crates/cli/tests/board-js/harness.mjs +437 -0
- package/work-view/crates/cli/tests/board-js/kanban-detail.test.mjs +75 -0
- package/work-view/crates/cli/tests/board-js/markdown-filter.test.mjs +60 -0
- package/work-view/crates/cli/tests/fixtures/golden/.work/CONVENTIONS.md +3 -0
- package/work-view/crates/cli/tests/fixtures/golden/.work/active/epics/epic-alpha.md +16 -0
- package/work-view/crates/cli/tests/fixtures/golden/.work/active/features/feat-a.md +16 -0
- package/work-view/crates/cli/tests/fixtures/golden/.work/active/features/feat-b.md +16 -0
- package/work-view/crates/cli/tests/fixtures/golden/.work/active/stories/story-alpha-1.md +16 -0
- package/work-view/crates/cli/tests/fixtures/golden/.work/active/stories/story-research-1.md +19 -0
- package/work-view/crates/cli/tests/fixtures/golden/.work/archive/feat-done.md +16 -0
- package/work-view/crates/cli/tests/fixtures/golden/.work/archive/feat-shipped.md +18 -0
- package/work-view/crates/cli/tests/fixtures/golden/.work/backlog/idea-backlog.md +7 -0
- package/work-view/crates/cli/tests/fixtures/golden/.work/releases/v1.0/v1.0.md +16 -0
- package/work-view/crates/cli/tests/fixtures/ready-drafting/.work/CONVENTIONS.md +6 -0
- package/work-view/crates/cli/tests/fixtures/ready-drafting/.work/active/features/feat-dep-done.md +17 -0
- package/work-view/crates/cli/tests/fixtures/ready-drafting/.work/active/features/feat-design-ready.md +17 -0
- package/work-view/crates/cli/tests/fixtures/ready-drafting/.work/active/features/feat-impl-ready.md +17 -0
- package/work-view/crates/cli/tests/fixtures/ready-drafting/.work/active/stories/story-review-ready.md +17 -0
- package/work-view/crates/cli/tests/fixtures/with-malformed/.work/CONVENTIONS.md +4 -0
- package/work-view/crates/cli/tests/fixtures/with-malformed/.work/active/epics/malformed-no-closing-fence.md +8 -0
- package/work-view/crates/cli/tests/fixtures/with-malformed/.work/active/features/good-item.md +16 -0
- package/work-view/crates/cli/tests/integration.rs +2833 -0
- package/work-view/crates/core/Cargo.toml +13 -0
- package/work-view/crates/core/src/error.rs +61 -0
- package/work-view/crates/core/src/filter.rs +804 -0
- package/work-view/crates/core/src/graph.rs +324 -0
- package/work-view/crates/core/src/index.rs +590 -0
- package/work-view/crates/core/src/lib.rs +54 -0
- package/work-view/crates/core/src/model.rs +202 -0
- package/work-view/crates/core/src/parse.rs +494 -0
- package/work-view/crates/core/tests/fixtures/golden/.work/CONVENTIONS.md +15 -0
- package/work-view/crates/core/tests/fixtures/golden/.work/active/epics/epic-core.md +16 -0
- package/work-view/crates/core/tests/fixtures/golden/.work/active/features/feat-parser.md +16 -0
- package/work-view/crates/core/tests/fixtures/golden/.work/active/features/feat-query.md +16 -0
- package/work-view/crates/core/tests/fixtures/golden/.work/active/stories/malformed-no-id.md +15 -0
- package/work-view/crates/core/tests/fixtures/golden/.work/active/stories/story-parse-unit.md +16 -0
- package/work-view/crates/core/tests/fixtures/golden/.work/active/stories/story-security-gate.md +16 -0
- package/work-view/crates/core/tests/fixtures/golden/.work/archive/feat-old.md +16 -0
- package/work-view/crates/core/tests/fixtures/golden/.work/archive/feat-parser.md +17 -0
- package/work-view/crates/core/tests/fixtures/golden/.work/backlog/idea-future-board.md +7 -0
- package/work-view/crates/core/tests/fixtures/golden/.work/releases/v1.0/v1.0.md +16 -0
- package/work-view/crates/core/tests/fixtures/precedence/.work/CONVENTIONS.md +10 -0
- package/work-view/crates/core/tests/fixtures/precedence/.work/archive/dup-item.md +18 -0
- package/work-view/crates/core/tests/fixtures/precedence/.work/releases/v2.0/dup-item.md +18 -0
- package/work-view/crates/core/tests/integration.rs +541 -0
- package/work-view/dist/.gitattributes +1 -0
- package/work-view/dist/README.md +42 -0
- package/work-view/dist/aarch64-apple-darwin/work-view +0 -0
- package/work-view/dist/aarch64-unknown-linux-musl/work-view +0 -0
- package/work-view/dist/x86_64-apple-darwin/work-view +0 -0
- package/work-view/dist/x86_64-unknown-linux-musl/work-view +0 -0
|
@@ -0,0 +1,384 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: refactor-design
|
|
3
|
+
description: >
|
|
4
|
+
ALWAYS invoke this skill when the user asks to scan for refactor opportunities, plan a refactor, or
|
|
5
|
+
design a [refactor]-tagged feature. Discovery mode scans code smells, separates pure refactors from
|
|
6
|
+
behavior changes, and emits substrate items. Per-feature mode plans an existing [refactor] feature
|
|
7
|
+
at stage:drafting, writes the plan into the feature body, spawns child stories with depends_on
|
|
8
|
+
chains, and advances drafting to implementing. Uses sensible built-in refactor heuristics by
|
|
9
|
+
default, and extends them with a project-specific refactor-conventions catalog when present.
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# Refactor-Design
|
|
13
|
+
|
|
14
|
+
You plan a refactor for a feature tagged `[refactor]` at `stage: drafting` in the
|
|
15
|
+
agile-workflow substrate. The plan lives in the feature item's body, structured as
|
|
16
|
+
discrete refactor steps with current/target states, risk assessments, and rollback
|
|
17
|
+
paths. Each step that warrants its own implementation pass becomes a child story.
|
|
18
|
+
|
|
19
|
+
A refactor preserves behavior. If you find yourself adding capability, that's not a
|
|
20
|
+
refactor — escalate via `/agile-workflow:scope` to add a feature without `[refactor]`
|
|
21
|
+
tag instead.
|
|
22
|
+
|
|
23
|
+
`refactor-design` has its own sensible defaults: code smells, missing
|
|
24
|
+
abstractions, established pattern drift, naming inconsistencies, and dead weight.
|
|
25
|
+
If `.agents/skills/refactor-conventions/` exists, treat it as an additional
|
|
26
|
+
project-specific lens. It extends the default scan; it never replaces it. If the
|
|
27
|
+
catalog is absent, proceed normally.
|
|
28
|
+
|
|
29
|
+
## Trigger
|
|
30
|
+
|
|
31
|
+
The agent picks this skill in two cases:
|
|
32
|
+
- A feature at `stage: drafting` with `tags: [refactor, ...]` is ready for design (per-feature mode)
|
|
33
|
+
- The user asks to find refactor candidates ("audit for cruft", "what should we clean up", "find refactor candidates") (discovery mode)
|
|
34
|
+
|
|
35
|
+
Common phrases:
|
|
36
|
+
- per-feature: "design the refactor of X", "plan the refactor for feature Y"
|
|
37
|
+
- discovery: "find refactor candidates", "scan for cruft", "what should we clean up here"
|
|
38
|
+
|
|
39
|
+
## Invocation modes
|
|
40
|
+
|
|
41
|
+
| Invocation | Behavior |
|
|
42
|
+
|---|---|
|
|
43
|
+
| `refactor-design` (no arg) / `--all` | **Discovery mode**: sweep the whole codebase for refactor candidates, emit items |
|
|
44
|
+
| `refactor-design <path>` | Discovery mode scoped to a path |
|
|
45
|
+
| `refactor-design <NL scope>` (e.g. "the auth module") | Discovery mode scoped by NL filter |
|
|
46
|
+
| `refactor-design <feature-id>` | **Per-feature mode**: design the refactor for an existing `[refactor]`-tagged feature at `stage: drafting` |
|
|
47
|
+
| `refactor-design --only-questions <id>` / `--only-questions --all` | Question-only alignment pass over `[refactor]`-tagged drafting features. Mirrors feature-design's `--only-questions` mode — surfaces ambiguities, captures answers under `## Design decisions`, does NOT design or advance stage. Requires interactive mode. |
|
|
48
|
+
|
|
49
|
+
Disambiguation: an arg is treated as a feature id only if
|
|
50
|
+
`.work/active/features/<arg>.md` exists and has `tags: [refactor]`. Otherwise
|
|
51
|
+
discovery mode against the arg as path or NL scope.
|
|
52
|
+
|
|
53
|
+
## Workflow — discovery mode
|
|
54
|
+
|
|
55
|
+
Use this path for `refactor-design`, `--all`, `<path>`, or `<NL scope>`. Goal:
|
|
56
|
+
scan the target, classify findings, emit items so the substrate can drain
|
|
57
|
+
them.
|
|
58
|
+
|
|
59
|
+
### Phase D1: Resolve scope
|
|
60
|
+
|
|
61
|
+
- no arg / `--all` → whole codebase
|
|
62
|
+
- `<path>` → that directory or file
|
|
63
|
+
- `<NL scope>` → interpret against the codebase structure; log the interpretation
|
|
64
|
+
|
|
65
|
+
### Phase D2: Ground yourself
|
|
66
|
+
|
|
67
|
+
Read `docs/VISION.md`, `docs/SPEC.md`, `docs/ARCHITECTURE.md`, `AGENTS.md` /
|
|
68
|
+
`CLAUDE.md`, `.agents/rules/*.md` (if present) — the project's force-loaded
|
|
69
|
+
agent rules (tag semantics, test integrity, review policy) — `.work/CONVENTIONS.md`,
|
|
70
|
+
and, if present, `.agents/skills/refactor-conventions/SKILL.md` plus relevant
|
|
71
|
+
referenced rule files. One pass — orient, don't memorize.
|
|
72
|
+
|
|
73
|
+
### Phase D3: Code-smell scan
|
|
74
|
+
|
|
75
|
+
Run a read-first scope-size probe. If the target is a small file set or one
|
|
76
|
+
obvious module, scan it directly across the Phase 3 lenses and skip sub-agents;
|
|
77
|
+
direct reading usually catches refactor shape better than broad summaries.
|
|
78
|
+
|
|
79
|
+
For medium or large targets, run the same sub-agent scan as Phase 3 of
|
|
80
|
+
per-feature mode (Code Smells, Missing Abstractions, Pattern Violations &
|
|
81
|
+
Naming Inconsistencies, Dead Weight, and optional Project Refactor Conventions)
|
|
82
|
+
but scoped to the target from Phase D1 instead of one feature's area. The
|
|
83
|
+
optional conventions scan only runs when `.agents/skills/refactor-conventions/`
|
|
84
|
+
exists. After direct or agent scan results, read 2-3 key files yourself to
|
|
85
|
+
verify.
|
|
86
|
+
|
|
87
|
+
### Phase D4: Classify each finding
|
|
88
|
+
|
|
89
|
+
Each finding is either:
|
|
90
|
+
|
|
91
|
+
- **Pure refactor** — behavior-preserving. Examples: extract helper to dedupe,
|
|
92
|
+
split god file, rename for clarity, dead code removal.
|
|
93
|
+
- **Behavior-changing** — adds capability, fixes a bug, alters semantics.
|
|
94
|
+
Examples: handling an unhandled error case discovered mid-scan, replacing a
|
|
95
|
+
silent failure with explicit reporting, splitting a function in a way that
|
|
96
|
+
changes call-site contracts.
|
|
97
|
+
|
|
98
|
+
If unclear, default to behavior-changing — feature-design will refine the
|
|
99
|
+
classification at its own pass.
|
|
100
|
+
|
|
101
|
+
### Phase D5: Decide item size per finding
|
|
102
|
+
|
|
103
|
+
| Finding shape | Item kind | Stage |
|
|
104
|
+
|---|---|---|
|
|
105
|
+
| Single-file, surgical, no design needed | story | `implementing` |
|
|
106
|
+
| Multi-file or needs a design pass | feature | `drafting` |
|
|
107
|
+
| Cohesive cluster of 3+ findings in one area | feature | `drafting` (group findings as child stories of one feature) |
|
|
108
|
+
|
|
109
|
+
For pure-refactor findings, tag `[refactor]`. For behavior-changing findings,
|
|
110
|
+
omit the `[refactor]` tag — let feature-design handle them.
|
|
111
|
+
|
|
112
|
+
### Phase D6: Emit items and commit
|
|
113
|
+
|
|
114
|
+
For each finding (or cluster), write the item file with brief + file:line
|
|
115
|
+
references + one-line rationale. Include the source lens when useful
|
|
116
|
+
(`code-smell`, `missing-abstraction`, `pattern-drift`, `dead-weight`, or
|
|
117
|
+
`refactor-convention:<rule>`). Set `gate_origin: refactor-design` for trace.
|
|
118
|
+
Cycle-check `depends_on` if any.
|
|
119
|
+
|
|
120
|
+
Commit per batch:
|
|
121
|
+
```bash
|
|
122
|
+
git add .work/active/stories/ .work/active/features/
|
|
123
|
+
git commit -m "refactor-design discovery: <N> findings (<M> pure-refactor, <K> behavior-changing)"
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Phase D7: Output
|
|
127
|
+
|
|
128
|
+
In conversation:
|
|
129
|
+
- **Scope**: how the target was interpreted
|
|
130
|
+
- **Findings**: count by classification (pure-refactor vs behavior-changing)
|
|
131
|
+
- **Items emitted**: counts by kind (story / feature) with new ids
|
|
132
|
+
- **Next**: `/agile-workflow:scope` (batch mode) to cluster further, or start
|
|
133
|
+
an autopilot goal to drain. Behavior-changing items will route to
|
|
134
|
+
feature-design when their stage advances.
|
|
135
|
+
|
|
136
|
+
## Workflow — `--only-questions` mode
|
|
137
|
+
|
|
138
|
+
Mirrors `feature-design`'s `--only-questions` mode, scoped to `[refactor]`-tagged
|
|
139
|
+
drafting features. Iterate over the target set:
|
|
140
|
+
|
|
141
|
+
1. Read the feature; skip if not `[refactor]`-tagged or not at `stage: drafting`
|
|
142
|
+
2. Light ground (foundation docs + AGENTS.md / CLAUDE.md)
|
|
143
|
+
3. Read-first map of the feature's area; use one exploratory sub-agent only if the
|
|
144
|
+
area is still unclear. Include `.agents/skills/refactor-conventions/` as
|
|
145
|
+
context when present.
|
|
146
|
+
4. Surface strategic ambiguities specific to the refactor (e.g., "preserve API
|
|
147
|
+
shape or break consumers?", "in-place or shadow-then-swap?", "rollback
|
|
148
|
+
strategy when atomic?"). Use structured question tool.
|
|
149
|
+
5. Capture answers under `## Design decisions` in the feature body
|
|
150
|
+
6. Do NOT design or advance stage — let the design family pick up later
|
|
151
|
+
7. Commit per feature: `refactor-design --only-questions: <id>`
|
|
152
|
+
|
|
153
|
+
Requires interactive mode; refuse to run under an active autopilot run or goal.
|
|
154
|
+
|
|
155
|
+
## Workflow — per-feature mode
|
|
156
|
+
|
|
157
|
+
### Phase 1: Read the feature item
|
|
158
|
+
|
|
159
|
+
Read `.work/active/features/<id>.md`. Confirm:
|
|
160
|
+
- `kind: feature`
|
|
161
|
+
- `stage: drafting`
|
|
162
|
+
- `tags` includes `refactor`
|
|
163
|
+
|
|
164
|
+
The brief should describe what's being refactored and why. Use it as input.
|
|
165
|
+
|
|
166
|
+
**Misroute check.** Apply the black-box test to the brief: would any observable
|
|
167
|
+
behavior change for a caller of the public surface as a result of this work?
|
|
168
|
+
Signals you're misrouted: the brief describes new capability, an API or
|
|
169
|
+
contract change, swapped semantics, "replacing X with Y" rather than
|
|
170
|
+
"restructuring X," or "major rework of X." If any of those apply, this item
|
|
171
|
+
was mistagged. Strip `refactor` from the item's `tags` frontmatter, append a
|
|
172
|
+
one-line note to the body ("Misrouted to refactor-design; brief describes
|
|
173
|
+
behavior change rather than pure restructuring — retagged for feature-design"),
|
|
174
|
+
commit (`refactor-design misroute: <id> retagged for feature-design`), and
|
|
175
|
+
return without advancing the stage. Autopilot will reroute on the next pass.
|
|
176
|
+
|
|
177
|
+
### Phase 2: Ground yourself
|
|
178
|
+
|
|
179
|
+
The principles skill auto-loads. Read:
|
|
180
|
+
- `docs/VISION.md`, `docs/SPEC.md`, `docs/ARCHITECTURE.md` (refactor must not
|
|
181
|
+
violate spec constraints)
|
|
182
|
+
- `AGENTS.md` / `CLAUDE.md`
|
|
183
|
+
- `.agents/rules/*.md` (if present) — the project's force-loaded agent rules
|
|
184
|
+
(tag semantics, test integrity, review policy)
|
|
185
|
+
- `.agents/skills/refactor-conventions/SKILL.md` and relevant referenced rule
|
|
186
|
+
files, if present. Treat these as project-specific extension lenses, not as
|
|
187
|
+
replacements for the defaults below.
|
|
188
|
+
- The parent epic if `parent` is set
|
|
189
|
+
- The code under refactor — read it thoroughly, don't refactor blind
|
|
190
|
+
|
|
191
|
+
### Phase 3: Code-smell scan
|
|
192
|
+
|
|
193
|
+
Run a read-first scope-size probe before spawning exploratory sub-agents. If the
|
|
194
|
+
refactor target is a bounded module or small file set, inspect it directly
|
|
195
|
+
across the lenses below and skip exploratory fanout. If one area is unclear, use one
|
|
196
|
+
focused exploratory sub-agent. Use parallel exploratory sub-agents only when the lenses need separate
|
|
197
|
+
attention across a medium/large target.
|
|
198
|
+
|
|
199
|
+
The first four scan axes are mandatory. Run them even when a project-specific
|
|
200
|
+
refactor-conventions catalog exists. The catalog adds a fifth scan axis; it
|
|
201
|
+
does not narrow or disable the default refactor judgment.
|
|
202
|
+
|
|
203
|
+
- Use the host's generic/general-purpose subagent prompted with the scanner
|
|
204
|
+
capsule from `../principles/references/subagents.md`: medium reasoning for
|
|
205
|
+
focused scans, high reasoning for normal refactor discovery, and strongest
|
|
206
|
+
reviewer reasoning only for large or architecture-heavy refactors.
|
|
207
|
+
- Agile-workflow does not ship a read-only Explore override, so use an existing
|
|
208
|
+
deployment-provided read-only role only if it is already available; otherwise
|
|
209
|
+
keep the host-local scan fallback.
|
|
210
|
+
|
|
211
|
+
1. **Code Smells** — "Find code that smells off in <area>. Look for: duplicated
|
|
212
|
+
logic across files; long files (>500 lines); deep nesting (>4 levels); god
|
|
213
|
+
functions (>100 lines doing multiple distinct things); god modules (>15
|
|
214
|
+
methods or multiple responsibilities); leaky abstractions (consumers reaching
|
|
215
|
+
past a module's public API). Report each with file:line and a one-line
|
|
216
|
+
explanation."
|
|
217
|
+
|
|
218
|
+
2. **Missing Abstractions** — "Find places where multiple modules implement
|
|
219
|
+
similar logic that could be extracted. Report each with file:line references
|
|
220
|
+
and which modules would benefit."
|
|
221
|
+
|
|
222
|
+
3. **Pattern Violations & Naming Inconsistencies** — "Read
|
|
223
|
+
`.agents/skills/patterns/*.md` and legacy `.claude/skills/patterns/*.md` if
|
|
224
|
+
they exist. Find code that deviates from established patterns. Report
|
|
225
|
+
naming inconsistencies — same concept named differently across modules. Report
|
|
226
|
+
each with file:line."
|
|
227
|
+
|
|
228
|
+
4. **Dead Weight** — "Find dead code: unused exports (cross-check against grep
|
|
229
|
+
for importers), commented-out blocks, TODO/FIXME where the work is clearly
|
|
230
|
+
already done, files with very few callers. Report each with file:line."
|
|
231
|
+
|
|
232
|
+
5. **Project Refactor Conventions** — Run only when
|
|
233
|
+
`.agents/skills/refactor-conventions/` exists. "Read
|
|
234
|
+
`.agents/skills/refactor-conventions/SKILL.md`, its referenced rule files,
|
|
235
|
+
and the `## Refactor Style Conventions` section in AGENTS.md if present.
|
|
236
|
+
Find high-confidence convention drift in <area>. Report only issues where a
|
|
237
|
+
behavior-preserving refactor has real value: less duplication, clearer
|
|
238
|
+
boundaries, easier scanning, lower coordination cost, or alignment with a
|
|
239
|
+
repeatedly-used project rule. Do not report churn-only violations. Include
|
|
240
|
+
the rule name, file:line, why it matters, and whether it is small/surgical
|
|
241
|
+
or multi-file."
|
|
242
|
+
|
|
243
|
+
After direct or agent scan results, **read 2-3 key files yourself** to verify
|
|
244
|
+
findings.
|
|
245
|
+
|
|
246
|
+
### Phase 4: Categorize findings
|
|
247
|
+
|
|
248
|
+
Sort the findings into:
|
|
249
|
+
- **High value** — reduces duplication, extracts shared abstractions, consolidates
|
|
250
|
+
similar code, or corrects convention drift that materially improves module
|
|
251
|
+
boundaries or repeated project workflow
|
|
252
|
+
- **Medium value** — improves consistency, aligns with established patterns
|
|
253
|
+
- **Low value** — minor structural improvements
|
|
254
|
+
|
|
255
|
+
Each refactor step you plan must articulate the value. If you can't articulate the
|
|
256
|
+
payoff, drop the step.
|
|
257
|
+
|
|
258
|
+
Convention drift by itself is not automatically high value. Aesthetic-only or
|
|
259
|
+
mass-import-churn fixes should be dropped or recorded as "not worth it" in the
|
|
260
|
+
run summary.
|
|
261
|
+
|
|
262
|
+
### Phase 5: Design refactor steps
|
|
263
|
+
|
|
264
|
+
For each step, specify:
|
|
265
|
+
- **Step name and value tier** (High / Medium / Low)
|
|
266
|
+
- **Source lens**: code smell / missing abstraction / pattern drift /
|
|
267
|
+
dead weight / refactor convention `<rule>` (if applicable)
|
|
268
|
+
- **Files affected**: paths
|
|
269
|
+
- **Current state**: actual code showing what exists now
|
|
270
|
+
- **Target state**: exact code showing what it should look like after
|
|
271
|
+
- **Implementation notes**: how to get from current to target; non-obvious considerations
|
|
272
|
+
- **Acceptance criteria**: build passes, tests pass, plus specific structural/behavioral
|
|
273
|
+
check
|
|
274
|
+
- **Risk**: Low / Medium / High — what could go wrong
|
|
275
|
+
- **Rollback**: how to revert this step if it breaks something
|
|
276
|
+
|
|
277
|
+
**Step independence rule**: each step should be applicable, buildable, testable, and
|
|
278
|
+
committable in isolation. If a step bundles multiple unrelated refactors, split
|
|
279
|
+
them — when one breaks, you want to roll back only that change, not lose every
|
|
280
|
+
unrelated improvement bundled with it.
|
|
281
|
+
|
|
282
|
+
**Atomic-step acknowledgment**: some refactors are inherently atomic (renaming a public
|
|
283
|
+
API, schema migrations, contract changes). Acknowledge irreversibility explicitly and,
|
|
284
|
+
where possible, stage behind feature flags or migration scripts.
|
|
285
|
+
|
|
286
|
+
### Phase 6: Spawn child stories
|
|
287
|
+
|
|
288
|
+
Each significant refactor step that warrants its own implementation pass becomes a
|
|
289
|
+
child story:
|
|
290
|
+
- `.work/active/stories/<feature-id>-step-<N>.md`
|
|
291
|
+
- `kind: story`, `stage: implementing`, `parent: <feature-id>`,
|
|
292
|
+
`tags: [refactor]`, `depends_on: [...]` (chain in step order)
|
|
293
|
+
- Body: the step's current/target/notes/acceptance/risk/rollback content
|
|
294
|
+
|
|
295
|
+
Cycle check via `.work/bin/work-view --blocking` before writing any `depends_on`.
|
|
296
|
+
|
|
297
|
+
For trivial single-file refactors that fit in one inline pass, skip child stories.
|
|
298
|
+
|
|
299
|
+
### Phase 7: Write plan INTO feature body
|
|
300
|
+
|
|
301
|
+
Append to the feature file's body:
|
|
302
|
+
|
|
303
|
+
```markdown
|
|
304
|
+
## Refactor Overview
|
|
305
|
+
<key problems found, summary of proposed steps>
|
|
306
|
+
|
|
307
|
+
## Refactor Steps
|
|
308
|
+
|
|
309
|
+
### Step 1: <name>
|
|
310
|
+
**Priority**: High/Medium/Low
|
|
311
|
+
**Risk**: Low/Medium/High
|
|
312
|
+
**Source Lens**: code smell / missing abstraction / pattern drift / dead weight / refactor convention `<rule>`
|
|
313
|
+
**Files**: `src/path/file.ext`, ...
|
|
314
|
+
**Story**: `<story-id>` (if spawned)
|
|
315
|
+
|
|
316
|
+
**Current State**:
|
|
317
|
+
\`\`\`<lang>
|
|
318
|
+
// Actual code now
|
|
319
|
+
\`\`\`
|
|
320
|
+
|
|
321
|
+
**Target State**:
|
|
322
|
+
\`\`\`<lang>
|
|
323
|
+
// Exact code after
|
|
324
|
+
\`\`\`
|
|
325
|
+
|
|
326
|
+
**Implementation Notes**:
|
|
327
|
+
- <how to get from current to target>
|
|
328
|
+
|
|
329
|
+
**Acceptance Criteria**:
|
|
330
|
+
- [ ] Build passes
|
|
331
|
+
- [ ] Tests pass
|
|
332
|
+
- [ ] <specific structural/behavioral check>
|
|
333
|
+
|
|
334
|
+
**Rollback**: <how to revert if needed>
|
|
335
|
+
|
|
336
|
+
---
|
|
337
|
+
|
|
338
|
+
### Step 2: <name>
|
|
339
|
+
...
|
|
340
|
+
|
|
341
|
+
## Implementation Order
|
|
342
|
+
1. <step / story>
|
|
343
|
+
2. <step / story>
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
### Phase 8: Advance stage and commit
|
|
347
|
+
|
|
348
|
+
1. Update feature frontmatter: `stage: drafting → implementing`. PostToolUse hook
|
|
349
|
+
bumps `updated:`.
|
|
350
|
+
2. Commit:
|
|
351
|
+
```bash
|
|
352
|
+
git add .work/active/features/<id>.md .work/active/stories/<feature-id>-step-*.md
|
|
353
|
+
git commit -m "refactor-design: <feature-id> (<N> steps)"
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
## Output
|
|
357
|
+
|
|
358
|
+
In conversation:
|
|
359
|
+
- **Designed**: `<feature-id>` advanced to `stage: implementing`
|
|
360
|
+
- **Steps**: list with priority and risk
|
|
361
|
+
- **Convention-driven steps**: list or "none"
|
|
362
|
+
- **Child stories**: list with `depends_on` chain
|
|
363
|
+
- **Atomic steps acknowledged**: any that can't be cleanly rolled back
|
|
364
|
+
- **Next**: `/agile-workflow:implement <story-id>` for sequential, or
|
|
365
|
+
`/agile-workflow:implement-orchestrator <feature-id>` for parallel agents
|
|
366
|
+
|
|
367
|
+
## Guardrails
|
|
368
|
+
|
|
369
|
+
- A refactor preserves behavior. If a step would change behavior, that's a feature
|
|
370
|
+
add — escalate via `/agile-workflow:scope` instead.
|
|
371
|
+
- Each step is self-contained and committable in isolation. Multi-step PRs lose the
|
|
372
|
+
ability to roll back individual steps.
|
|
373
|
+
- Specify test verification for every step. A refactor without verification is a hope.
|
|
374
|
+
- Prioritize measurable improvements (less duplication, clearer boundaries) over
|
|
375
|
+
aesthetic preferences. Beauty that doesn't reduce complexity isn't worth the risk.
|
|
376
|
+
- Project-specific refactor conventions extend the defaults; they never replace
|
|
377
|
+
the built-in scan. If no convention catalog exists, proceed normally.
|
|
378
|
+
- Convention violations are not automatically work. Emit only behavior-preserving
|
|
379
|
+
refactors with meaningful payoff; record churn-only fixes as not worth it.
|
|
380
|
+
- If a refactor changes a public API, include a migration path. Breaking consumers
|
|
381
|
+
without a path forward creates more work than the refactor saves.
|
|
382
|
+
- Cycle prevention is mandatory for `depends_on`. Use `work-view --blocking`.
|
|
383
|
+
- The plan lives in the feature's body. NEVER create `docs/designs/refactor-<name>.md`
|
|
384
|
+
— that's a workflow-plugin pattern.
|