| name | refactor |
| description | Refactor code to improve readability, reduce duplication, and align with conventions — no behavior change |
| version | 2.0.0 |
| compat | claude-code, codex, cursor, openclaw |
Skill: refactor
What it does
Refactors existing code to improve readability, reduce duplication, and align with project conventions, without changing behavior.
When to use it
- After a pr-review with code observations
- When there's obvious duplication between Server Actions or components
- Before extending a feature that has technical debt
Process
- Read
.knowledge/conventions.md to understand project patterns
- Identify: duplication, long functions, unclear names, dead imports
- Refactor in atomic commits — one change per commit
- Never change observable behavior — if something could change, ask first
- Run
tsc --noEmit before and after to confirm no type regressions
Patterns to apply
- Extract repeated logic to helpers in
/lib/utils/
- Split components > 150 lines into sub-components
- Unify error handling in Server Actions
- Replace
any with explicit types
Expected output
Atomic commits with message refactor: <concise description of the change>
Warnings
- Don't refactor and add features in the same commit
- If the refactor requires test changes, update them in the same commit
- Don't change public export names without reviewing all imports first