waterfall-refactor
Identify refactoring opportunities in code that a feature will touch. Runs at strategic level during design (looking for structural moves that could change which approach is chosen) or tactical level before implementation (looking for pre-work that gives the feature a better foundation). Primarily invoked by waterfall-design or waterfall-implement; avoid auto-triggering on casual mentions of "refactor".
- License 许可
- MIT
- 所属仓库
- lithammer/ai
- 最近更新
- 2026-11-13
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- waterfall-refactor
- description
- Identify refactoring opportunities in code that a feature will touch. Runs at strategic level during design (looking for structural moves that could change which approach is chosen) or tactical level before implementation (looking for pre-work that gives the feature a better foundation). Primarily invoked by waterfall-design or waterfall-implement; avoid auto-triggering on casual mentions of "refactor".
02 资源文件 1
- 参考文档agents/openai.yaml122 B
03 SKILL.md 正文
Refactor
Analyze the codebase for refactoring opportunities relevant to the feature being built. This is not a general cleanup pass — it focuses on code the feature touches and asks what changes would give it a better foundation.
The analysis adapts to when it runs. The caller provides a review level:
- Strategic: Run during design, before approaches are generated. Surface structural opportunities that could influence which approach to take.
- Tactical: Run before implementation, after the plan is approved. Surface pre-work and incorporated refactors that make the implementation cleaner.
Step 1: Determine scope
Extract from the conversation:
- The feature being built.
- Which areas of the codebase are involved.
- The review level (strategic or tactical).
If running at the strategic level, the scope is broader — look at the modules and services the feature touches, not just individual files. If tactical, focus on the specific files in the plan's manifest.
Step 2: Analyze
Read the affected code with the feature in mind. The question is not "what is wrong with this code?" but "will this code give the feature a good foundation?"
At the strategic level, be willing to consider larger structural moves. A refactor that turns the feature from complex to trivial is worth naming, even if the user ultimately decides not to take it.
At the tactical level, look for smaller moves: pre-work that keeps the implementation diff clean, or cleanups that fold naturally into the planned changes.
Step 3: Classify
For each opportunity:
-
Strategic level:
- Enables new approach: A refactor that opens up a design option that would otherwise be impractical. Note what approach it enables.
- Simplifies all approaches: A refactor that benefits the feature regardless of which approach is chosen.
- Unrelated: Not relevant to this feature. Do not include.
-
Tactical level:
- Pre-work: Do before implementation starts.
- Incorporate: Fold into the implementation alongside planned changes.
- Skip: Not relevant to the planned changes. Do not include.
At the tactical level, also assess two signals the implementation gate keys on, for each included opportunity:
- Magnitude: bounded — localized to a small area — or large — spread across many files, or structural.
- Shape: self-contained, or risky — it changes a contract other code depends on, regardless of diff size.
Report these as factual assessments; do not decide whether to proceed —
the orchestrator (waterfall-implement Step 2) owns the gate.
Step 4: Present
Return the opportunities with file paths, descriptions, and why each matters for the feature. At the strategic level, explicitly note how opportunities connect to potential approaches. At the tactical level, include each opportunity's magnitude and shape so the implementation gate can act on them.
04 同仓库更多 Skills
shape
Review a working change for its shape (cause, ownership, states, names, size, reuse, cost), then apply what you accept.
correctness
Review a working change for defects (logic, state, lifecycle, concurrency, regression) and for drift from its ticket, docs, and rules, then apply what you accept.
zero-tech-debt
Rework a change as if the intended UX and architecture existed from day one, deleting compatibility cruft and accidental complexity.
waterfall-review
Review a code change by dispatching specialized review subagents in parallel — each focused on a single dimension (correctness, security, architecture, etc.) — then triaging their findings into a unified report. Works standalone on a branch or as part of the waterfall flow after implementation. Invoke when the user explicitly asks to review a branch or diff, or as a step inside waterfall-implement; avoid auto-triggering on casual mentions of "review".
waterfall-plan
Detail a chosen design approach into an implementation plan (objective, file manifest, execution order, test strategy), then auto-proceed to waterfall-challenge. Convergent phase of the waterfall flow.
waterfall-implement
Implement a planned and challenged feature one increment at a time. Each increment is delegated to a subagent, then run through a review-fix loop until clean. Orchestrator stays in oversight.