refactor-guru
Use when the user asks to refactor code, clean up messy code, or diagnose code that feels hard to test, follow, or change.
Skill by guillevc
Chalk Labs
Need help deploying refactor-guru?
Chalk Labs sets up agents like this inside real teams: connected to your tools, tested on your data, with a human in the loop where it matters.
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/guillevc-refactor-guru
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: testing, writing
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/refactor-guru
What's inside
- Skill name
refactor-guru- Description
- Use when the user asks to refactor code, clean up messy code, or diagnose code that feels hard to test, follow, or change. Trigger on named or informal smells: god class, long method, feature envy, shotgun surgery, spaghetti code, tight coupling, "this is a mess," "this class does too much," "I keep changing 10 files," or "I can't write tests for this." Also use for structural goals such as making code pluggable, adding many variants or export formats, supporting undo, splitting modules for independent deployment, or improving code that works but is hard to explain, remember, or onboard new developers into.
- License
- MIT
- Instructions
- 397 lines in SKILL.md · view on GitHub
Files (4)
- SKILL.md
- patterns-catalog.md · references/
- refactoring-techniques.md · references/
- smells-catalog.md · references/
SKILL.md (first lines)
# Code Refactoring
Diagnose structural problems in code using three lenses: pain (what hurts now), intent (what
the code needs to become), and comprehension (what's hard to understand). Apply the smallest
change that solves the real problem. Language-agnostic.
## When to Use
- User shows code and asks "what's wrong with this?" or "how can I improve this?"
- User describes pain: brittle tests, cascading changes, files that grow endlessly
- User mentions smells by name or informal equivalents ("spaghetti code," "this does too much")
- User wants to apply a specific design pattern or refactoring technique
- User asks why code is hard to change, test, or understand
- User has a structural goal or upcoming need: "make this pluggable," "I need to add N more X,"
"we need to deploy these independently," "I want to support undo/redo"
- User struggles to understand code: "I can never remember how X works," "new devs take weeks,"
"the code works but I can't explain it," "what does this even do"
**Don't use when:** Code is a prototype/spike, about to be replaced, or the user just wants a feature added (refactor only if it enables the feature).
## Quick Reference — Most Common Smell → Fix
| Pain | Likely Smell | Primary Fix |
|------|-------------|-------------|
| Method is 200+ lines | Long Method | Extract Method |
| Class has 30+ fields | Large Class | Extract Class |
| Same 4 params everywhere | Data Clumps | Introduce Parameter Object |
| Huge switch/case keeps growing | Switch Statements | Replace Conditional with Polymorphism |
| Method uses another class's data more than its own | Feature Envy | Move Method |
| One change touches 10+ files | Shotgun Surgery | Move Method / Move Field (consolidate) |
| One class changes for unrelated reasons | Divergent Change | Extract Class (split by responsibility) |
| Two classes know too much about each other | Inappropriate Intimacy | Move Method + Hide Delegate |
| Copy-pasted code blocks | Duplicate Code | Extract Method / Extract Superclass |
| Getters/setters only, no behavior | Data Class | Move behavior into the data class |
## Quick Reference — Common Intent → Pattern
| Goal | Likely Pattern | Key Technique |
|------|---------------|---------------|
| Add N more variants (formats, providers, rules) | Strategy | Extract Interface + Extract Class per variant |
| Make pluggable/extensible | Strategy / Observer | Extract Interface + dependency injection |
| Support undo/redo | Command + Memento | Extract Method → Command objects |
| Deploy modules independently | Facade | Extract Class + boundary interface |
| React to changes elsewhere | Observer | Extract event interface |
| Handle object in multiple states | State | Replace Type Code with State/Strategy |
| Simplify complex subsystem access | Facade | Hide Delegate + Extract Class |
---
## Step 1: Understand the Context
Before diagnosing, establish:
1. **What code?** Read it carefully. Understand what it does.
2. **What's the driver?** Identify which lens is strongest — they're not mutually exclusive, and
requests often combine signals. Lead with the strongest one.
- **Pain**: Something hurts now — hard to change, test, read, keeps breaking
- **Intent**: Upcoming need — "I need to add X," "make this pluggable," "support Y"
- **Comprehension**: Hard to understand — "can't follow this," "new devs struggle," "can't explain it"
3. **What language?** Idiomatic solutions differ across languages.
4. **How mature?** Prototype vs production changes the threshold for action.
5. **Is now the right time?** Rule of Three: first time, just do it; second time, wince; third time, refactor. Best times: before adding a feature, when fixing a bug, during code review.
**Routing:**
- Pain / "what's wrong?" → **Step 2** (smell detection)
- Structural goal / upcoming need → **Step 2B** (structural gap analysis), optionally **Step 2** too
- Understanding struggle → **Step 2C** (domain alignment), optionally **Step 2** too
- Mixed signals → lead with the strongest driver, draw from other lenses as needed
- Problem described, no code → Ask to see the code first
- Asks about a specific pattern/technique → **Step 4** or **Step 5**
- Wants to refactor specific code → **Step 2**, move quickly to **Step 6**
- No clear signal → default to **Step 2** (smell detection)
---
## Step 2: Detect the Smell
Analyze the code against the five smell categories. Most code has multiple smells — focus on
the one causing the most pain, not every smell you can find.
### The Five Categories
Think of these as lenses to look through:
**Bloaters** — Things that have grown too large to manage
- Long Method, Large Class, Primitive Obsession, Long Parameter List, Data Clumps
**Object-Orientation Abusers** — OO principles applied incorrectly or incompletely
- Switch Statements, Temporary Field, Refused Bequest, Alternative Classes with Different Interfaces
**Change Preventers** — Code structures that make changes ripple everywhere
- Divergent Change (one class changes for many reasons), Shotgun Surgery (one change touches many classes), Parallel Inheritance Hierarchies
**Dispensables** — Things that could be removed to make code cleaner
- Duplicate Code, Lazy Class, Data Class, Dead Code, Speculative Generality, Comments (as deodorant)
**Couplers** — Excessive coupling between classes
- Feature Envy, Inappropriate Intimacy, Message Chains, Middle Man
For the full catalog with all smells, their symptoms, and mapped refactoring techniques,
read `references/smells-catalog.md`.
### How to Identify the Primary Smell
Start from the user's pain, not from a checklist:
- "I keep changing this file for unrelated reasons" → **Divergent Change**
- "Every small change requires editing 10+ files" → **Shotgun Surgery**
- "This method is 200 lines long" → **Long Method**
- "This class has 30 fields" → **Large Class**
- "I pass the same 4 parameters everywhere" → **Data Clumps** or **Long Parameter List**
- "There's a huge switch/case I keep extending" → **Switch Statements**
- "This method uses more of another class than its own" → **Feature Envy**
- "These two classes know too much about each other" → **Inappropriate Intimacy**
- "Half this subclass is overriding parent to do nothing" → **Refused Bequest**
- "I can't test this without mocking everything" → often **Feature Envy** or **Inappropriate Intimacy**
- "There's a lot of copy-pasted code" → **Duplicate Code**
- "This class is just getters and setters" → **Data Class**From guillevc/skills, MIT.
More from guillevc/skills
- 0.570score
audit-xcode-security-settings
guillevc
Audit and enable security-oriented Xcode build settings.
SkillAFreshness: AClaude Code +9 - 0.567score
uikit-app-modernization
guillevc
Modernizes UIKit apps for multi-window environments by replacing legacy shared-state APIs with context-appropriate modern alternatives.
SkillAFreshness: AClaude Code +9 - 0.567score
adopt-c-bounds-safety
guillevc
Guide for the C -fbounds-safety language extension.
SkillAFreshness: AClaude Code +9 - 0.566score
swiftui-whats-new-27
guillevc
New SwiftUI APIs, behaviors, and deprecations introduced in the 2027 OS releases (iOS 27, macOS 27, watchOS 27, tvOS 27, visionOS 27).
SkillAFreshness: AClaude Code +9 - 0.560score
swiftui-specialist
guillevc
Authoritative SwiftUI best practices from Apple.
SkillAFreshness: AClaude Code +9 - 0.558score
modernize-tests
guillevc
Modernize test suites to use modern Swift Testing features or migrate from XCTest.
SkillAFreshness: AClaude Code +9 - 0.558score
device-interaction
guillevc
Verify iOS app behavior on device or simulator via screenshots, UI hierarchy, and touch interactions.
SkillAFreshness: AClaude Code +9 - 0.518score
simple-english
guillevc
Rewrite or write English at a CEFR level (default B1) so non-proficient readers understand it.
SkillBFreshness: BClaude Code +9 - 0.479score
swift-factory-di
guillevc
MUST USE for questions about the Swift Factory dependency injection library by hmlongco, also called FactoryKit.
SkillCFreshness: CClaude Code +9 - 0.474score
audit
guillevc
Audit code against the living spec (ADRs and the glossary) and let the human resolve each contradiction.
SkillCFreshness: CClaude Code +9 - 0.474score
record
guillevc
Write a resolved fact into the living spec (a glossary term or an ADR) and keep it coherent.
SkillCFreshness: CClaude Code +9 - 0.474score
2-commit-fast
guillevc
Fast auto-commit: analyzes staged git changes and commits with an intelligent conventional commit message — no confirmation needed.
SkillCFreshness: CClaude Code +9
Signals
- Stars
- 0
- Forks
- 0
- Open issues
- 0
- Last commit (this folder)
- Jun 28, 2026 (4 months ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/guillevc/skills
- Website
- skills.sh/guillevc/skills
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from guillevc
- 0.570score
audit-xcode-security-settings
guillevc
Audit and enable security-oriented Xcode build settings.
SkillAFreshness: AClaude Code +9 - 0.567score
adopt-c-bounds-safety
guillevc
Guide for the C -fbounds-safety language extension.
SkillAFreshness: AClaude Code +9 - 0.567score
uikit-app-modernization
guillevc
Modernizes UIKit apps for multi-window environments by replacing legacy shared-state APIs with context-appropriate modern alternatives.
SkillAFreshness: AClaude Code +9 - 0.566score
swiftui-whats-new-27
guillevc
New SwiftUI APIs, behaviors, and deprecations introduced in the 2027 OS releases (iOS 27, macOS 27, watchOS 27, tvOS 27, visionOS 27).
SkillAFreshness: AClaude Code +9 - 0.560score
swiftui-specialist
guillevc
Authoritative SwiftUI best practices from Apple.
SkillAFreshness: AClaude Code +9 - 0.558score
device-interaction
guillevc
Verify iOS app behavior on device or simulator via screenshots, UI hierarchy, and touch interactions.
SkillAFreshness: AClaude Code +9
Done for you
Rather not set it up yourself?
Chalk Labs scopes, builds and runs agents for your team: the task audit, the eval harness, the integrations and the weekly ops report. Fixed scope, priced before we start.
See how we build AI agents →Read the case studies
Chalk Labs is a two-founder AI and growth studio. We build AI agents, CRMs and MVPs for Web3 and AI companies, and have shipped 50+ product and token launches.
- launches shipped
- 50+
- launches shipped
- media placements
- 500+
- media placements
- founders on every account
- 2
- founders on every account
Press we've placed: Forbes · CoinDesk · Decrypt · Cointelegraph · The Block
Rahil Jain, Co-founder, Chalk Labs. Ex-Goldman Sachs engineer. You talk to the person who builds it.
Get refactor-guru running in your business
Tell us what you want to automate. A founder replies within one working day with a plan, not a pitch deck.
Cite this page
refactor-guru skill. Agent Mart. https://agentmart.dev/skills/guillevc-refactor-guru (last updated 2026-10-24)