MCP HubMCP Hub
スキル一覧に戻る

refactor-assistant

CuriousLearner
更新日 Today
49 閲覧
16
3
16
GitHubで表示
開発automation

について

リファクタリングアシスタントスキルは、コードを自動分析して、コードスメル、複雑さの問題、SOLID原則違反などのリファクタリング機会を特定します。その後、「メソッドの抽出」「変数の名前変更」「条件分岐のポリモーフィズムへの置き換え」などのパターンを使用した具体的な提案と実装を提供します。このスキルを使用して、コード品質を向上させるための自動化されたエキスパートレベルのリファクタリング提案を受けることができます。

クイックインストール

Claude Code

推奨
プラグインコマンド推奨
/plugin add https://github.com/CuriousLearner/devkit
Git クローン代替
git clone https://github.com/CuriousLearner/devkit.git ~/.claude/skills/refactor-assistant

このコマンドをClaude Codeにコピー&ペーストしてスキルをインストールします

ドキュメント

Refactor Assistant Skill

Automated code refactoring suggestions and implementation.

Instructions

You are a code refactoring expert. When invoked:

  1. Analyze Code: Examine the target code for:

    • Code smells (long functions, duplicate code, large classes)
    • Complexity issues (high cyclomatic complexity)
    • Naming inconsistencies
    • Violation of SOLID principles
    • Performance bottlenecks
    • Security concerns
  2. Identify Patterns: Look for opportunities to apply:

    • Extract Method/Function
    • Extract Class/Module
    • Rename Variable/Function/Class
    • Introduce Parameter Object
    • Replace Conditional with Polymorphism
    • Remove Dead Code
    • Simplify Complex Conditionals
    • Extract Interface
    • Move Method
  3. Propose Changes: For each refactoring opportunity:

    • Explain the current issue
    • Suggest the refactoring pattern
    • Estimate impact (low/medium/high)
    • Identify potential risks
  4. Execute Refactoring: If approved:

    • Make changes incrementally
    • Ensure tests still pass after each change
    • Maintain backward compatibility when possible

Refactoring Priorities

  1. High Priority:

    • Security vulnerabilities
    • Critical performance issues
    • Obvious bugs or error-prone code
  2. Medium Priority:

    • Code duplication
    • Functions longer than 50 lines
    • Classes with too many responsibilities
    • Complex conditionals
  3. Low Priority:

    • Minor naming improvements
    • Formatting inconsistencies
    • Optional type annotations

Usage Examples

@refactor-assistant UserService.js
@refactor-assistant src/
@refactor-assistant --focus complexity
@refactor-assistant --suggest-only

Refactoring Guidelines

  • Safety First: Never change behavior, only structure
  • Test Coverage: Ensure tests exist before refactoring
  • Incremental Changes: Make small, testable changes
  • Preserve Semantics: Keep the same functionality
  • Document Why: Explain the reasoning for changes

Common Refactoring Patterns

Extract Function

// Before
function processOrder(order) {
  // validate order (10 lines)
  // calculate total (15 lines)
  // apply discounts (20 lines)
  // save order (5 lines)
}

// After
function processOrder(order) {
  validateOrder(order);
  const total = calculateTotal(order);
  const discounted = applyDiscounts(order, total);
  saveOrder(order, discounted);
}

Remove Duplication

# Before
def format_user_name(user):
    return f"{user.first_name} {user.last_name}".strip()

def format_admin_name(admin):
    return f"{admin.first_name} {admin.last_name}".strip()

# After
def format_full_name(person):
    return f"{person.first_name} {person.last_name}".strip()

Red Flags to Watch For

  • Functions with more than 4 parameters
  • Nested conditionals (more than 3 levels deep)
  • Classes with more than 10 methods
  • Files longer than 500 lines
  • Cyclomatic complexity > 10
  • Duplicate code blocks
  • Magic numbers or strings
  • Global variables or state

Notes

  • Always run tests after refactoring
  • Get approval before major structural changes
  • Maintain git history (don't squash refactoring commits)
  • Document breaking changes clearly

GitHub リポジトリ

CuriousLearner/devkit
パス: skills/refactor-assistant

関連スキル

content-collections

メタ

This skill provides a production-tested setup for Content Collections, a TypeScript-first tool that transforms Markdown/MDX files into type-safe data collections with Zod validation. Use it when building blogs, documentation sites, or content-heavy Vite + React applications to ensure type safety and automatic content validation. It covers everything from Vite plugin configuration and MDX compilation to deployment optimization and schema validation.

スキルを見る

sglang

メタ

SGLang is a high-performance LLM serving framework that specializes in fast, structured generation for JSON, regex, and agentic workflows using its RadixAttention prefix caching. It delivers significantly faster inference, especially for tasks with repeated prefixes, making it ideal for complex, structured outputs and multi-turn conversations. Choose SGLang over alternatives like vLLM when you need constrained decoding or are building applications with extensive prefix sharing.

スキルを見る

cloudflare-turnstile

メタ

This skill provides comprehensive guidance for implementing Cloudflare Turnstile as a CAPTCHA-alternative bot protection system. It covers integration for forms, login pages, API endpoints, and frameworks like React/Next.js/Hono, while handling invisible challenges that maintain user experience. Use it when migrating from reCAPTCHA, debugging error codes, or implementing token validation and E2E tests.

スキルを見る

Algorithmic Art Generation

メタ

This skill helps developers create algorithmic art using p5.js, focusing on generative art, computational aesthetics, and interactive visualizations. It automatically activates for topics like "generative art" or "p5.js visualization" and guides you through creating unique algorithms with features like seeded randomness, flow fields, and particle systems. Use it when you need to build reproducible, code-driven artistic patterns.

スキルを見る