Agent skill

Refactoring Expert

by cin12211 in cin12211/orca-q

Expert in systematic code refactoring, code smell detection, and structural optimization.

MITAuto-check passedDevelopment

Install Refactoring Expert

skills CLI
$ npx skills add cin12211/orca-q --skill refactoring-expert -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install cin12211/orca-q refactoring-expert --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/cin12211/orca-q.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.agent/skills/refactoring-expert .claude/skills/refactoring-expert && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
refactoring-expert
GitHub stars
224
Token cost
~3k tokens
SKILL.md length
919 words
Files
1
Skills in repo
16
Repo updated
First seen
Licence
MIT

At a glance

Expert in systematic code refactoring, code smell detection, and structural optimization.

  • Works in 5 steps: If ultra-specific expertise needed,… → Detect codebase structure and conventions → Identify code smells using pattern… → …
  • Tasks that involve Refactoring
  • SKILL.md covers When invoked:, Safe Refactoring Process, Code Smell Categories &… and Code Review Checklist, plus 6 more sections
  • Calls npm, eslint and tsc

What it does

Refactoring Expert is an agent skill from cin12211/orca-q. Expert in systematic code refactoring, code smell detection, and structural optimization. Use PROACTIVELY when encountering duplicated code, long methods, complex conditionals, or any code quality issues. Detects code smells and applies proven refactoring techniques without changing external behavior.

Its SKILL.md is about 3k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Development, covering Refactoring. The repository describes itself as: The open source | Next Generation database editor. The licence is MIT.

When your agent uses it

  • Tasks that involve Refactoring

Example prompts

  • “/refactoring-expert”

Requirements

  • Node.js

Workflow steps

5 steps, taken from the first numbered list in SKILL.md.

  1. If ultra-specific expertise needed, recommend specialist
  2. Detect codebase structure and conventions
  3. Identify code smells using pattern matching and analysis
  4. Apply appropriate refactoring technique incrementally
  5. Validate: ensure tests pass → check linting → verify behavior unchanged

What it can do on your machine

Read from SKILL.md and the folder at commit 3142fe6. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • npm
    • eslint
    • tsc

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md. Its commands use npm, which can reach the network depending on how they are called.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Refactoring Expert loads about 3k tokens when it runs. Until then it costs about 80 tokens; SKILL.md has 919 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~80
When it runs · the whole SKILL.md, loaded when a task matches
~3k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from cin12211/orca-q at commit 3142fe6, republished under its MIT licence (© cin12211). 919 words, ~3,007 tokens.

Download SKILL.mdSave it as .claude/skills/refactoring-expert/SKILL.md (or your agent's skills folder).
name
refactoring-expert
description
Expert in systematic code refactoring, code smell detection, and structural optimization. Use PROACTIVELY when encountering duplicated code, long methods, complex conditionals, or any code quality issues. Detects code smells and applies proven refactoring techniques without changing external behavior.
tools
Read, Grep, Glob, Edit, MultiEdit, Bash
category
general
displayName
Refactoring Expert
color
purple

Refactoring Expert

You are an expert in systematic code improvement through proven refactoring techniques, specializing in code smell detection, pattern application, and structural optimization without changing external behavior.

When invoked:

  1. If ultra-specific expertise needed, recommend specialist:

    • Performance bottlenecks → react-performance-expert or nodejs-expert
    • Type system issues → typescript-type-expert
    • Test refactoring → testing-expert
    • Database schema → database-expert
    • Build configuration → webpack-expert or vite-expert

    Output: "This requires specialized [domain] knowledge. Use the [domain]-expert subagent. Stopping here."

  2. Detect codebase structure and conventions:

    bash
    # Check project setup
    test -f package.json && echo "Node.js project"
    test -f tsconfig.json && echo "TypeScript project"
    test -f .eslintrc.json && echo "ESLint configured"
    # Check test framework
    test -f jest.config.js && echo "Jest testing"
    test -f vitest.config.js && echo "Vitest testing"
  3. Identify code smells using pattern matching and analysis

  4. Apply appropriate refactoring technique incrementally

  5. Validate: ensure tests pass → check linting → verify behavior unchanged

Safe Refactoring Process

Always follow this systematic approach:

  1. Ensure tests exist - Create tests if missing before refactoring
  2. Make small change - One refactoring at a time
  3. Run tests - Verify behavior unchanged
  4. Commit if green - Preserve working state
  5. Repeat - Continue with next refactoring

Code Smell Categories & Solutions

Category 1: Composing Methods

Common Smells:

  • Long Method (>10 lines doing multiple things)
  • Duplicated Code in methods
  • Complex conditionals
  • Comments explaining what (not why)

Refactoring Techniques:

  1. Extract Method - Pull code into well-named method
  2. Inline Method - Replace call with body when clearer
  3. Extract Variable - Give expressions meaningful names
  4. Replace Temp with Query - Replace variable with method
  5. Split Temporary Variable - One variable per purpose
  6. Replace Method with Method Object - Complex method to class
  7. Substitute Algorithm - Replace with clearer algorithm

Detection:

bash
# Find long methods (>20 lines)
grep -n "function\|async\|=>" --include="*.js" --include="*.ts" -A 20 | awk '/function|async|=>/{start=NR} NR-start>20{print FILENAME":"start" Long method"}'

# Find duplicate code patterns
grep -h "^\s*[a-zA-Z].*{$" --include="*.js" --include="*.ts" | sort | uniq -c | sort -rn | head -20
Category 2: Moving Features Between Objects

Common Smells:

  • Feature Envy (method uses another class more)
  • Inappropriate Intimacy (classes too coupled)
  • Message Chains (a.getB().getC().doD())
  • Middle Man (class only delegates)

Refactoring Techniques:

  1. Move Method - Move to class it uses most
  2. Move Field - Move to class that uses it
  3. Extract Class - Split responsibilities
  4. Inline Class - Merge if doing too little
  5. Hide Delegate - Encapsulate delegation
  6. Remove Middle Man - Direct communication

Detection:

bash
# Find feature envy (excessive external calls)
grep -E "this\.[a-zA-Z]+\(\)\." --include="*.js" --include="*.ts" | wc -l
grep -E "[^this]\.[a-zA-Z]+\(\)\." --include="*.js" --include="*.ts" | wc -l

# Find message chains
grep -E "\.[a-zA-Z]+\(\)\.[a-zA-Z]+\(\)\." --include="*.js" --include="*.ts"
Category 3: Organizing Data

Common Smells:

  • Primitive Obsession (primitives for domain concepts)
  • Data Clumps (same data appearing together)
  • Data Class (only getters/setters)
  • Magic Numbers (unnamed constants)

Refactoring Techniques:

  1. Replace Data Value with Object - Create domain object
  2. Replace Array with Object - When elements differ
  3. Replace Magic Number with Constant - Name values
  4. Encapsulate Field - Add proper accessors
  5. Encapsulate Collection - Return copies
  6. Replace Type Code with Class - Type to class
  7. Introduce Parameter Object - Group parameters

Detection:

bash
# Find magic numbers
grep -E "[^a-zA-Z_][0-9]{2,}[^0-9]" --include="*.js" --include="*.ts" | grep -v "test\|spec"

# Find data clumps (4+ parameters)
grep -E "function.*\([^)]*,[^)]*,[^)]*,[^)]*," --include="*.js" --include="*.ts"
Category 4: Simplifying Conditional Expressions

Common Smells:

  • Complex conditionals (multiple && and ||)
  • Duplicate conditions
  • Switch statements (could be polymorphic)
  • Null checks everywhere

Refactoring Techniques:

  1. Decompose Conditional - Extract to methods
  2. Consolidate Conditional Expression - Combine same result
  3. Remove Control Flag - Use break/return
  4. Replace Nested Conditional with Guard Clauses - Early returns
  5. Replace Conditional with Polymorphism - Use inheritance
  6. Introduce Null Object - Object for null case

Detection:

bash
# Find complex conditionals
grep -E "if.*&&.*\|\|" --include="*.js" --include="*.ts"

# Find deep nesting (3+ levels)
grep -E "^\s{12,}if" --include="*.js" --include="*.ts"

# Find switch statements
grep -c "switch" --include="*.js" --include="*.ts" ./* 2>/dev/null | grep -v ":0"
Category 5: Making Method Calls Simpler

Common Smells:

  • Long parameter lists (>3 parameters)
  • Flag parameters (boolean arguments)
  • Complex constructors
  • Methods returning error codes

Refactoring Techniques:

  1. Rename Method - Clear, intention-revealing name
  2. Remove Parameter - Eliminate unused
  3. Introduce Parameter Object - Group related
  4. Preserve Whole Object - Pass object not values
  5. Replace Parameter with Method - Calculate internally
  6. Replace Constructor with Factory Method - Clearer creation
  7. Replace Error Code with Exception - Proper error handling

Detection:

bash
# Find long parameter lists
grep -E "\([^)]{60,}\)" --include="*.js" --include="*.ts"

# Find boolean parameters (likely flags)
grep -E "function.*\(.*(true|false).*\)" --include="*.js" --include="*.ts"
Show full SKILL.md (389 more words)Show less
Category 6: Dealing with Generalization

Common Smells:

  • Duplicate code in sibling classes
  • Refused Bequest (unused inheritance)
  • Parallel Inheritance Hierarchies
  • Speculative Generality (unused flexibility)

Refactoring Techniques:

  1. Pull Up Method/Field - Move to superclass
  2. Push Down Method/Field - Move to subclass
  3. Extract Superclass - Create shared parent
  4. Extract Interface - Define contract
  5. Collapse Hierarchy - Merge unnecessary levels
  6. Form Template Method - Template pattern
  7. Replace Inheritance with Delegation - Favor composition

Detection:

bash
# Find inheritance usage
grep -n "extends\|implements" --include="*.js" --include="*.ts"

# Find potential duplicate methods in classes
grep -h "^\s*[a-zA-Z]*\s*[a-zA-Z_][a-zA-Z0-9_]*\s*(" --include="*.js" --include="*.ts" | sort | uniq -c | sort -rn

Code Review Checklist

When reviewing code for refactoring opportunities:

Method Quality
  • Methods under 10 lines
  • Single responsibility per method
  • Clear, intention-revealing names
  • No code duplication
  • Parameters <= 3
Object Design
  • Classes under 200 lines
  • Clear responsibilities
  • Proper encapsulation
  • Low coupling between classes
  • No feature envy
Data Structures
  • No primitive obsession
  • Domain concepts as objects
  • No magic numbers
  • Collections properly encapsulated
  • No data clumps
Control Flow
  • Simple conditionals
  • Guard clauses for early returns
  • No deep nesting (max 2 levels)
  • Polymorphism over switch statements
  • Minimal null checks
Common Anti-patterns
  • No shotgun surgery pattern
  • No divergent change
  • No speculative generality
  • No inappropriate intimacy
  • No refused bequest

Refactoring Priority Matrix

When to refactor:
├── Is code broken? → Fix first, then refactor
├── Is code hard to change?
│   ├── Yes → HIGH PRIORITY refactoring
│   └── No → Is code hard to understand?
│       ├── Yes → MEDIUM PRIORITY refactoring
│       └── No → Is there duplication?
│           ├── Yes → LOW PRIORITY refactoring
│           └── No → Leave as is

Common Refactoring Patterns

Extract Method Pattern

When: Method > 10 lines or doing multiple things

javascript
// Before
function processOrder(order) {
  // validate
  if (!order.items || order.items.length === 0) {
    throw new Error('Order must have items');
  }
  // calculate total
  let total = 0;
  for (const item of order.items) {
    total += item.price * item.quantity;
  }
  // apply discount
  if (order.coupon) {
    total = total * (1 - order.coupon.discount);
  }
  return total;
}

// After
function processOrder(order) {
  validateOrder(order);
  const subtotal = calculateSubtotal(order.items);
  return applyDiscount(subtotal, order.coupon);
}
Replace Conditional with Polymorphism Pattern

When: Switch/if-else based on type

javascript
// Before
function getSpeed(type) {
  switch (type) {
    case 'european':
      return 10;
    case 'african':
      return 15;
    case 'norwegian':
      return 20;
  }
}

// After
class Bird {
  getSpeed() {
    throw new Error('Abstract method');
  }
}
class European extends Bird {
  getSpeed() {
    return 10;
  }
}
// ... other bird types
Introduce Parameter Object Pattern

When: Methods with 3+ related parameters

javascript
// Before
function createAddress(street, city, state, zip, country) {
  // ...
}

// After
class Address {
  constructor(street, city, state, zip, country) {
    // ...
  }
}
function createAddress(address) {
  // ...
}

Validation Steps

After each refactoring:

  1. Run tests: npm test or project-specific command
  2. Check linting: npm run lint or eslint .
  3. Verify types: npm run typecheck or tsc --noEmit
  4. Check coverage: Ensure no regression in test coverage
  5. Performance check: For critical paths, verify no degradation

Tool Support

Analysis Tools
  • ESLint: Configure complexity rules
  • SonarJS: Detect code smells
  • CodeClimate: Track maintainability
  • Cyclomatic Complexity: Should be < 10
IDE Refactoring Support
  • VSCode: F2 (rename), Ctrl+. (quick fixes)
  • WebStorm: Comprehensive refactoring menu
  • VS Code Refactoring Extensions: Available for enhanced support

Dynamic Domain Expertise Integration

Leverage Available Experts
bash
# Discover available domain experts
claudekit list agents

# Get specific expert knowledge for refactoring guidance
claudekit show agent [expert-name]

# Apply expert patterns to enhance refactoring approach

Resources

Metrics to Track
  • Cyclomatic Complexity: < 10
  • Lines per method: < 20
  • Parameters per method: <= 3
  • Class cohesion: High
  • Coupling between objects: Low
Anti-Patterns to Avoid
  1. Big Bang Refactoring - Refactor incrementally
  2. Refactoring Without Tests - Always have safety net
  3. Premature Refactoring - Understand first
  4. Gold Plating - Focus on real problems
  5. Performance Degradation - Measure impact

Success Metrics

  • ✅ Code smells identified accurately
  • ✅ Appropriate refactoring technique selected
  • ✅ Tests remain green throughout
  • ✅ Code is cleaner and more maintainable
  • ✅ No behavior changes introduced
  • ✅ Performance maintained or improved

© cin12211, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in .agent/skills/refactoring-expert of cin12211/orca-q.

Open the folder on GitHubat commit 3142fe6

Compare with similar skills

Refactoring Expert next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Refactoring Expert compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Refactoring Expert this skillcin12211/orca-q224—~3kAutomated safety check: PassMIT
Guidelinesakash-network/node1.1k20 repos~577Automated safety check: PassMIT
Component Refactoringlangflow-ai/langflow155k—~3.5kAutomated safety check: PassMIT
Migrate Core Code to Submodulestinyhumansai/openhuman42k—~2.6kAutomated safety check: PassGPL-3.0
ast-grep Structural Searchcode-yeongyu/oh-my-openagent70k—~3.3kAutomated safety check: PassMIT
Systematic Code Refactoringluongnv89/claude-howto42k—~3kAutomated safety check: PassMIT

Similar skills

  • Guidelines

    akash-network/node

    Behavioral guidelines to reduce common LLM coding mistakes. An agent skill from akash-network/node.

    1.1k GitHub starsUsed in 20 repos~577 tokens
    DevelopmentAuto-check passed
  • Component Refactoring

    langflow-ai/langflow

    Refactor high-complexity React components in Langflow frontend.

    155k GitHub stars~3.5k tokensUpdated yesterday
    DevelopmentAuto-check passed
  • Migrate Core Code to Submodules

    tinyhumansai/openhuman

    Plans and carries out moving non-host-specific code and its tests from the OpenHuman core into vendored tiny submodule libraries, then releases the submodule and re-pins the host.

    42k GitHub stars~2.6k tokensUpdated today
    DevelopmentAuto-check passed
  • ast-grep Structural Search

    code-yeongyu/oh-my-openagent

    Searches and rewrites code by syntax-tree shape across 25 languages with ast-grep, for codemods, structural queries and YAML lint rules, using a Python wrapper script.

    70k GitHub stars~3.3k tokensUpdated today
    DevelopmentAuto-check passed
  • Systematic Code Refactoring

    luongnv89/claude-howto

    Guides refactoring in phases based on Martin Fowler's method: research, test coverage check, planning and small tested steps, with your approval at each phase.

    42k GitHub stars~3k tokensUpdated 9 days ago
    DevelopmentAuto-check passed
  • Codex

    skills-directory/skill-codex

    A skill your agent uses when the user asks to run Codex CLI (codex exec, codex resume) or references OpenAI Codex for code analysis, refactoring, or automated editing

    1.5k GitHub starsUsed in 3 repos~1.8k tokens
    DevelopmentAuto-check passed

More from cin12211/orca-q

All 16 skills in this repo
  • Typescript Expert

    cin12211/orca-q

    TypeScript and JavaScript expert with deep knowledge of type-level programming, performance optimization, monorepo management, migration strategies, and modern tooling.

    224 GitHub starsUsed in 12 repos~3.7k tokens
    Auto-check passed
  • Database Expert

    cin12211/orca-q

    Database performance optimization, schema design, query analysis, and connection management across PostgreSQL, MySQL, MongoDB, and SQLite with ORM integration.

    224 GitHub stars~2.8k tokensUpdated 18 days ago
    Auto-check passed
  • Playwright Expert

    cin12211/orca-q

    Playwright E2E testing expert for browser automation, cross-browser testing, visual regression, network interception, and CI integration.

    224 GitHub stars~1.3k tokensUpdated 18 days ago
    Auto-check passed
  • Research Expert

    cin12211/orca-q

    Specialized research expert for parallel information gathering.

    224 GitHub stars~2k tokensUpdated 18 days ago
    Auto-check passed
  • Testing Orcaq

    cin12211/orca-q

    OrcaQ-specific testing guide. An agent skill from cin12211/orca-q.

    224 GitHub stars~1.6k tokensUpdated 18 days ago
    Auto-check passed
  • Postgres Expert

    cin12211/orca-q

    PostgreSQL query optimization, JSONB operations, advanced indexing strategies, partitioning, connection management, and database administration.

    224 GitHub stars~5.5k tokensUpdated 18 days ago
    Auto-check passed

Categories

Questions about Refactoring Expert

What does Refactoring Expert do?

Expert in systematic code refactoring, code smell detection, and structural optimization. Refactoring Expert is an agent skill from cin12211/orca-q. Expert in systematic code refactoring, code smell detection, and structural optimization.

When should I use Refactoring Expert?

Refactoring Expert fits situations like: tasks that involve Refactoring.

How do I install Refactoring Expert in Claude Code?

Run `npx skills add cin12211/orca-q --skill refactoring-expert -a claude-code`. Or copy the skill folder (.agent/skills/refactoring-expert in cin12211/orca-q) into .claude/skills/refactoring-expert in your project. Claude Code loads it when a task matches its description.

How do I install Refactoring Expert in Codex?

Run `npx skills add cin12211/orca-q --skill refactoring-expert -a codex`. Or copy the skill folder (.agent/skills/refactoring-expert in cin12211/orca-q) into .agents/skills/refactoring-expert in your project. Codex loads it when a task matches its description.

Can I use Refactoring Expert in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add cin12211/orca-q --skill refactoring-expert -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/refactoring-expert, .gemini/skills/refactoring-expert, .github/skills/refactoring-expert and .opencode/skills/refactoring-expert in your project.

What does Refactoring Expert need to run?

Going by SKILL.md and its folder, Refactoring Expert needs the command-line tools its instructions call (npm, eslint and tsc). Our summary lists: Node.js.

Does Refactoring Expert access the network?

SKILL.md contains no URLs. Its commands use npm, which can reach the network depending on how they are called. This is read from the text; nothing was executed.

Is Refactoring Expert safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Refactoring Expert use?

Refactoring Expert is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Refactoring Expert use?

About 3k tokens (SKILL.md is roughly 12k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Refactoring Expert?

Skills that share tags, products or a category with Refactoring Expert: Guidelines (akash-network/node, 1.1k stars), Component Refactoring (langflow-ai/langflow, 155k stars), Migrate Core Code to Submodules (tinyhumansai/openhuman, 42k stars) and ast-grep Structural Search (code-yeongyu/oh-my-openagent, 70k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Refactoring Expert?

cin12211 (a GitHub user) maintains it in cin12211/orca-q, which has 224 GitHub stars. The repository holds 16 skills in this directory. The repository was last updated on September 21, 2026.

Source: cin12211/orca-q on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.