Sub-Agent Refactor Command banner
derek-opdee derek-opdee

Sub-Agent Refactor Command

Development community intermediate

Description

A powerful refactoring orchestrator that uses multiple specialized sub-agents to analyze, plan, implement, and verify code improvements while maintaining functionality.

Installation

Terminal
claude install-skill https://github.com/derek-opdee/subagent-example-script

README

Sub-Agent Refactor Command

A powerful refactoring orchestrator that uses multiple specialized sub-agents to analyze, plan, implement, and verify code improvements while maintaining functionality.

Command Syntax

sub-agent-refactor [target] [options]

# Aliases
@refactor [target] [options]
@sar [target] [options]

Parameters

    undefined

Examples

Basic Refactoring

# Auto-detect and refactor a single file
sub-agent-refactor src/components/UserDashboard.tsx

# Refactor an entire directory
sub-agent-refactor src/services/

# Use glob pattern
sub-agent-refactor "src/**/*Service.ts"

Specific Refactoring Types

# Extract repeated code into shared utilities
sub-agent-refactor src/pages/ --type extract-method --create-shared

# Break down large React components
sub-agent-refactor src/components/Dashboard.tsx --type extract-component

# Reduce function complexity
sub-agent-refactor src/utils/calculations.ts --type reduce-complexity --max-function-size 20

# Consolidate duplicate utilities across project
sub-agent-refactor . --type consolidate-utils

Advanced Usage

# Interactive mode with custom test command
sub-agent-refactor src/ --interactive --test-command "npm run test:unit"

# Dry run to preview changes
sub-agent-refactor src/api/ --dry-run --type reduce-complexity

# Strict mode with specific constraints
sub-agent-refactor src/ --strict --max-file-size 200 --max-complexity 8

# Refactor Laravel controllers
sub-agent-refactor app/Http/Controllers/ --type extract-method --create-shared

Agent Orchestration

Stage 1: Analysis Agent

**Prompt:**

Analyze the codebase at [TARGET] for refactoring opportu