Individual skill
refactoring-safely
Change the structure of code that already exists without changing what it does: smells as triggers, the named transformations (extract/inline, move feature, organise data, simplify conditionals), and above all the workflow that makes it safe — characterization tests first, one transformation at a time, green between every step. Use when a file or function is already too large; when asked to "split this module", "extract this", "break up main.py", "clean up this legacy code", "reduce coupling here"; when asked to remove dead code, stale feature flags or finished experiments; when a shape advisory fires on a grown file; or before any restructuring of code that has users. Do NOT use to decide the target layout of a NEW project (use architecture-first), for unit-level naming and function quality in code you are writing fresh (use code-complexity), for capacity or storage decisions (use system-and-data-design), or to strip over-engineering on request (use lean-code). This is the transformation with a net; deciding WHERE things should end up is a different question, and doing both at once is how refactors lose behaviour.
skills/development/refactoring-safely/SKILL.md
Source commit 849719987d9c0d6ed973bdbce8ed37b266d3b1f3
What was checked
- Matches the observed repository HEAD
- Yes
- Scanner rules are current
- No
- Repository scan complete
- No
- Skill scan complete
- No
- Observed behavior
- Not checked yet
- Last checked
- Nov 7, 2026
These are observations at the recorded commit, not a guarantee of safety. Review the source before running it.
Install this skill
Choose an agent in your Stack or copy a command below. Commands fetch the pinned commit and copy only this skill directory. Existing destinations are refused. Copying a command does not install anything.
An install command is unavailable: current rules, complete repository and skill scans, an eligible behavior level and a permitted license are required.
Repository context
- Repository stars (not skill ratings)
- 214
- Repository last updated
- Nov 7, 2026
- License
- MIT
Observed agent integration: No specific integration evidence. Standard SKILL.md installation does not imply verified compatibility.
- ai-agents Repository topic
- claude Repository topic
- claude-code Repository topic
- llm Repository topic
- machine-learning Repository topic
- prompt-engineering Repository topic
- skills Repository topic
- mcp Repository topic
- agent-harness Repository topic
- harness Repository topic
- engineering Derived category
- design Derived category
- operations Derived category
- writing Derived category
- data Derived category
Files and excerpt
File metadata and permitted, redacted excerpts come from the recorded scan. Source links are pinned to that commit.
Browse files
SKILL.mdcore · 8,174 bytesSKILL.mdcore · 8,174 bytesreferences/dead-code-sweep.mddoc · 4,251 bytesreferences/refactoring-patterns-original.mddoc · 21,382 bytesreferences/refactoring-patterns/composing-methods.mddoc · 11,914 bytesreferences/refactoring-patterns/moving-features.mddoc · 12,272 bytesreferences/refactoring-patterns/organizing-data.mddoc · 12,987 bytesreferences/refactoring-patterns/refactoring-workflow.mddoc · 14,298 bytesreferences/refactoring-patterns/simplifying-conditionals.mddoc · 13,132 bytesreferences/refactoring-patterns/smell-catalog.mddoc · 13,510 bytes
Read excerpt
# Refactoring safely — changing shape without changing behaviour
Refactoring is a behaviour-preserving transformation. If behaviour changed, that was not
a refactor, it was a rewrite with optimistic branding — and the reason large restructures
fail is almost always that the two were done in one step.
## The rule that makes the rest work
**Never restructure and change behaviour in the same commit.** Alternate deliberately:
refactor (green → green, no behaviour change), then change behaviour (with a new test).
When both happen at once, a failing test cannot tell you which half broke it.
## Before touching anything: the net