refactor
Surgical code refactoring to improve maintainability without changing behavior.
Skill by PhilippOesch
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/philippoesch-refactor
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/refactor
What's inside
- Skill name
refactor- Description
- Surgical code refactoring to improve maintainability without changing behavior. Covers extracting functions, renaming variables, breaking down god functions, improving type safety, eliminating code smells, and applying design patterns. Less drastic than repo-rebuilder; use for gradual improvements.
- License
- MIT
- Instructions
- 641 lines in SKILL.md · view on GitHub
Agent Skills spec issues
- body: 641 lines (spec recommends under 500)
Files (1)
- SKILL.md
SKILL.md (first lines)
# Refactor
## Overview
Improve code structure and readability without changing external behavior. Refactoring is gradual evolution, not revolution. Use this for improving existing code, not rewriting from scratch.
## When to Use
Use this skill when:
- Code is hard to understand or maintain
- Functions/classes are too large
- Code smells need addressing
- Adding features is difficult due to code structure
- User asks "clean up this code", "refactor this", "improve this"
---
## Refactoring Principles
### The Golden Rules
1. **Behavior is preserved** - Refactoring doesn't change what the code does, only how
2. **Small steps** - Make tiny changes, test after each
3. **Version control is your friend** - Commit before and after each safe state
4. **Tests are essential** - Without tests, you're not refactoring, you're editing
5. **One thing at a time** - Don't mix refactoring with feature changes
### When NOT to Refactor
```
- Code that works and won't change again (if it ain't broke...)
- Critical production code without tests (add tests first)
- When you're under a tight deadline
- "Just because" - need a clear purpose
```
---
## Common Code Smells & Fixes
### 1. Long Method/Function
```diff
# BAD: 200-line function that does everything
- async function processOrder(orderId) {
- // 50 lines: fetch order
- // 30 lines: validate order
- // 40 lines: calculate pricing
- // 30 lines: update inventory
- // 20 lines: create shipment
- // 30 lines: send notifications
- }
# GOOD: Broken into focused functions
+ async function processOrder(orderId) {
+ const order = await fetchOrder(orderId);
+ validateOrder(order);
+ const pricing = calculatePricing(order);
+ await updateInventory(order);
+ const shipment = await createShipment(order);
+ await sendNotifications(order, pricing, shipment);
+ return { order, pricing, shipment };
+ }
```
### 2. Duplicated Code
```diff
# BAD: Same logic in multiple places
- function calculateUserDiscount(user) {
- if (user.membership === 'gold') return user.total * 0.2;
- if (user.membership === 'silver') return user.total * 0.1;
- return 0;
- }
-
- function calculateOrderDiscount(order) {
- if (order.user.membership === 'gold') return order.total * 0.2;
- if (order.user.membership === 'silver') return order.total * 0.1;
- return 0;
- }
# GOOD: Extract common logic
+ function getMembershipDiscountRate(membership) {
+ const rates = { gold: 0.2, silver: 0.1 };
+ return rates[membership] || 0;
+ }
+
+ function calculateUserDiscount(user) {
+ return user.total * getMembershipDiscountRate(user.membership);
+ }
+
+ function calculateOrderDiscount(order) {
+ return order.total * getMembershipDiscountRate(order.user.membership);
+ }
```
### 3. Large Class/Module
```diff
# BAD: God object that knows too much
- class UserManager {
- createUser() { /* ... */ }
- updateUser() { /* ... */ }
- deleteUser() { /* ... */ }
- sendEmail() { /* ... */ }
- generateReport() { /* ... */ }
- handlePayment() { /* ... */ }
- validateAddress() { /* ... */ }
- // 50 more methods...
- }
# GOOD: Single responsibility per class
+ class UserService {
+ create(data) { /* ... */ }
+ update(id, data) { /* ... */ }
+ delete(id) { /* ... */ }
+ }
+From PhilippOesch/agent-skills, MIT.
More from PhilippOesch/agent-skills
- 0.559score
agent-context
PhilippOesch
Save and retrieve agent-generated knowledge in the configured Obsidian agent-context folder.
SkillAFreshness: AClaude Code +9 - 0.556score
refactor-method-complexity-reduce
PhilippOesch
Refactor given method `${input:methodName}` to reduce its cognitive complexity to `${input:complexityThreshold}` or below, by extracting helper methods.
SkillAFreshness: AClaude Code +9 - 0.553score
diagram
PhilippOesch
Generate a self-contained HTML page rendering a mermaid diagram.
SkillAFreshness: AClaude Code +9 - 0.552score
html-report
PhilippOesch
Self-contained styled HTML reports saved under the configured agent-context research folder: PDF-exportable documents with inline data, charts, and…
SkillAFreshness: AClaude Code +9 - 0.551score
grilling-in-cave
PhilippOesch
Run a grilling session while speaking like a caveman.
SkillAFreshness: AClaude Code +9 - 0.542score
rmslop
PhilippOesch
Remove AI code slop
SkillAFreshness: AClaude Code +9 - 0.534score
grilling
PhilippOesch
Grill the user relentlessly about a plan, decision, or idea.
SkillAFreshness: AClaude Code +9 - 0.534score
handoff
PhilippOesch
Compact the current conversation into a handoff document for another agent to pick up.
SkillAFreshness: AClaude Code +9 - 0.534score
code-review
PhilippOesch
Review the changes since a fixed point (commit, branch, tag, or merge-base) along two axes — Standards (does the code follow this repo's documented coding…
SkillAFreshness: AClaude Code +9 - 0.525score
implement-spec
PhilippOesch
Implement the result of /to-spec and /to-tickets in code.
SkillAFreshness: AClaude Code +9 - 0.523score
implement
PhilippOesch
Implement a piece of work based on a spec or set of tickets.
SkillAFreshness: AClaude Code +9
Signals
- Stars
- 0
- Forks
- 0
- Open issues
- 0
- Last commit (this folder)
- Oct 19, 2026 (9 days ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/PhilippOesch/agent-skills
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
Same skill elsewhere
Copies of this SKILL.md published by others; search shows only one of them.
More from PhilippOesch
- 0.559score
agent-context
PhilippOesch
Save and retrieve agent-generated knowledge in the configured Obsidian agent-context folder.
SkillAFreshness: AClaude Code +9 - 0.556score
refactor-method-complexity-reduce
PhilippOesch
Refactor given method `${input:methodName}` to reduce its cognitive complexity to `${input:complexityThreshold}` or below, by extracting helper methods.
SkillAFreshness: AClaude Code +9 - 0.553score
diagram
PhilippOesch
Generate a self-contained HTML page rendering a mermaid diagram.
SkillAFreshness: AClaude Code +9 - 0.552score
html-report
PhilippOesch
Self-contained styled HTML reports saved under the configured agent-context research folder: PDF-exportable documents with inline data, charts, and…
SkillAFreshness: AClaude Code +9 - 0.551score
grilling-in-cave
PhilippOesch
Run a grilling session while speaking like a caveman.
SkillAFreshness: AClaude Code +9 - 0.542score
rmslop
PhilippOesch
Remove AI code slop
SkillAFreshness: AClaude Code +9
Cite this page
refactor skill. Agent Mart. https://agentmart.dev/skills/philippoesch-refactor (last updated 2026-10-24)