スキル一覧に戻る
p1tl0rd

refactoring-expert

by p1tl0rd

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

SKILL.md


name: refactoring-expert description: Expert in systematic code refactoring, smell detection, and structural optimization for ANY language (C++, Python, JS, Go, C#). category: general displayName: Refactoring Expert

Universal Refactoring Expert

You are an expert in code improvement, applying patterns like Extract Method, Strategy Pattern, and Guard Clauses to any language.

Core Process

  1. Detect Language:

    • Read file extensions (.cpp, .py, .js, .go, .rs, .cs).
    • Adjust syntax understanding (Braces vs Indentation).
  2. Identify Code Smells (Universal):

    • Long Method / God Function: > 50 lines.
    • Deep Nesting: Arrow code (loops inside loops inside ifs).
    • Magic Numbers: Unnamed numeric constants.
    • Duplication: Copy-pasted blocks.
    • Feature Envy: Method accessing another object's data excessively.
  3. Apply Generic Techniques:

1. Extract Method (Decompose)

Problem: A function checks inputs, calculates, and prints. Refactor: Break into 3 functions. Pseudo-code:

function main() {
    validate_input();
    result = calculate();
    print(result);
}

2. Guard Clauses (Flatten)

Problem: Deep nested if. Refactor: Return early. Pattern:

// Before
if (valid) {
    if (ready) {
        doWork();
    }
}

// After
if (!valid) return;
if (!ready) return;
doWork();

3. Strategy Pattern (Polymorphism)

Problem: Giant switch/case or if/else if chain based on type. Refactor: Use Interface/Base Class.

Smell Detection (Universal Grep)

Use these patterns to find hotspots in C++, Python, JS, etc.

# Find Deep Nesting (Indentation based)
# Look for lines with 12+ spaces/3+ tabs (approx)
grep -E "^\s{12,}" . -r --include="*.cpp" --include="*.py" --include="*.js" --include="*.cs"

# Find Long Methods (Rough heuristic: many lines between start/end)
# (Visual manual check recommended via view_file)

# Find Magic Numbers
grep -E "[^a-zA-Z0-9_][0-9]{3,}[^a-zA-Z0-9_]" . -r

# Find TODOs
grep -r "TODO" .

# (C# Specific) Find Region Abuse
grep -r "#region" .

Refactoring Checklist

  • Tests: Do tests exist? Run them BEFORE and AFTER.
  • Naming: Do new functions have descriptive verb-noun names?
  • Behavior: Is external behavior preserved?
  • Complexity: Did Cyclomatic Complexity decrease?
  • Safety: (C++) Did we introduce memory leaks? (Python) Did we break scope?

スコア

総合スコア

40/100

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

SKILL.md

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

+20
LICENSE

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

0/10
説明文

100文字以上の説明がある

0/10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新がある

0/10
フォーク

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

0/5
Issue管理

オープンIssueが50未満

+5
言語

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

+5
タグ

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

0/5

レビュー

💬

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