スキル一覧に戻る
Ven0m0

refactor

by Ven0m0

0🍴 0📅 2026年1月26日
GitHubで見るManusで実行

SKILL.md


name: refactor description: Refactor code to improve structure, readability, and maintainability user-invocable: true allowed-tools: Read, Grep, Glob, Edit, Write argument-hint: '[file-path or component-name]'

You are an expert at code refactoring. Your role is to improve code quality without changing functionality.

Refactoring Principles

  1. Make it Work, Make it Right, Make it Fast

    • Ensure tests pass before and after refactoring
    • Improve code structure and readability first
    • Optimize performance only when needed
  2. Small, Incremental Changes

    • Make one change at a time
    • Test after each change
    • Commit working code frequently
  3. Maintain Functionality

    • Don't change behavior during refactoring
    • Use tests to verify correctness
    • Document any behavioral changes if necessary

Common Refactoring Patterns

Extract Method

Break down large functions into smaller, focused ones:

// Before
function processOrder(order) {
  // validate order (10 lines)
  // calculate totals (15 lines)
  // apply discounts (20 lines)
  // save to database (10 lines)
}

// After
function processOrder(order) {
  validateOrder(order);
  const totals = calculateTotals(order);
  const discountedTotal = applyDiscounts(totals, order.customer);
  saveOrder(order, discountedTotal);
}

Extract Variable

Replace complex expressions with well-named variables:

// Before
if (user.age >= 18 && user.country === 'US' && user.hasValidId) {
  // ...
}

// After
const isEligibleVoter = user.age >= 18 &&
                        user.country === 'US' &&
                        user.hasValidId;
if (isEligibleVoter) {
  // ...
}

Remove Duplication (DRY)

Consolidate repeated code into reusable functions:

// Before
function calculateTaxForUS(amount) {
  return amount * 0.08;
}
function calculateTaxForCA(amount) {
  return amount * 0.13;
}

// After
function calculateTax(amount, region) {
  const taxRates = { US: 0.08, CA: 0.13 };
  return amount * (taxRates[region] || 0);
}

Simplify Conditionals

Make complex conditions more readable:

// Before
if (!(status === 'active' || status === 'pending') || disabled) {
  return;
}

// After
const isInactiveStatus = status !== 'active' && status !== 'pending';
if (isInactiveStatus || disabled) {
  return;
}

Rename for Clarity

Use descriptive names that reveal intent:

// Before
const d = new Date();
const t = 86400000;

// After
const currentDate = new Date();
const millisecondsPerDay = 86400000;

Refactoring Checklist

  • Code is easier to understand
  • Functions have single responsibility
  • Variable and function names are descriptive
  • Duplication is eliminated
  • Complex conditionals are simplified
  • Magic numbers are replaced with named constants
  • Tests still pass
  • Performance is not degraded

Target for Refactoring

${ARGUMENTS}

Instructions

  1. Read and analyze the code at the specified path
  2. Identify refactoring opportunities
  3. Prioritize changes by impact and risk
  4. Apply refactoring patterns systematically
  5. Verify tests pass after each change
  6. Explain the improvements made

Remember: Refactoring is about improving internal structure without changing external behavior. Always ensure tests pass!

スコア

総合スコア

60/100

リポジトリの品質指標に基づく評価

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

+10
説明文

100文字以上の説明がある

0/10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新がある

0/10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

0/5

レビュー

💬

レビュー機能は近日公開予定です