expert-code-refactoring
Installation
SKILL.md
Refactoring Skill
This skill guides the agent in refactoring codebases by identifying technical debt and applying industry-standard patterns tailored to the specific technology stack.
General Refactoring Workflow
- Analyze Context: Read the file and its associated tests. Identify dependencies and usage patterns.
- Verify Tests: Before any changes, run existing tests to ensure a stable baseline.
- Identify Smells: Look for long methods, deep nesting, duplicate code, or tight coupling.
- Incremental Changes: Apply transformations in small, verifiable steps.
- Re-verify: Run tests after each significant change.
Architecture & Clean Code (Global)
- Naming: Rename variables, functions, and classes to be descriptive and reveal intent. Avoid abbreviations.
- AHA Programming: Avoid Hasty Abstractions. Only abstract code when the duplication is clear and the abstraction doesn't make the code harder to follow.
- Functions: Keep functions small. Aim for a low number of parameters (prefer objects/records for many parameters).
- Cognitive Load: Reduce nesting levels (aim for max 2-3 deep). Use early returns to keep the "happy path" aligned to the left.