```
Refactors entire codebases by removing duplication and standardizing patterns across all files.
/plugin marketplace add fradser/dotclaude/plugin install refactor@frad-dotclauderefactor-project/references/Task tool parameters:
subagent_type: "refactor:code-simplifier"
description: "Refactor entire project with cross-file optimization"
prompt: <detailed context below>
Pass the following information to the agent:
Refactor the entire project with aggressive cleanup and cross-file optimization.
Project Scope: <total file count> files across <language count> languages
Target Files:
<organized list of files by directory or language>
Project-Wide Mode: Emphasize duplication reduction across files and consistent patterns project-wide.
Cross-File Optimization Focus:
- Identify and consolidate duplicate utilities across files
- Standardize naming conventions project-wide
- Ensure consistent error handling patterns
- Apply uniform code style and structure
Aggressive Mode: Remove legacy code, unused exports, backwards-compatibility hacks, and rename improperly named variables.
Frameworks Detected: <list of frameworks>
Refactor the entire project with aggressive cleanup and cross-file optimization.
Project Scope: 65 files across 2 languages
Target Files:
TypeScript (45 files):
src/components/: Button.tsx, Input.tsx, Modal.tsx, ...
src/services/: auth.ts, api.ts, user.ts, ...
src/utils/: validation.ts, formatting.ts, ...
tests/: auth.test.ts, user.test.ts, ...
Python (12 files):
scripts/: build.py, deploy.py, validate.py, ...
Project-Wide Mode: Emphasize duplication reduction across files and consistent patterns project-wide.
Cross-File Optimization Focus:
- Identify and consolidate duplicate utilities across files
- Standardize naming conventions project-wide
- Ensure consistent error handling patterns
- Apply uniform code style and structure
Aggressive Mode: Remove legacy code, unused exports, backwards-compatibility hacks, and rename improperly named variables.
Frameworks Detected: Next.js, React
The code-simplifier agent executes the following workflow for project-wide refactoring:
Load refactor:best-practices skill using Skill tool
Provides same references as file-level refactoring:
Two-Pass Analysis:
Pass 1: Individual File Analysis
Pass 2: Cross-File Pattern Detection
Individual File Improvements (same as file-level):
Cross-File Improvements (project-wide specific):
Duplication Consolidation:
// Before: Duplicate formatting in 3 files
// src/utils/auth.ts
const formatDate = (date) => { /* impl */ }
// src/utils/user.ts
const formatDate = (date) => { /* impl */ }
// After: Single shared utility
// src/utils/date.ts
export const formatDate = (date) => { /* impl */ }
// Updated imports in auth.ts and user.ts
import { formatDate } from './date'
Naming Standardization:
// Before: Inconsistent naming
// file1.ts: getUserInfo()
// file2.ts: fetchUserData()
// file3.ts: loadUserDetails()
// After: Consistent naming
// All files: getUserData()
Pattern Consistency:
// Before: Inconsistent error handling
// file1.ts: throw new Error()
// file2.ts: console.error() + return null
// file3.ts: try-catch with recovery
// After: Consistent approach based on context
// Services: throw errors (caller handles)
// UI: try-catch with user-friendly messages
Project-Wide Validation:
Incremental Review Suggestions:
Track changes across two dimensions:
See output-requirements.md for complete summary structure.
Project-wide refactoring uses the same best-practices skill as file-level refactoring.
Cross-File Context:
Example - Consistent Import Patterns:
// Before: Mixed import styles
// file1.ts: import React from 'react'
// file2.ts: import * as React from 'react'
// After: Standardized (based on project's tsconfig)
// All files: import React from 'react'
model: opus # Required for cross-file reasoning
Project-wide refactoring requires Opus for:
allowed-tools:
- Read # Read all target files
- Edit # Apply refactoring changes
- Glob # Discover files and patterns
- Grep # Search for patterns project-wide
- Bash(git:*) # Git status, diff for context
- Skill # Load best-practices
Same restrictions as file-level:
Batching Strategy:
Progress Indication: Agent should provide progress updates for large projects:
Analyzing files... (1/3 - TypeScript source)
Analyzing files... (2/3 - Python scripts)
Analyzing files... (3/3 - Test files)
Applying refactoring... (components)
Applying refactoring... (services)
...
Pre-Refactoring:
Post-Refactoring:
git reset --hard HEADInclude in summary:
### Rollback
If needed, revert all project-wide changes:
git reset --hard HEAD
Or create a backup first:
git branch backup-before-refactor
git reset --hard HEAD