Refactor without breaking behavior (C++)
Characterization tests, small mechanical steps, and clean-cut commits keeping refactors boring.
Track: 🧰 Engineering Essentials · Domain: Code Quality · Level: intermediate · ~35 min
Who this is for: All Software Engineers
When to Use This Skill
Characterization tests, small mechanical steps, and clean-cut commits keeping refactors boring. Use it whenever a matching task appears in conversation — the agent loads these instructions on demand.
Steps
- Pin current behavior with characterization tests where gaps exist
- Plan steps each leaving tests green; commit per step
- Prefer mechanical moves (extract, inline, rename) over clever rewrites
- Keep behavior changes in separate PRs from structure moves
- Measure complexity delta honestly; stop when readability peaks
- Leave the campsite cleaner but don't rebuild the forest
- Sanitizer builds (ASan/UBSan) in CI before perf tuning
- Profile with perf/VTune; watch cache lines and allocations
Common Pitfalls
- Big-bang rewrites losing hidden behaviors
- 'While I'm here' feature creep inside refactor PRs
Commands
Install with skills CLI
npx skills add aniruddhaadak80/skills --skill code-quality-refactor-safely-cpp
Install globally
npx skills add aniruddhaadak80/skills --skill code-quality-refactor-safely-cpp -g
Part of aniruddhaadak80/skills · Browse all at https://skills.sh/aniruddhaadak80/skills