Agent and skills for code simplification and refactoring to improve code quality while preserving functionality.
Version: 1.5.5
claude plugin install refactor@frad-dotclaudeProvides specialized tools for code simplification and refactoring. Includes an expert code simplifier agent and skills for targeted and project-wide refactoring. All refactoring operations preserve functionality while improving clarity, consistency, and maintainability.
refactor/
├── .claude-plugin/
│ └── plugin.json # Plugin manifest
├── agents/
│ └── code-simplifier.md # Expert refactoring agent
├── skills/
│ ├── best-practices/ # Knowledge skill (internal)
│ │ ├── SKILL.md
│ │ └── references/ # 110 reference files
│ │ ├── typescript.md
│ │ ├── python.md (+ python/ subdir)
│ │ ├── go.md
│ │ ├── swift.md
│ │ ├── universal.md
│ │ └── react/rules/ # 57 Next.js/React patterns
│ ├── refactor/ # Instruction skill (user-invocable)
│ │ └── SKILL.md
│ └── refactor-project/ # Instruction skill (user-invocable)
│ └── SKILL.md
└── README.md
Expert code simplification specialist that enhances code clarity, consistency, and maintainability while preserving functionality. Automatically loads refactor:best-practices skill for language-specific standards.
Usage:
@code-simplifier Simplify the authentication logic in src/auth/login.ts
For details, see agents/code-simplifier.md.
Provides language-specific best practices, code quality standards, and framework detection for refactoring workflows. Automatically loaded by code-simplifier agent.
Language Support: TypeScript, Python, Go, Swift, JavaScript Framework Support: React (57 performance patterns), Next.js
For details, see skills/best-practices/SKILL.md.
Quick refactoring for recently modified or specified code.
Usage:
# Refactor recently modified code
/refactor
# Refactor specific files
/refactor src/auth/login.ts src/utils/Launches code-simplifier agent with targeted scope. For details, see skills/refactor/SKILL.md.
Project-wide code refactoring across entire codebase.
Usage:
/refactor-projectLaunches code-simplifier agent with project-wide scope, emphasizing cross-file duplication reduction and consistent patterns. For details, see skills/refactor-project/SKILL.md.
# Refactor recent changes
/refactor
# Refactor specific files
/refactor src/auth/login.ts/refactor-project@code-simplifier Simplify the authentication logic in src/auth/login.ts
Before:
function processUser(user: any) {
if (user) {
if (user.age) {
if (user.age >= 18) {
if (user.verified) {
return { status: 'active', user: user };
} else {
return { status: 'unverified', user: user };
}
} else {
return { status: 'minor', user: user };
}
}
}
return { status: 'invalid', user: null };
}After:
interface User {
age: number;
verified: boolean;
}
function processUser(user: User | null): { status: string; user: User | null } {
// Early returns for guard clauses
if (!user?.age) {
return { status: 'invalid', user: null };
}
if (user.age < 18) {
return { status: 'minor', user };
}
const status = user.verified ? 'active' : 'unverified';
return { status, user };
}Improvements:
- Eliminated nested conditionals with guard clauses
- Added proper TypeScript types
- Reduced cognitive complexity
- Made logic flow more obvious and testable
Demonstrates parallelizing independent async operations to eliminate sequential waterfalls. See skills/best-practices/references/react/rules/async-parallel.md for detailed examples.
Demonstrates eliminating code duplication using Enums and type hints. See skills/best-practices/references/python.md for comprehensive patterns.
- Language Support: TypeScript, JavaScript, Python, Go, Swift
- Framework Support: Next.js (57 performance patterns), React
- Automated Workflow: Agent-driven refactoring with best practices
- Safe Refactoring: Preserves functionality, uses git for rollback
- Impact-Based: Prioritizes CRITICAL > HIGH > MEDIUM > LOW improvements
- Refactor frequently during development
- Use
/refactorfor targeted improvements - Use
/refactor-projectfor major modernization - Review changes to ensure functionality is preserved
- Run tests after refactoring to validate
- Trust git for rollback if needed
- Git repository for change tracking
- Test suite for validation (recommended)
- Lint/build tools for quality checks (recommended)
Q: Will refactoring break my code? A: No. The agent preserves functionality. Always run tests after refactoring.
Q: Refactoring changes too much
A: Use /refactor with specific files for targeted changes. Review changes before committing.
Q: What's the difference between /refactor and /refactor-project?
A: /refactor is for targeted changes (recent/specified files). /refactor-project is for entire codebase.
For more FAQs and detailed troubleshooting, see individual skill documentation in skills/.
Frad LEE (fradser@gmail.com)
React/Next.js Best Practices:
- React and Next.js performance optimization guidelines are sourced from Vercel Engineering's agent-skills repository
- Contains 40+ rules across 8 categories, prioritized by impact
- Originally created by @shuding at Vercel