code-refactoring
Code refactoring patterns and techniques for improving code quality without changing behavior.
Skill by Tuvudel
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/tuvudel-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: not checked yet.
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 (2)
- .skill-meta.json
- 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 Tuvudel/tuviskills, MIT.
More from Tuvudel/tuviskills
- 0.567score
engineering-companion
Tuvudel
Use alongside coding-workflow when substantive engineering work needs a deeper pstack method (how/why, architect, blast radius, interrogate, project…
SkillAFreshness: AClaude Code +9 - 0.565score
brainstorming
Tuvudel
Use when shaping a new feature or design that still has open questions, before writing a spec.
SkillAFreshness: AClaude Code +9 - 0.565score
algorithm-design
Tuvudel
Design algorithms with LaTeX pseudocode and UML diagrams.
SkillAFreshness: AClaude Code +9 - 0.559score
circles-agent-bridge
Tuvudel
Use when the user's Codex reads, writes, verifies, or discusses agent-to-agent handoffs with a teammate's Codex through the Circles Slack agent bridge.
SkillAFreshness: AClaude Code +9 - 0.559score
circles-hebrew-content
Tuvudel
Use when writing Hebrew-facing Circles text (docs, mockups, dashboards, reports, in-app copy) or presenting dense structured information such as inventories…
SkillAFreshness: AClaude Code +9 - 0.556score
coding-workflow
Tuvudel
Use at the start of, or when switching phase in, any non-trivial engineering task (feature, bug, refactor, review, CI, ship) to pick the specialist skill for…
SkillAFreshness: AClaude Code +9 - 0.556score
check-compiler-errors
Tuvudel
Use after code changes, or when a build or editor shows errors, to run the project's compile and type-check commands and report failures.
SkillAFreshness: AClaude Code +9 - 0.553score
format-first
Tuvudel
Pre-feature formatting workflow to prevent mixed logic/formatting commits and keep git blame clean
SkillAFreshness: AClaude Code +9 - 0.534score
frontend-design
Tuvudel
Create distinctive, production-grade frontend interfaces with high design quality.
SkillAFreshness: AClaude Code +9
Signals
- Stars
- 0
- Forks
- 0
- Open issues
- 0
- Last commit (this folder)
- Oct 19, 2026 (8 days ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/Tuvudel/tuviskills
- 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 Tuvudel
- 0.567score
engineering-companion
Tuvudel
Use alongside coding-workflow when substantive engineering work needs a deeper pstack method (how/why, architect, blast radius, interrogate, project…
SkillAFreshness: AClaude Code +9 - 0.565score
brainstorming
Tuvudel
Use when shaping a new feature or design that still has open questions, before writing a spec.
SkillAFreshness: AClaude Code +9 - 0.565score
algorithm-design
Tuvudel
Design algorithms with LaTeX pseudocode and UML diagrams.
SkillAFreshness: AClaude Code +9 - 0.559score
circles-agent-bridge
Tuvudel
Use when the user's Codex reads, writes, verifies, or discusses agent-to-agent handoffs with a teammate's Codex through the Circles Slack agent bridge.
SkillAFreshness: AClaude Code +9 - 0.559score
circles-hebrew-content
Tuvudel
Use when writing Hebrew-facing Circles text (docs, mockups, dashboards, reports, in-app copy) or presenting dense structured information such as inventories…
SkillAFreshness: AClaude Code +9 - 0.556score
coding-workflow
Tuvudel
Use at the start of, or when switching phase in, any non-trivial engineering task (feature, bug, refactor, review, CI, ship) to pick the specialist skill for…
SkillAFreshness: AClaude Code +9
Cite this page
code-refactoring skill. Agent Mart. https://agentmart.dev/skills/tuvudel-code-refactoring (last updated 2026-10-24)