refactoring-patterns
Safe refactoring techniques — extract method, rename, move, inline, and structural patterns.
Skill by Claude-Code-Community-Ireland
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/claude-code-community-ireland-refactoring-patterns
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
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-patterns
What's inside
- Skill name
refactoring-patterns- Description
- Safe refactoring techniques — extract method, rename, move, inline, and structural patterns. Includes code smell identification and transformation recipes. Use when refactoring code or improving structure.
- License
- MIT
- Instructions
- 243 lines in SKILL.md · view on GitHub
Files (1)
- SKILL.md
SKILL.md (first lines)
# Refactoring Patterns
## Safety Rules
Before any refactoring, verify all of the following:
- [ ] Tests exist covering the code you will change
- [ ] All tests pass before you start
- [ ] Perform one transformation at a time
- [ ] Run tests after every single transformation
- [ ] Commit after each successful step
- [ ] Name every transformation in your commit message (e.g., "refactor: Extract Method -- validateEmail")
- [ ] Never change behavior and structure in the same commit
- [ ] If a step breaks tests, revert immediately and try a smaller step
## Code Smell Catalog
| Smell | Symptoms | Typical Refactoring |
|------------------------|------------------------------------------------------------|----------------------------------------------|
| Long Method | Method over 20 lines; multiple levels of abstraction | Extract Method |
| Large Class | Class over 300 lines; too many responsibilities | Extract Class |
| Feature Envy | Method uses more data from another class than its own | Move Method |
| Data Clump | Same group of fields/params appear together repeatedly | Introduce Parameter Object |
| Primitive Obsession | Using primitives instead of small domain objects | Replace Primitive with Value Object |
| Shotgun Surgery | One change requires edits across many files | Move Method, Inline Class |
| Divergent Change | One class changed for many different reasons | Extract Class |
| Dead Code | Unreachable code, unused variables, commented-out blocks | Remove Dead Code |
| Long Parameter List | Method takes more than 3 parameters | Introduce Parameter Object |
| Switch Statements | Repeated switch/if-else on the same type field | Replace Conditional with Polymorphism |
| Duplicate Code | Same logic in multiple places | Extract Method, Extract Superclass |
| Magic Numbers | Unexplained literal values in logic | Replace Magic Number with Named Constant |
### Smell Examples
**Long Method:**
```typescript
function processOrder(order: Order) {
// validate (10 lines) + calculate totals (15 lines)
// apply discounts (12 lines) + check inventory (8 lines)
// create invoice (10 lines) + send notification (6 lines)
}
```
**Feature Envy:**
```typescript
class Order {
calculateShipping() {
if (this.customer.address.country === "US") {
if (this.customer.tier === "premium") return 0;
return this.customer.address.isRemote ? 15 : 5;
}
return 25;
}
}
```
**Data Clump:**
```typescript
function createUser(name: string, street: string, city: string, state: string, zip: string) {}
function updateAddress(street: string, city: string, state: string, zip: string) {}
```
## Named Refactorings
| Refactoring | Input | Output |
|-------------------------------------------|-----------------------------------|----------------------------------------|
| Extract Method | Code block inside a method | New method + call site |
| Extract Class | Fields and methods from a class | New class with focused responsibility |
| Inline Method | Trivial method | Body placed at all call sites |
| Rename | Unclear name | Intention-revealing name |
| Move Method | Method in wrong class | Method in the class that owns the data |
| Introduce Parameter Object | Multiple related parameters | Single object parameter |
| Replace Conditional with Polymorphism | Type-based switch/if-else | Subclasses with overridden method |
| Replace Magic Number with Named Constant | Literal number in code | Named constant |
| Decompose Conditional | Complex boolean expression | Named methods for conditions |
| Remove Dead Code | Unused code | Deletion |
### Extract Method
**Recipe:** (1) Identify code to extract. (2) Create method with intention-revealing name. (3) Copy code in. (4) Local variables become locals; outer scope reads become parameters; modified-and-used-after become return values. (5) Replace original with call. (6) Run tests.
```typescript
// Before
function printInvoice(invoice: Invoice) {
console.log("=== Invoice ===");
let total = 0;
for (const item of invoice.items) { total += item.price * item.quantity; }
const tax = total * 0.08;
console.log(`Total: ${total + tax}`);
}
// After
function printInvoice(invoice: Invoice) {
console.log("=== Invoice ===");
console.log(`Total: ${calculateGrandTotal(invoice.items)}`);
}
function calculateGrandTotal(items: InvoiceItem[]): number {
const subtotal = items.reduce((sum, i) => sum + i.price * i.quantity, 0);
return subtotal + subtotal * 0.08;
}
```
### Extract Class
**Recipe:** (1) Identify cohesive fields and methods. (2) Create new class. (3) Move fields. (4) Move methods. (5) Delegate from original. (6) Run tests after each move.
```typescript
// Before
class User {
name: string; email: string;
street: string; city: string; state: string; zip: string;
fullAddress(): string { return `${this.street}, ${this.city}, ${this.state} ${this.zip}`; }
}
// After
class Address {
constructor(public street: string, public city: string, public state: string, public zip: string) {}
full(): string { return `${this.street}, ${this.city}, ${this.state} ${this.zip}`; }From Claude-Code-Community-Ireland/claude-code-resources, MIT.
More from Claude-Code-Community-Ireland/claude-code-resources
- 0.477score
start-of-day
Claude-Code-Community-Ireland
Comprehensive daily project sync - checks git repos, analyzes all code, reads documentation, and provides status report.
SkillDFreshness: D★ 11Claude Code +9 - 0.477score
performance-profiling
Claude-Code-Community-Ireland
Performance analysis methodology — identifying bottlenecks, profiling techniques, benchmarking, and common optimization patterns.
SkillDFreshness: D★ 11Claude Code +9 - 0.477score
architecture-decision-record
Claude-Code-Community-Ireland
ADR format and methodology for documenting significant technical decisions with context, alternatives considered, and consequences.
SkillDFreshness: D★ 11Claude Code +9 - 0.477score
incident-response
Claude-Code-Community-Ireland
Incident response procedures — triage, communication, investigation, mitigation, and post-incident review.
SkillDFreshness: D★ 11Claude Code +9 - 0.477score
conventional-commits
Claude-Code-Community-Ireland
Generate well-formatted conventional commit messages from staged changes.
SkillDFreshness: D★ 11Claude Code +9 - 0.477score
tdd-workflow
Claude-Code-Community-Ireland
Test-driven development methodology — red-green-refactor cycle, writing failing tests first, minimal implementation, and iterative refinement.
SkillDFreshness: D★ 11Claude Code +9 - 0.477score
debugging-systematic
Claude-Code-Community-Ireland
Systematic debugging methodology — binary search isolation, hypothesis-driven debugging, reproducing issues, and root cause analysis.
SkillDFreshness: D★ 11Claude Code +9 - 0.477score
dependency-audit
Claude-Code-Community-Ireland
Dependency management and auditing — evaluating new dependencies, security vulnerability scanning, update strategies, and license compliance.
SkillDFreshness: D★ 11Claude Code +9 - 0.477score
community-code-reviewer
Claude-Code-Community-Ireland
Perform thorough, constructive code reviews on pull requests and code changes.
SkillDFreshness: D★ 11Claude Code +9 - 0.477score
finish-the-day
Claude-Code-Community-Ireland
End-of-day wrap up - analyzes all work done, creates detailed daily update log, commits all changes, and pushes to remote.
SkillDFreshness: D★ 11Claude Code +9 - 0.477score
discord
Claude-Code-Community-Ireland
Manage your Discord server - post announcements, create events, moderate, and more.
SkillDFreshness: D★ 11Claude Code +9 - 0.474score
database-migration
Claude-Code-Community-Ireland
Database migration best practices — schema changes, zero-downtime migrations, rollback strategies, and data migration patterns.
SkillDFreshness: D★ 11Claude Code +9
Signals
- Stars
- 11
- Forks
- 4
- Open issues
- 4
- Last commit (this folder)
- Jan 29, 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 Claude-Code-Community-Ireland
- 0.477score
debugging-systematic
Claude-Code-Community-Ireland
Systematic debugging methodology — binary search isolation, hypothesis-driven debugging, reproducing issues, and root cause analysis.
SkillDFreshness: D★ 11Claude Code +9 - 0.477score
dependency-audit
Claude-Code-Community-Ireland
Dependency management and auditing — evaluating new dependencies, security vulnerability scanning, update strategies, and license compliance.
SkillDFreshness: D★ 11Claude Code +9 - 0.477score
architecture-decision-record
Claude-Code-Community-Ireland
ADR format and methodology for documenting significant technical decisions with context, alternatives considered, and consequences.
SkillDFreshness: D★ 11Claude Code +9 - 0.477score
community-code-reviewer
Claude-Code-Community-Ireland
Perform thorough, constructive code reviews on pull requests and code changes.
SkillDFreshness: D★ 11Claude Code +9 - 0.477score
conventional-commits
Claude-Code-Community-Ireland
Generate well-formatted conventional commit messages from staged changes.
SkillDFreshness: D★ 11Claude Code +9 - 0.477score
discord
Claude-Code-Community-Ireland
Manage your Discord server - post announcements, create events, moderate, and more.
SkillDFreshness: D★ 11Claude Code +9
Cite this page
refactoring-patterns skill. Agent Mart. https://agentmart.dev/skills/claude-code-community-ireland-refactoring-patterns (last updated 2026-10-24)