```
Refactors code by removing legacy patterns, unused exports, and simplifying complex logic across specified files.
/plugin marketplace add fradser/dotclaude/plugin install refactor@frad-dotclauderefactor/references/Task tool parameters:
subagent_type: "refactor:code-simplifier"
description: "Refactor code with aggressive cleanup"
prompt: <detailed context below>
Pass the following information to the agent:
Refactor the following files with aggressive cleanup enabled:
Target Scope: <list of file paths>
Scope Determination: <one of: "explicit paths", "semantic search: <query>", "session context">
Aggressive Mode: Remove legacy code, unused exports, backwards-compatibility hacks, and rename improperly named variables.
<if semantic search>
Semantic Query: "<original query>"
Search Results: <number> files matched
</if>
<if session context>
Recent Changes: <number> files modified in git working tree
</if>
Path-based:
Target Scope:
- src/auth/login.ts
- src/auth/session.ts
Scope Determination: explicit paths
Aggressive Mode: Remove legacy code, unused exports, backwards-compatibility hacks, and rename improperly named variables.
Semantic search:
Target Scope:
- src/services/user-validator.ts
- src/lib/validation-utils.ts
- src/middleware/auth-check.ts
Scope Determination: semantic search: "user validation logic"
Semantic Query: "user validation logic"
Search Results: 3 files matched
Aggressive Mode: Remove legacy code, unused exports, backwards-compatibility hacks, and rename improperly named variables.
Session context:
Target Scope:
- src/components/Button.tsx
- src/styles/theme.ts
Scope Determination: session context
Recent Changes: 2 files modified in git working tree
Aggressive Mode: Remove legacy code, unused exports, backwards-compatibility hacks, and rename improperly named variables.
The code-simplifier agent executes the following workflow autonomously:
Load refactor:best-practices skill using Skill tool
This provides:
For each file in target scope:
Aggressive Mode Changes:
_unusedVar, re-exports of deleted code)Behavior-Preserving Changes:
npm test auth.test.ts)Track all changes by category for summary report (see output-requirements.md).
The agent's skills manifest includes refactor:best-practices, so it loads automatically on launch.
Next.js Detection:
import { useRouter } from 'next/router'
import Image from 'next/image'
React Detection:
import React from 'react'
import { useState } from 'react'
Agent applies only rules relevant to detected frameworks:
Based on detection, agent loads:
references/typescript.mdreferences/python.md + references/python/INDEX.mdreferences/react/ directory with rule indexreferences/universal.mdmodel: opus # High reasoning for complex refactoring decisions
Opus provides superior:
allowed-tools:
- Read # Read target files
- Edit # Apply refactoring changes
- Glob # Discover related files
- Grep # Search for patterns
- Bash(git:*) # Git status, diff for context
- Skill # Load best-practices
No Write tool: Agent uses Edit for surgical changes, not full rewrites.
Restricted Bash: Only git commands allowed for safety.