loom-refactoring
SolidRestructures existing code to improve readability, maintainability, and performance without changing behavior.
Code & Development 54 stars
3 forks Updated today MIT
Install
Quality Score: 87/100
Stars 20%
Recency 20%
Frontmatter 20%
Documentation 15%
Issue Health 10%
License 10%
Description 5%
Skill Content
# Refactoring
## Overview
Change the internal structure of code without changing its observable behavior. Restructuring and behavior change are two different activities — never do both in one commit.
## The cardinal rule
**Behavior-preserving, tests green before AND after.** If you can't prove behavior is unchanged, you're not refactoring — you're rewriting, and you need different discipline (characterization tests, feature flags; see `/loom-code-migration`).
Corollaries an expert never violates:
1. **Tests are the safety net.** Run them before you touch anything (establish green). If there are none for the code you're changing, write **characterization tests** first (below) — do not refactor untested legacy blind.
2. **Tiny reversible steps.** One mechanical move at a time; re-run tests after each. When something breaks, inspect the small current diff and use the repository's approved recovery workflow rather than discarding unrelated work.
3. **Separate refactor commits from behavior-change commits.** A `refactor:` commit must be a no-op at runtime — reviewers can trust the diff without re-verifying logic. Mixing a bug fix into a rename hides the fix and poisons `git bisect`. (Commit mechanics: `/loom-git-workflow`.)
4. **Don't change tests and production code in the same step.** If a refactor "requires" editing a test's assertions, behavior changed — stop and reconsider.
## Not this skill
- Fixing a bug → `/loom-debugging` (that *is* a behavior change; write the fa...
Details
- Author
- cosmix
- Repository
- cosmix/loom
- Created
- 8 months ago
- Last Updated
- today
- Language
- Rust
- License
- MIT
Similar Skills
Semantically similar based on skill content — not just same category
Code & Development Listed
refactoring
Use for refactoring, behavior-preserving change, tests, safe rewrites.
1 Updated 1 weeks ago
kreek AI & Automation Listed
refactoring
Improve code structure in small, always-green steps without changing behavior. Use when asked to clean up, simplify, restructure, or de-duplicate working code.
7 Updated 5 days ago
Amey-Thakur Code & Development Listed
refactoring-patterns
Improve code structure without changing behavior — the discipline of small, named, test-backed moves. Extract function/variable, inline, rename, replace conditional with polymorphism, introduce parameter object, guard clauses. Recognize smells, refactor safely, avoid big-bang rewrites.
9 Updated 3 weeks ago
vanara-agents