From ct
Analyzes code smells like long functions and nesting, prioritizes high-impact refactorings, presents findings, then applies one transformation per cycle after user approval without changing behavior.
npx claudepluginhub pvillega/claude-templates --plugin ctThis skill uses the workspace's default tool permissions.
**Read [guide.md](guide.md) before starting.** Contains the refactoring catalog, examples, and techniques.
Applies disciplined refactoring in small, verifiable steps to improve code structure without changing behavior: extract functions, rename, move code.
Refactors code structure for better readability and maintainability without changing behavior. Applies patterns like extract/inline/rename functions, eliminates duplication, addresses code smells like long functions and deep nesting.
Guides safe, incremental refactoring to improve code quality without changing behavior. Generates analysis/plans via refactor:analyze/plan commands, covers smells and patterns like Extract Method.
Share bugs, ideas, or general feedback.
Read guide.md before starting. Contains the refactoring catalog, examples, and techniques.
digraph refactoring {
"Analyze code" -> "Prioritize (80/20)";
"Prioritize (80/20)" -> "Present HIGH/MED/LOW findings";
"Present HIGH/MED/LOW findings" -> "STOP. End your response. Wait for user approval." [style=bold];
"STOP. End your response. Wait for user approval." -> "Pick ONE transformation" [label="user approves"];
"Pick ONE transformation" -> "Apply it";
"Apply it" -> "Verify (tests/types)";
"Verify (tests/types)" -> "Commit";
"Commit" -> "STOP. End your response. Ask what's next." [style=bold];
"STOP. End your response. Ask what's next." -> "Pick ONE transformation" [label="user says continue"];
"STOP. End your response. Ask what's next." -> "Done" [label="user says stop"];
}
HARD STOP: End your response after presenting the analysis. Do NOT continue to Phase 2 in the same message. Do NOT show code changes, proposed extractions, or "here's what I would do" previews. The user must explicitly approve before you touch any code.
Only enter Phase 2 after the user has responded with approval.
HARD STOP: End your response after each transformation. Ask the user if they want to continue, adjust direction, or stop. Do NOT batch multiple transformations in one response.
"Ugly" is not sufficient reason if the code is stable, tested, and rarely touched.
| Smell | Transformation | guide.md |
|---|---|---|
| Long function (>50 lines) | Extract Method | Yes |
| Duplicated code | Extract Method, Unify | Yes |
| Deep nesting (>3 levels) | Guard Clauses | Yes |
| Unclear name | Rename | Yes |
| Complex expression | Extract Variable | Yes |
| Code in wrong file | Move Function | Yes |
| Loop does too much | Split Loop | Yes |
| Thought | Correct Response |
|---|---|
| "I'll extract all 6 methods at once" | ONE transformation, verify, commit, then next |
| "I'll refactor while adding this feature" | Separate. Refactor first OR feature first. Never both |
| "This is ugly, I should clean it up" | Does it change often? Causing bugs? If no, push back |
| "Let me plan all steps upfront" | Plan only the next step. Observe after each |
| "I'll show what I would do so they can approve" | That IS doing it. Present analysis, STOP, wait |
| "I'll present all cycles for review" | One cycle per response. User controls the pace |
| "Tests are slow, I'll batch verifications" | Verify after EVERY transformation |
| "I'll just do a quick rename too" | Second transformation. Commit the first one first |
| "User said refactor so I should refactor everything" | 80/20. Stop at diminishing returns |