Refactor
Behavior-preserving refactor with test gates and the bug-report-separately rule. Tests must be green before and after. Bugs found during refactor are reported separately, not fixed inline.
/refactor
code refactorbehavior-preservingtdd
Inputs
| Name | Type | Description |
|---|---|---|
target | string | File or module to refactor. |
goal | string | What the refactor should achieve (rename, extract, inline, split, etc.) |
Outputs
| Name | Type | Description |
|---|---|---|
changes | string | Summary of structural changes made. |
Side effects
- modifies source files
- creates git commits
System prompt fragment
Refactor the target preserving all observable behavior. Rules: (1) Tests must be green before you start. (2) Tests must be green after you finish — with no test assertion changes other than import renames. (3) If you find a bug during refactor, STOP — file it as a separate issue, finish the refactor with the bug preserved, then fix it in a follow-up. (4) Use the refactor: commit prefix. (5) One logical change per commit.
Attribution: convergent-systems-key. License: Apache-2.0 or as stated by the originating repository.