Agent skill
refactor
Refactor code across the codebase using parallel Snipper agents. Use when user wants to rename methods, update patterns, fix code smells, or apply consistent changes across multiple files.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/other/utils-refactor
SKILL.md
Refactor
Refactor code matching $ARGUMENTS across the codebase using parallel Snipper agents for maximum speed.
Process
Phase 1: Discovery
-
Parse the refactor request from
$ARGUMENTS- Identify: method name, component name, pattern, or code smell
- Choose search strategy: Grep for code patterns, Glob for file patterns
-
Find all affected files
- Use Grep/Glob to search the codebase
- Exclude: node_modules, .git, dist, build
- If >15 files found, ask user to confirm or narrow scope
Phase 2: Create Instructions
-
Create task folder:
.claude/tasks/refactor-{timestamp}/ -
Create ONE instruction file at
instructions.md:
# Refactor: {title}
## Objective
{What to refactor - derived from $ARGUMENTS}
## Pattern to Find
{Exact code pattern or structure to locate}
## Transformation
{How to transform - be specific and adaptive}
## Examples
Before:
{current code}
After:
{refactored code}
## Constraints
- Only modify code matching the pattern
- Preserve all existing functionality
- Follow codebase conventions
Phase 3: Execute in Parallel
-
Group files into batches of max 3 files each
-
Launch Snipper agents in parallel - ALL batches in a SINGLE message:
Using instructions in .claude/tasks/refactor-{id}/instructions.md, refactor:
- {file_1}
- {file_2}
- {file_3}
Read instructions first, then apply the refactor to each file.
Phase 4: Verification
-
Validate changes
- Run
pnpm lint(if available) - Run
pnpm tsc(if TypeScript)
- Run
-
Report summary
- Files modified
- Errors encountered
- Next steps if needed
Example
User: /refactor rename getUserData to fetchUserProfile
- Grep finds 12 files containing "getUserData"
- Creates
.claude/tasks/refactor-1702489200/instructions.md - Groups into 4 batches of 3 files
- Launches 4 Snipper agents in parallel
- Runs lint, reports: "Refactored 12 files"
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?