safe-refactor · git:20261118.549ccf7 · 2026-11-18 · sha256 3910b933c512ca16
safe-refactor git:20261118.549ccf7A
Immutable. This exact content never changes and is served at /api/v1/blob/3910b933c512ca16.
No tool to install first
claude plugin marketplace add https://markdownregistry.com/mp/a/art_kn65rxkm3bezeyhh/3910b933c512ca16f2798e238ba6cc495b6765c0a398a6e5613594f1d3f2f27d.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 consolidating shared UI/helpers without changing external behavior. --- # Safe Refactor Restructure internal code and eliminate duplication while preserving 100% of observable external behavior at every step. ## Decision tree 1. **Are you trying to change observable behavior and restructure code in the same step?** - **Yes** → Separate into two passes/commits: land the behavior-preserving refactor first, then apply the behavioral change. - **No** → Proceed to step 2. 2. **Do passing automated tests cover the public seam of the code being refactored?** - **No** → Write characterization tests at the public seam and confirm they pass before changing internals. - **Yes** → Proceed to workflow below. ## Workflow 1. **Baseline & Caller Check**: - Search all callers of target symbols (`rg -n` via `run_command` or search tool). - Run the typechecker and test suite via `run_command` to verify a green baseline. 2. **Atomic Transformations**: - Extract duplicated UI/helpers/validators into existing shared modules. - Collapse shallow pass-through wrappers and replace boolean flag clusters with discriminated unions. 3. **Bracketed Verification**: - Run typecheck and tests immediately after each transformation. If a step breaks and cannot be fixed cleanly, revert only your own edit (via `edit_file` or `git stash push -- <file>`, never `git checkout -- .`) and take a smaller step.