
Refactoring Patterns
- 115 installs
- 433 repo stars
- Updated August 4, 2026
- proffesor-for-testing/agentic-qe
refactoring-patterns is a Claude Code skill for code review & quality.
About
refactoring-patterns is a Claude Code skill for code review & quality. It helps solo builders move faster with AI-assisted development.
- refactoring-patterns
- Code Review & Quality
- AI-coding skill
Refactoring Patterns by the numbers
- 115 all-time installs (skills.sh)
- +3 installs in the week ending Aug 4, 2026 (Skillselion tracking)
- Ranked #433 of 1,352 Code Review & Quality skills by installs in the Skillselion catalog
- Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/proffesor-for-testing/agentic-qe --skill refactoring-patternsAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 115 |
|---|---|
| repo stars | ★ 433 |
| Last updated | August 4, 2026 |
| Repository | proffesor-for-testing/agentic-qe ↗ |
How do I helps with code review & quality tasks.?
Helps with code review & quality tasks.
Who is it for?
Best when you're working on code review & quality and need structured help with refactoring patterns.
Skip if: Teams with no code review & quality needs, or anyone wanting a generic chat assistant without this specific workflow.
When should I use this skill?
When you need to helps with code review & quality tasks., or when refactoring-patterns is a claude code skill for code review & quality.
What you get
Structured output aligned to refactoring-patterns: refactoring-patterns, Code Review & Quality.
Files
Refactoring Patterns
<default_to_action> When refactoring: 1. ENSURE tests pass (never refactor without tests) 2. MAKE small change (one refactoring at a time) 3. RUN tests (must stay green) 4. COMMIT (save progress) 5. REPEAT
Safe Refactoring Cycle:
npm test # Green ✅
# Make ONE small change
npm test # Still green ✅
git commit -m "refactor: extract calculateTotal"
# RepeatCode Smells → Refactoring:
| Smell | Refactoring |
|---|---|
| Long method (>20 lines) | Extract Method |
| Large class | Extract Class |
| Long parameter list (>3) | Introduce Parameter Object |
| Duplicated code | Extract Method/Class |
| Complex conditional | Decompose Conditional |
| Magic numbers | Named Constants |
| Nested loops | Replace Loop with Pipeline |
NEVER REFACTOR:
- Without tests (write tests first)
- When deadline is tomorrow
- Code you don't understand
- Code that works and won't be touched
</default_to_action>
Quick Reference Card
Common Refactorings
| Pattern | Before | After |
|---|---|---|
| Extract Method | 50-line function | 5 small functions |
| Extract Class | Class doing 5 things | 5 single-purpose classes |
| Parameter Object | fn(a,b,c,d,e,f) | fn(options) |
| Replace Conditional | if (type === 'a') {...} | Polymorphism |
| Pipeline | Nested loops | .filter().map().reduce() |
The Rule of Three
1. First time → Just do it 2. Second time → Wince and duplicate 3. Third time → Refactor
---
Key Patterns
Extract Method
// Before: Long method
function processOrder(order) {
// 50 lines of validation, calculation, saving, emailing...
}
// After: Clear responsibilities
function processOrder(order) {
validateOrder(order);
const pricing = calculatePricing(order);
const saved = saveOrder(order, pricing);
sendConfirmationEmail(saved);
return saved;
}Replace Loop with Pipeline
// Before
let results = [];
for (let item of items) {
if (item.inStock) {
results.push(item.name.toUpperCase());
}
}
// After
const results = items
.filter(item => item.inStock)
.map(item => item.name.toUpperCase());Decompose Conditional
// Before
if (order.total > 1000 && customer.isPremium && allInStock(order)) {
return 'FREE_SHIPPING';
}
// After
function isEligibleForFreeShipping(order, customer) {
return isLargeOrder(order) &&
isPremiumCustomer(customer) &&
allInStock(order);
}---
Refactoring Anti-Patterns
| ❌ Anti-Pattern | Problem | ✅ Better |
|---|---|---|
| Without tests | No safety net | Write tests first |
| Big bang | Rewrite everything | Small incremental steps |
| For perfection | Endless tweaking | Good enough, move on |
| Premature abstraction | Pattern not clear yet | Wait for Rule of Three |
| During feature work | Mixed changes | Separate commits |
---
Agent Integration
// Detect code smells
const smells = await Task("Detect Code Smells", {
source: 'src/services/',
patterns: ['long-method', 'large-class', 'duplicate-code']
}, "qe-quality-analyzer");
// Safe refactoring with test verification
await Task("Verify Refactoring", {
beforeCommit: 'abc123',
afterCommit: 'def456',
expectSameBehavior: true
}, "qe-test-executor");---
Agent Coordination Hints
Memory Namespace
aqe/refactoring/
├── smells/* - Detected code smells
├── suggestions/* - Refactoring recommendations
├── verifications/* - Behavior preservation checks
└── history/* - Refactoring logFleet Coordination
const refactoringFleet = await FleetManager.coordinate({
strategy: 'refactoring',
agents: [
'qe-quality-analyzer', // Identify targets
'qe-test-generator', // Add safety tests
'qe-test-executor', // Verify behavior
'qe-test-refactorer' // TDD refactor phase
],
topology: 'sequential'
});---
Related Skills
- tdd-london-chicago - TDD refactor phase
- code-review-quality - Review refactored code
- xp-practices - Collective ownership
---
Remember
Refactoring is NOT:
- Adding features
- Fixing bugs
- Performance optimization
- Rewriting from scratch
Refactoring IS:
- Improving structure
- Making code clearer
- Reducing complexity
- Removing duplication
- Without changing behavior
Always have tests. Always take small steps. Always keep tests green.
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://agentic-qe.dev/schemas/refactoring-patterns-output.json",
"title": "Refactoring Patterns Skill Output Schema",
"description": "Schema for refactoring patterns output with refactoring catalog, code smells, and transformation metrics.",
"type": "object",
"required": ["skillName", "version", "timestamp", "status", "trustTier", "output"],
"properties": {
"skillName": {
"type": "string",
"const": "refactoring-patterns",
"description": "Must be 'refactoring-patterns'"
},
"version": {
"type": "string",
"pattern": "^\\d+\\.\\d+\\.\\d+(-[a-zA-Z0-9]+)?$"
},
"timestamp": {
"type": "string",
"format": "date-time"
},
"status": {
"type": "string",
"enum": ["success", "partial", "failed", "skipped"]
},
"trustTier": {
"type": "integer",
"minimum": 0,
"maximum": 3
},
"output": {
"type": "object",
"required": ["summary", "refactorings"],
"properties": {
"summary": {
"type": "string",
"minLength": 50,
"maxLength": 2000
},
"refactorings": {
"type": "array",
"items": {
"$ref": "#/$defs/refactoring"
},
"minItems": 0,
"description": "List of refactorings performed or recommended"
},
"codeSmells": {
"type": "array",
"items": {
"$ref": "#/$defs/codeSmell"
},
"description": "Code smells detected"
},
"qualityMetrics": {
"$ref": "#/$defs/qualityMetrics"
},
"transformationSummary": {
"$ref": "#/$defs/transformationSummary"
},
"findings": {
"type": "array",
"items": {
"$ref": "#/$defs/finding"
},
"maxItems": 100
},
"recommendations": {
"type": "array",
"items": {
"$ref": "#/$defs/recommendation"
},
"maxItems": 50
},
"artifacts": {
"type": "array",
"items": {
"$ref": "#/$defs/artifact"
}
}
}
},
"metadata": {
"$ref": "#/$defs/metadata"
},
"validation": {
"$ref": "#/$defs/validationResult"
},
"learning": {
"$ref": "#/$defs/learningData"
}
},
"$defs": {
"refactoring": {
"type": "object",
"required": ["id", "name", "category", "status"],
"properties": {
"id": {
"type": "string",
"pattern": "^REF-\\d{3,6}$"
},
"name": {
"type": "string",
"description": "Refactoring pattern name (e.g., Extract Method, Rename Variable)"
},
"category": {
"type": "string",
"enum": [
"composing-methods",
"moving-features",
"organizing-data",
"simplifying-conditional",
"simplifying-method-calls",
"dealing-with-generalization",
"encapsulation",
"inline",
"extract"
]
},
"status": {
"type": "string",
"enum": ["applied", "suggested", "rejected", "in-progress"]
},
"description": {
"type": "string",
"maxLength": 1000
},
"motivation": {
"type": "string",
"maxLength": 500
},
"location": {
"type": "object",
"properties": {
"file": {
"type": "string"
},
"line": {
"type": "integer",
"minimum": 1
},
"method": {
"type": "string"
},
"class": {
"type": "string"
}
}
},
"codeExample": {
"type": "object",
"properties": {
"before": {
"type": "string"
},
"after": {
"type": "string"
},
"language": {
"type": "string"
}
}
},
"risk": {
"type": "string",
"enum": ["low", "medium", "high"]
},
"effort": {
"type": "string",
"enum": ["trivial", "low", "medium", "high", "major"]
},
"impact": {
"type": "object",
"properties": {
"readability": {
"type": "number",
"minimum": -10,
"maximum": 10
},
"maintainability": {
"type": "number",
"minimum": -10,
"maximum": 10
},
"performance": {
"type": "number",
"minimum": -10,
"maximum": 10
},
"testability": {
"type": "number",
"minimum": -10,
"maximum": 10
}
}
},
"relatedSmells": {
"type": "array",
"items": {
"type": "string"
}
}
}
},
"codeSmell": {
"type": "object",
"required": ["id", "name", "severity"],
"properties": {
"id": {
"type": "string",
"pattern": "^SMELL-\\d{3,6}$"
},
"name": {
"type": "string",
"description": "Code smell name (e.g., Long Method, Feature Envy)"
},
"severity": {
"type": "string",
"enum": ["critical", "high", "medium", "low", "info"]
},
"category": {
"type": "string",
"enum": [
"bloaters",
"oo-abusers",
"change-preventers",
"dispensables",
"couplers"
]
},
"description": {
"type": "string"
},
"location": {
"type": "object",
"properties": {
"file": {
"type": "string"
},
"line": {
"type": "integer"
},
"method": {
"type": "string"
}
}
},
"suggestedRefactorings": {
"type": "array",
"items": {
"type": "string"
}
},
"metrics": {
"type": "object",
"additionalProperties": {
"type": "number"
}
}
}
},
"qualityMetrics": {
"type": "object",
"properties": {
"beforeRefactoring": {
"type": "object",
"properties": {
"cyclomaticComplexity": {
"type": "number"
},
"linesOfCode": {
"type": "integer"
},
"duplications": {
"type": "number"
},
"couplingScore": {
"type": "number"
},
"cohesionScore": {
"type": "number"
}
}
},
"afterRefactoring": {
"type": "object",
"properties": {
"cyclomaticComplexity": {
"type": "number"
},
"linesOfCode": {
"type": "integer"
},
"duplications": {
"type": "number"
},
"couplingScore": {
"type": "number"
},
"cohesionScore": {
"type": "number"
}
}
},
"improvement": {
"type": "object",
"properties": {
"complexityReduction": {
"type": "number"
},
"locReduction": {
"type": "number"
},
"duplicationReduction": {
"type": "number"
}
}
}
}
},
"transformationSummary": {
"type": "object",
"properties": {
"totalRefactorings": {
"type": "integer",
"minimum": 0
},
"appliedRefactorings": {
"type": "integer",
"minimum": 0
},
"suggestedRefactorings": {
"type": "integer",
"minimum": 0
},
"codeSmellsResolved": {
"type": "integer",
"minimum": 0
},
"codeSmellsRemaining": {
"type": "integer",
"minimum": 0
},
"testsPreserved": {
"type": "boolean"
},
"behaviorPreserved": {
"type": "boolean"
}
}
},
"finding": {
"type": "object",
"required": ["id", "title", "severity", "category"],
"properties": {
"id": {
"type": "string",
"pattern": "^RFP-\\d{3,6}$"
},
"title": {
"type": "string"
},
"description": {
"type": "string"
},
"severity": {
"type": "string",
"enum": ["critical", "high", "medium", "low", "info"]
},
"category": {
"type": "string",
"enum": ["smell", "pattern", "design", "safety", "test-impact"]
},
"remediation": {
"type": "string"
}
}
},
"recommendation": {
"type": "object",
"required": ["id", "title", "priority"],
"properties": {
"id": {
"type": "string",
"pattern": "^REC-\\d{3,6}$"
},
"title": {
"type": "string"
},
"description": {
"type": "string"
},
"priority": {
"type": "string",
"enum": ["critical", "high", "medium", "low"]
},
"effort": {
"type": "string",
"enum": ["trivial", "low", "medium", "high", "major"]
},
"impact": {
"type": "integer",
"minimum": 1,
"maximum": 10
}
}
},
"artifact": {
"type": "object",
"required": ["type", "path"],
"properties": {
"type": {
"type": "string",
"enum": ["report", "diff", "code", "metrics"]
},
"path": {
"type": "string"
},
"format": {
"type": "string"
}
}
},
"metadata": {
"type": "object",
"properties": {
"executionTimeMs": {
"type": "integer",
"minimum": 0
},
"toolsUsed": {
"type": "array",
"items": {
"type": "string"
}
},
"agentId": {
"type": "string"
}
}
},
"validationResult": {
"type": "object",
"properties": {
"schemaValid": {
"type": "boolean"
},
"contentValid": {
"type": "boolean"
},
"confidence": {
"type": "number",
"minimum": 0,
"maximum": 1
}
}
},
"learningData": {
"type": "object",
"properties": {
"patternsDetected": {
"type": "array",
"items": {
"type": "string"
}
},
"reward": {
"type": "number",
"minimum": 0,
"maximum": 1
}
}
}
}
}
{
"skillName": "refactoring-patterns",
"skillVersion": "1.0.0",
"requiredTools": [
"jq"
],
"optionalTools": [],
"schemaPath": "schemas/output.json",
"requiredFields": [
"skillName",
"status",
"output",
"output.summary",
"output.refactorings"
],
"requiredNonEmptyFields": [],
"mustContainTerms": [
"refactor",
"pattern",
"smell"
],
"mustNotContainTerms": [
"TODO",
"FIXME",
"placeholder"
],
"enumValidations": {
".status": [
"success",
"partial",
"failed",
"skipped"
]
}
}
Related skills
FAQ
What does refactoring-patterns do?
refactoring-patterns is a Claude Code skill for code review & quality.
When should I use refactoring-patterns?
When you need to helps with code review & quality tasks., or when refactoring-patterns is a claude code skill for code review & quality.
What are the main capabilities?
refactoring-patterns; Code Review & Quality; AI-coding skill.