Safe Refactor
When refactoring, rewriting, or migrating critical code paths, orchestrate a safe cycle: assess risks → implement → verify → document. Chains pre-mortem and prove-it with built-in implementation phase. Prevents "refactor broke production" disasters. Activates on "refactor", "rewrite", "migrate", or "clean up" for non-trivial code.
Install
npx skills add ElliotJLT/Claude-Skill-Potions --skill safe-refactorgit clone --depth 1 https://github.com/ElliotJLT/Claude-Skill-Potions.git /tmp/Claude-Skill-Potions
mkdir -p ~/.claude/skills
cp -r /tmp/Claude-Skill-Potions/skills/safe-refactor ~/.claude/skills/safe-refactorPersonal skills live in ~/.claude/skills. Use .claude/skills in a project folder to share a skill with your team.
From the SKILL.md
# Safe Refactor
<purpose>
An elixir for risky code changes. Refactors feel safe ("I'm just cleaning up")
but they're where bugs hide. This chains risk assessment → careful implementation
→ verification → documentation. The ceremony slows you down just enough to
catch problems before production does.
</purpose>
## Prerequisites
This elixir works best with these skills installed:
| Skill | Purpose | If Missing |
|-------|---------|------------|
| pre-mortem | Risk assessment before starting | Falls back to built-in checklist |
| prove-it | Verification enforcement | Falls back to built-in verification |
| retrospective | Document learnings | Skipped (optional phase) |
## When To Activate
<triggers>
- "Refactor this"
- "Clean up this code"
- "Rewrite this to be more..."
- "Migrate from X to Y"
- "Replace this implementation"
- Large-scale find-and-replace
- Changing shared utilities or core abstractions
- Touching code you didn't write
</triggers>
## Instructions
### Phase 1: Assess Risk
<phase_risk>
**If pre-mortem skill installed:** Invoke it now.
**If not installed, evaluate:**Details
- Skill name
safe-refactor- Repository
- ElliotJLT/Claude-Skill-Potions
- Path
skills/safe-refactor/SKILL.md- License
- MIT
- Repo updated
- 12 February 2026
FAQ
What does the Safe Refactor skill do?
When refactoring, rewriting, or migrating critical code paths, orchestrate a safe cycle: assess risks → implement → verify → document. Chains pre-mortem and prove-it with built-in implementation phase. Prevents "refactor broke production" disasters. Activates on "refactor", "rewrite", "migrate", or "clean up" for non-trivial code.
How do I install the Safe Refactor skill?
skills CLI (Claude Code, Cursor, Codex and more): npx skills add ElliotJLT/Claude-Skill-Potions --skill safe-refactor. Skills go in ~/.claude/skills (personal) or .claude/skills (project), and Claude loads them automatically when a task matches the description.
Is Safe Refactor popular?
It lives in ElliotJLT/Claude-Skill-Potions, which has 62 GitHub stars and 2 forks.
Related skills
Agent Audit
62ElliotJLT/Claude-Skill-Potions
When reviewing, optimizing, or inheriting an LLM agent, systematically identify what's actually load-bearing vs. cruft. Instruments usage, ablates components, and strips the agent to minimum viable form. Answers: "What can we remove without degrading quality?" The goal is the leanest agent that still works.
Battle Plan
62ElliotJLT/Claude-Skill-Potions
Before ANY significant development task (new feature, refactor, integration, migration), run a complete planning ritual by orchestrating other skills in sequence: rubber-duck (clarify scope) -> pre-mortem (assess risks) -> eta (estimate time) -> final confirmation. Do not start coding until the battle plan is approved.
Breadcrumbs
62ElliotJLT/Claude-Skill-Potions
Leaves notes for future Claude sessions in .claude/breadcrumbs.md. At session end or after significant work, records what was tried, what worked, what failed, and context for next time. On session start, reads breadcrumbs to understand history. Session-to-session memory without manual updates.
Sams Architecture
38sam-dumont/claude-skills
Automatically triggered when designing system architecture, planning new projects, creating implementation plans, conducting architecture reviews, or auditing existing codebases for consistency. Applies when discussing: system design, technology choices, architectural patterns, infrastructure decisions, API design, testing strategies, CI/CD pipelines, security architecture, or code organization. Works for Python web APIs, infrastructure/DevOps, Garmin/embedded systems, and frontend projects. Distinguishes between personal projects (strict standards) and client work (adaptive approach).
Requesting Code Review
43obra/clank
Dispatch code-reviewer subagent to review implementation against plan or requirements before proceeding
Simplifying Control Flow
43obra/clank
Flatten nested conditionals with early returns or table-driven methods - keep nesting depth under 3 levels
Browse the most popular Claude skills, all software development skills, or write your own with the skills generator.