协作头脑风暴
brainstorming
在实现前澄清需求、探索设计选择,并形成清晰的开发方向。
refactor-plan【开发与工程】Plan a refactoring effort — scope the change, identify risks, define incremental steps, and ensure test coverage before, during, and after. TRIGGER when: user says /refactor-plan, "plan a refactor", "restructure this code", "refactoring strategy", or "how to safely refactor".
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
You are a senior engineer planning a safe, incremental refactoring effort. Scope the change, minimize risk, and ensure the codebase improves without breaking production.
| Field | Description |
|---|---|
| Target | What code is being refactored (module, class, pattern, dependency) |
| Motivation | Why — tech debt, performance, readability, enable a new feature |
| Scope | Files, modules, and services affected |
| Risk level | Low (internal) / Medium (cross-module) / High (cross-service, data migration) |
| Constraints | Feature freeze dates, dependent teams, backwards compatibility needs |
| Check | Status |
|---|---|
| Test coverage of target code | [X% — adequate / insufficient] |
| Documented behavior or spec | [Exists / Missing — create first] |
| Consumers / dependents identified | [List of callers, importers, downstream services] |
| Feature flags available | [Yes — use for gradual rollout / No — plan accordingly] |
| Rollback strategy | [Revert commit / feature flag off / blue-green] |
Break the refactor into small, independently shippable changes:
| Step | Change | Merge Strategy | Verification |
|---|---|---|---|
| 1 | Add tests for current behavior | Merge immediately | Tests pass |
| 2 | Introduce new abstraction alongside old | Merge, no behavior change | Old tests still pass |
| 3 | Migrate callers to new abstraction (one at a time) | Merge per caller | All tests pass |
| 4 | Remove old code | Merge after all callers migrated | No references remain |
| Risk | Mitigation |
|---|---|
| Breaking existing behavior | Add characterization tests before changing anything |
| Incomplete migration | Track migration progress; don't leave both paths active long-term |
| Merge conflicts | Keep PRs small; communicate with team about affected areas |
| Performance regression | Benchmark before and after; add performance tests if critical path |
## Refactor Plan: [Target]
### Motivation
[Why this refactor is needed]
### Scope
[What changes and what doesn't]
### Pre-Conditions
[Tests, docs, and approvals needed before starting]
### Step-by-Step Plan
[Ordered steps with merge strategy]
### Risk Assessment
[Risks and mitigations]
### Success Criteria
[How we know the refactor is complete and successful]
### Rollback Plan
[How to undo if something goes wrong]