
Refactor
Refactor code to improve structure and maintainability
Install
npx skills add vstorm-co/pydantic-deepagents --skill refactor -g -a claude-code -y- Repository
- vstorm-co/pydantic-deepagents1.1k
- Category
- Engineering
- Updated
- 5d ago
- License
- MIT
- Context cost
- Lightabout 248 tokens
- Runs scripts
- No, instructions only
What it does
Refactor code to improve structure and maintainability
Refactor
Improve code structure without changing external behavior.
Process
- Understand, Read all related code, run existing tests
- Plan, Identify what to change and why
- Execute, Make changes incrementally
- Verify, Run tests after each change
Common Refactoring Patterns
Extract
- Long function → smaller focused functions
- Repeated code → shared helper
- Magic numbers → named constants
Simplify
- Deep nesting → early returns / guard clauses
- Complex conditionals → descriptive functions
- Large classes → smaller focused classes
Rename
- Unclear names → descriptive names
- Inconsistent naming → consistent conventions
Reorganize
- Related functions scattered → grouped in modules
- Circular dependencies → dependency inversion
Rules
- Never change behavior, tests must pass before and after
- One refactoring type per commit
- If tests don't exist, write them first
- Don't refactor and add features in the same change
