Back to list
Row0902

refactor-large-file

by Row0902

0🍴 0📅 Jan 21, 2026

SKILL.md


name: Refactor Large File description: Strategy for splitting files >300 lines into cohesive sub-modules.

✂️ Refactoring Skill: Splitting Large Files

Context

Files exceeding 300 lines violate SRP and become hard to maintain. This skill systematically breaks them down.

Steps

  1. Analyze Responsibilities:

    • Identify distinct clusters of logic (e.g., UI Components vs Event Handlers vs Helper Functions).
    • Use view_file_outline to visualize class/function groups.
  2. Create Package Structure:

    • If module.py is the target:
      mkdir module_pkg
      mv module.py module_pkg/__init__.py
      
    • Or prefer creating specific files: helpers.py, constants.py, types.py.
  3. Move & Isolate:

    • Move code chunks to new files.
    • CRITICAL: Ensure imports in new files are correct.
    • CRITICAL: Re-export moved classes in __init__.py to maintain backward compatibility if needed, OR update all consumers (preferred).
  4. Verify:

    • Run uv run pytest immediately.
    • Check for circular imports (common risk).

Example Command Sequence

# 1. Create sub-modules
New-Item -Path "src/core/complex_module/types.py" -Force
New-Item -Path "src/core/complex_module/logic.py" -Force

# 2. Update __init__.py to export public API
echo "from .types import *" > src/core/complex_module/__init__.py
echo "from .logic import *" >> src/core/complex_module/__init__.py

Score

Total Score

35/100

Based on repository quality metrics

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
言語

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

0/5
タグ

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

0/5

Reviews

💬

Reviews coming soon