/refactor
Refactor code to improve structure and maintainability
$ npx -y skills add vstorm-co/pydantic-deepagents --skill refactor --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
- Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
- You can call itInvoke it directly when you want it.
- Slash command
/refactor
Context preview
The summary Claude sees to decide when to auto-load this skill.
Refactor code to improve structure and maintainability
SKILL.md
refactor.SKILL.mdname: refactor description: "Refactor code to improve structure and maintainability" tags: [code-quality, refactoring] version: "1.0.0"
Refactor
Improve code structure without changing external behavior.
Process
1. **Understand** — Read all related code, run existing tests 2. **Plan** — Identify what to change and why 3. **Execute** — Make changes incrementally 4. **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
Open-source, self-hosted Claude Code - a terminal AI assistant and the Python framework behind it. Tool-calling, sandboxed execution, multi-agent teams, skills, checkpoints, unlimited context - on Pydantic AI, any model.
Repo: vstorm-co/pydantic-deepagents
Other skills on pydantic-deepagents.
- /build-and-compile
Building, compiling, and resolving dependency issues across languages
Open skill - /code-review
Systematic code review for bugs, security, style, and performance
Open skill - /data-formats
Working with diverse data formats: binary, text, structured, and custom
Open skill - /environment-discovery
Systematic exploration of unknown environments before starting work
Open skill - /git-workflow
Git operations: commits, branches, PRs, and conflict resolution
Open skill - /performant-code
Writing efficient code that handles large data and tight constraints
Open skill

