blob: 09f01fafc6318833a47649e8ad7b3a6d63ae2235 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
---
name: refactoring
description: "Explicitly preserve behavior while improving structure; identify unnecessary abstraction and avoid scope creep."
---
# Refactoring Skill
Explicitly preserve behavior while improving structure; identify unnecessary abstraction and avoid scope creep.
## Subagents
When you need to delegate sub‑tasks, use the `pi-subagents` skill.
**Example:** When refactoring a legacy module, use a **scout** to identify all call sites of the `legacy::utils` functions, another **scout** to map the test coverage for each, and an **implementer** to inline or replace them incrementally while a **reviewer** ensures behavior is preserved.
*You may adapt the delegation pattern to fit the exact requirements of the codebase.*
## Principles
### Preserve Behavior
- Run tests before and after
- Make incremental changes
- Verify at each step
### Improve Structure
- Reduce duplication
- Clarify intent
- Improve modularity
### Avoid Scope Creep
- One refactoring at a time
- No new features
- No style-only changes in same commit
### Identify Unnecessary Abstraction
- Remove unused interfaces
- Inline single-use functions
- Flatten deep hierarchies
### Run tools
- Use refactoring tools like formatters/linters when available
|