safe-refactor · git:20261028.6945601 · 2026-10-28 · sha256 981a5ccd9e9048dd
safe-refactor git:20261028.6945601A
Immutable. This exact content never changes and is served at /api/v1/blob/981a5ccd9e9048dd.
No tool to install first
claude plugin marketplace add https://markdownregistry.com/mp/a/art_kn65rxkm3bezeyhh/981a5ccd9e9048dd51bb2361021fc3cf776e805f8f5b49623a99ce0907459bda.json
Then /plugin install safe-refactor@markdownregistry-kn65rxkm3bezeyhh in Claude Code. It installs this exact version, the one graded A here, pinned to the commit it was graded at, and leaves it there.
--- name: safe-refactor description: Restructures code in atomic behavior-preserving steps verified by characterization and regression tests. Use when refactoring code, eliminating duplication, or deepening shallow modules without changing external behavior. --- # Safe Refactor Restructure internal code while preserving 100% of observable external behavior at every step. ## Decision tree 1. **Are you trying to change observable business behavior and restructure code in the same step?** - **Yes** → Separate into two commits: complete the pure behavior-preserving refactor first, then implement the behavioral change. - **No** → Proceed to step 2. 2. **Do passing automated tests already cover the public seam of the code being refactored?** - **No** → Write **Characterization Tests** at the public seam first and confirm they pass before modifying internals. - **Yes** → Proceed to step 3. ## Refactoring workflow 1. **Baseline & caller check**: - Run `grep_search` to map every caller of the target symbol across the workspace. - Run the typechecker and test suite via `run_command` to confirm a green baseline. 2. **Apply one atomic transformation at a time**: - Inline shallow pass-through wrappers or middle-man delegates. - Extract duplicated logic into a single pure helper. - Replace boolean flag clusters with a discriminated union. - Move methods exhibiting Feature Envy onto the module that owns the data. 3. **Bracketed verification**: - Run typecheck and tests immediately after each transformation. If verification fails and cannot be fixed within 30 seconds, revert (`git checkout -- <file>`) and take a smaller step.