code-refactoring
Code refactoring patterns and techniques for improving code quality without changing behavior.
Skill by myths-labs
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/myths-labs-code-refactoring
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 and code. 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/code-refactoring
What's inside
- Skill name
code-refactoring- Description
- Code refactoring patterns and techniques for improving code quality without changing behavior. Use for cleaning up legacy code, reducing complexity, or improving maintainability.
- License
- MIT
- Instructions
- 204 lines in SKILL.md · view on GitHub
Files (1)
- SKILL.md
SKILL.md (first lines)
# Code Refactoring
## Refactoring Principles
### When to Refactor
- Before adding new features (make change easy, then make easy change)
- After getting tests passing (red-green-refactor)
- When you see code smells
- During code review feedback
### When NOT to Refactor
- Without tests covering the code
- Under tight deadlines with no safety net
- Code that will be replaced soon
- When you don't understand what the code does
## Common Code Smells
### Long Methods
```typescript
// BEFORE: Method doing too much
function processOrder(order: Order) {
// 100 lines of validation, calculation, notification, logging...
}
// AFTER: Extract into focused methods
function processOrder(order: Order) {
validateOrder(order);
const total = calculateTotal(order);
saveOrder(order, total);
notifyCustomer(order);
}
```
### Deeply Nested Conditionals
```typescript
// BEFORE: Arrow code
function getDiscount(user: User, order: Order) {
if (user) {
if (user.isPremium) {
if (order.total > 100) {
if (order.items.length > 5) {
return 0.2;
}
}
}
}
return 0;
}
// AFTER: Early returns (guard clauses)
function getDiscount(user: User, order: Order) {
if (!user) return 0;
if (!user.isPremium) return 0;
if (order.total <= 100) return 0;
if (order.items.length <= 5) return 0;
return 0.2;
}
```
### Primitive Obsession
```typescript
// BEFORE: Primitives everywhere
function createUser(name: string, email: string, phone: string) {
if (!email.includes('@')) throw new Error('Invalid email');
// more validation...
}
// AFTER: Value objects
class Email {
constructor(private value: string) {
if (!value.includes('@')) throw new Error('Invalid email');
}
toString() { return this.value; }
}
function createUser(name: string, email: Email, phone: Phone) {
// Email is already validated
}
```
### Feature Envy
```typescript
// BEFORE: Method uses another object's data extensively
function calculateShipping(order: Order) {
const address = order.customer.address;
const weight = order.items.reduce((sum, i) => sum + i.weight, 0);
const distance = calculateDistance(address.zip);
return weight * distance * 0.01;
}
// AFTER: Move method to where the data is
class Order {
calculateShipping() {
return this.totalWeight * this.customer.shippingDistance * 0.01;
}
}
```
## Refactoring Techniques
### Extract Method
```typescript
// Identify a code block that does one thing
// Move it to a new method with a descriptive name
// Replace original code with method call
function printReport(data: ReportData) {
// Extract this block...
const header = `Report: ${data.title}\nDate: ${data.date}\n${'='.repeat(40)}`;
console.log(header);
// ...into a method
printHeader(data);
}
```
### Replace Conditional with Polymorphism
```typescriptFrom myths-labs/muse, MIT.
More from myths-labs/muse
- 0.659score
growth-distribution
myths-labs
Cross-platform content distribution and growth strategy for DYA app across 10+ platforms (Xiaohongshu, Douyin, TikTok, Instagram Reels, X/Twitter, Reddit…
SkillAFreshness: A★ 36Claude Code +9 - 0.659score
github-pr-review
myths-labs
Handles PR review comments and feedback resolution.
SkillAFreshness: A★ 36Claude Code +9 - 0.659score
muse-orchestration
myths-labs
Run several long-lived AI coding sessions ("lanes") as one team led by an orchestrator lane.
SkillAFreshness: A★ 36Claude Code +9 - 0.656score
muse-commands
myths-labs
Run MUSE /resume, /save and /bye for continuous work in Codex or Claude Code, preserving the selected role, Lane, decisions and source evidence across sessions.
SkillAFreshness: A★ 36Claude Code +9 - 0.654score
markitdown
myths-labs
A Python utility for converting various file formats (PDF, Word, Excel, PowerPoint, etc.) to Markdown.
SkillAFreshness: A★ 36Claude Code +9 - 0.654score
coordinator-mode
myths-labs
Multi-agent coordination SOP derived from Anthropic's internal coordinator architecture.
SkillAFreshness: A★ 36Claude Code +9 - 0.654score
semantic-search
myths-labs
Zero-dependency TF-IDF search across MUSE memory, roles, and skills.
SkillAFreshness: A★ 36Claude Code +9 - 0.651score
javascript-typescript
myths-labs
JavaScript and TypeScript development with ES6+, Node.js, React, and modern web frameworks.
SkillAFreshness: A★ 36Claude Code +9 - 0.651score
architect-agent
myths-labs
Software architecture specialist for system design, scalability, and technical decision-making.
SkillAFreshness: A★ 36Claude Code +9 - 0.651score
database-reviewer
myths-labs
PostgreSQL database specialist for query optimization, schema design, security, and performance.
SkillAFreshness: A★ 36Claude Code +9 - 0.651score
context-health-check
myths-labs
Check actual session context observations; save and reassess after compaction without forcing Bye or guessing model limits.
SkillAFreshness: A★ 36Claude Code +9 - 0.651score
strategic-compact
myths-labs
Suggests manual context compaction at logical intervals to preserve context through task phases rather than arbitrary auto-compaction.
SkillAFreshness: A★ 36Claude Code +9
Compare and alternatives
Featured in
Signals
- Stars
- 36
- Forks
- 4
- Open issues
- 0
- Last commit (this folder)
- Mar 12, 2026 (7 months ago)
- Last release
- Oct 24, 2026 (3 days ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/myths-labs/muse
- Website
- github.com/myths-labs/muse
- 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 myths-labs
- 0.659score
github-pr-review
myths-labs
Handles PR review comments and feedback resolution.
SkillAFreshness: A★ 36Claude Code +9 - 0.659score
muse-orchestration
myths-labs
Run several long-lived AI coding sessions ("lanes") as one team led by an orchestrator lane.
SkillAFreshness: A★ 36Claude Code +9 - 0.659score
growth-distribution
myths-labs
Cross-platform content distribution and growth strategy for DYA app across 10+ platforms (Xiaohongshu, Douyin, TikTok, Instagram Reels, X/Twitter, Reddit…
SkillAFreshness: A★ 36Claude Code +9 - 0.656score
muse-commands
myths-labs
Run MUSE /resume, /save and /bye for continuous work in Codex or Claude Code, preserving the selected role, Lane, decisions and source evidence across sessions.
SkillAFreshness: A★ 36Claude Code +9 - 0.654score
coordinator-mode
myths-labs
Multi-agent coordination SOP derived from Anthropic's internal coordinator architecture.
SkillAFreshness: A★ 36Claude Code +9 - 0.654score
semantic-search
myths-labs
Zero-dependency TF-IDF search across MUSE memory, roles, and skills.
SkillAFreshness: A★ 36Claude Code +9
Cite this page
code-refactoring skill. Agent Mart. https://agentmart.dev/skills/myths-labs-code-refactoring (last updated 2026-10-24)