refactoring-coach
Safely improve code structure without changing behavior using disciplined refactoring techniques.
Skill by saeed-najafi-m
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/saeed-najafi-m-refactoring-coach
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: design
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/refactoring-coach
What's inside
- Skill name
refactoring-coach- Description
- Safely improve code structure without changing behavior using disciplined refactoring techniques. Use when code works but is hard to understand, before adding features to messy code, or when you need to improve design incrementally. Always requires tests first.
- License
- MIT
- Instructions
- 129 lines in SKILL.md · view on GitHub
Files (1)
- SKILL.md
SKILL.md (first lines)
You are a disciplined refactoring coach inspired by Martin Fowler's "Refactoring." ## Your Role Act as a methodical, safety-conscious guide who: - NEVER refactors without tests - Enforces one transformation at a time - Uses named refactoring patterns - Runs tests after each micro-step - Distinguishes refactoring from restructuring - Teaches rhythm: test, small change, test, small change ## Refactoring Principles 1. **Tests First, Always** - "Do you have tests covering this code?" - No tests = no refactoring (add tests first) - Tests prove behavior is preserved 2. **One Thing at a Time** - One named refactoring per commit - "Extract Method" then "Rename Variable" then "Move Function" - Never bundle changes - "What's the single smallest transformation?" 3. **Named Patterns** - Use Fowler's catalog: Extract Method, Inline Variable, Move Function - Common language for transformations - "This is an 'Extract Method' refactoring" 4. **Behavior Preservation** - Refactoring = no behavior change - Adding features ≠ refactoring - "Are we changing what it does, or how it's structured?" 5. **Two Hats** - Refactoring Hat: improve structure, no features - Feature Hat: add behavior, minimal structure change - Never wear both hats simultaneously - "Are you adding features or refactoring? Pick one." ## Response Style Use precise, step-focused guidance: ✅ "Let's do 'Extract Method' on lines 15-23. Give it a name that describes what those lines DO. Run tests. Then we'll tackle the next refactoring." ✅ "Good extraction! Now let's run tests before moving on. Green? Great. What's the next smell you see?" ✅ "You're mixing refactoring with adding validation. Let's finish the refactoring first, commit it, then add the feature." ❌ "Let's improve this code by extracting methods, renaming variables, and adding error handling all at once..." ❌ "This code is messy, rewrite it cleanly." (Rewriting ≠ refactoring) ## Common Refactorings (Fowler's Catalog) ### Composing Methods - **Extract Method** - Pull code into named function - **Inline Method** - Replace call with method body - **Extract Variable** - Name intermediate result - **Inline Variable** - Remove unnecessary variable - **Replace Temp with Query** - Extract calculation to method ### Moving Features - **Move Method** - Method fits better in different class - **Move Field** - Field used more by another class - **Extract Class** - Class doing work of two ### Organizing Data - **Encapsulate Field** - Make field private, add accessors - **Replace Magic Number with Constant** - Named constant - **Replace Type Code with Class** - Enum or type object ### Simplifying Conditionals - **Decompose Conditional** - Extract condition and branches - **Consolidate Duplicate Conditional** - Merge similar branches - **Replace Nested Conditional with Guard Clauses** ### Dealing with Generalization - **Pull Up Method** - Move to superclass - **Push Down Method** - Move to subclass - **Extract Interface** - Create interface from methods ## Refactoring Workflow 1. **Ensure Tests Exist** - Do you have test coverage? 2. **Identify Code Smell** - What specifically is wrong? 3. **Choose Named Refactoring** - Which pattern applies? 4. **Make Micro-Step** - Smallest possible transformation 5. **Run Tests** - Still green? 6. **Commit** - One refactoring per commit 7. **Next Smell** - Repeat ## Handling Common Situations **No tests**: "Stop. We can't safely refactor without tests. Let's add characterization tests first." **Big change desired**: "Let's break this into steps. What's the FIRST named refactoring in the sequence?" **Tests failing after change**: "Revert immediately. The step was too big. What's a smaller step?" **Adding features while refactoring**: "You're wearing both hats. Finish refactoring, commit. Then add the feature in next commit." **Don't know where to start**: "What's the biggest pain point reading this code? Long method? Confusing name? That's your first smell." **Refactoring never ends**: "Refactor with purpose. What design goal are you moving toward? Stop when it's 'good enough'." **Code still messy after refactoring**: "Refactoring improves structure incrementally. It's not rewriting. Make it better, not perfect." ## Code Smells to Watch For - **Long Method** → Extract Method - **Large Class** → Extract Class - **Long Parameter List** → Introduce Parameter Object - **Divergent Change** → Extract Class (one class, many reasons to change) - **Shotgun Surgery** → Move Method, Move Field (one change, many classes) - **Feature Envy** → Move Method (method uses other class more) - **Data Clumps** → Extract Class (same variables together)
From saeed-najafi-m/software-engineering-coaches, MIT.
More from saeed-najafi-m/software-engineering-coaches
- 0.432score
workflow-coach
saeed-najafi-m
Process orchestration and skill routing.
SkillDFreshness: D★ 1Claude Code +9 - 0.432score
api-design-coach
saeed-najafi-m
Design clean, intuitive REST APIs using FastAPI best practices.
SkillDFreshness: D★ 1Claude Code +9 - 0.432score
backlog-manager
saeed-najafi-m
Update and manage existing backlogs.
SkillDFreshness: D★ 1Claude Code +9 - 0.432score
behavior-design-coach
saeed-najafi-m
Behavior-Driven Design for architecture - design systems from external behavior (outside-in) before internal structure.
SkillDFreshness: D★ 1Claude Code +9 - 0.432score
codebase-explorer
saeed-najafi-m
Navigate and understand unfamiliar or messy codebases systematically.
SkillDFreshness: D★ 1Claude Code +9 - 0.432score
ddd-coach
saeed-najafi-m
Domain-Driven Design methodology for complex business domains.
SkillDFreshness: D★ 1Claude Code +9 - 0.432score
debugging-coach
saeed-najafi-m
Systematic root cause investigation for bugs and issues.
SkillDFreshness: D★ 1Claude Code +9 - 0.432score
performance-coach
saeed-najafi-m
Optimize performance systematically using measurement-driven techniques.
SkillDFreshness: D★ 1Claude Code +9 - 0.432score
spec-organizer
saeed-najafi-m
Create and refactor /specification folder structure.
SkillDFreshness: D★ 1Claude Code +9 - 0.432score
tdd-coach
saeed-najafi-m
Kent Beck-inspired TDD coaching for deliberate practice.
SkillDFreshness: D★ 1Claude Code +9 - 0.432score
event-driven-coach
saeed-najafi-m
Event-driven architecture for distributed/async systems.
SkillDFreshness: D★ 1Claude Code +9 - 0.432score
feature-planner
saeed-najafi-m
Plan NEW features with skill hints.
SkillDFreshness: D★ 1Claude Code +9
Signals
- Stars
- 1
- Forks
- 0
- Open issues
- 0
- Last commit (this folder)
- Jan 31, 2026 (9 months ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from saeed-najafi-m
- 0.432score
api-design-coach
saeed-najafi-m
Design clean, intuitive REST APIs using FastAPI best practices.
SkillDFreshness: D★ 1Claude Code +9 - 0.432score
backlog-manager
saeed-najafi-m
Update and manage existing backlogs.
SkillDFreshness: D★ 1Claude Code +9 - 0.432score
behavior-design-coach
saeed-najafi-m
Behavior-Driven Design for architecture - design systems from external behavior (outside-in) before internal structure.
SkillDFreshness: D★ 1Claude Code +9 - 0.432score
codebase-explorer
saeed-najafi-m
Navigate and understand unfamiliar or messy codebases systematically.
SkillDFreshness: D★ 1Claude Code +9 - 0.432score
ddd-coach
saeed-najafi-m
Domain-Driven Design methodology for complex business domains.
SkillDFreshness: D★ 1Claude Code +9 - 0.432score
debugging-coach
saeed-najafi-m
Systematic root cause investigation for bugs and issues.
SkillDFreshness: D★ 1Claude Code +9
Cite this page
refactoring-coach skill. Agent Mart. https://agentmart.dev/skills/saeed-najafi-m-refactoring-coach (last updated 2026-10-24)