From agent-core
大きなファイルを責務ごとに分割するリファクタリング。言語不問(Dart, Swift, TypeScript等)。参照の自動修正と検証を含む。Trigger - "ファイル分割", "大きすぎる", "責務分離", "extract", "split file", "ファイルが長い"
How this skill is triggered — by the user, by Claude, or both
Slash command
/agent-core:extractThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
1ファイルに複数の責務が混在している場合に、責務単位で分割する。言語不問。
1ファイルに複数の責務が混在している場合に、責務単位で分割する。言語不問。
/extract # 対話的に対象ファイルを指定
/extract src/app/dashboard.ts # 指定ファイルを分割
$ARGUMENTS で対象ファイルを指定。省略時は AskUserQuestion で確認。
ファイル全体を読み、以下を特定する:
ユーザーに承認を求める。実装前に必ずこの表を提示:
## 分割計画: [元ファイル名] ([総行数]行)
| # | 新ファイル | 移動する要素 | 行数 | 依存 |
|---|----------|------------|------|------|
| 1 | [path] | [class/func名] | ~N行 | なし |
| 2 | [path] | [class/func名] | ~N行 | #1に依存 |
| 3 | [元ファイル(残留)] | [残る要素] | ~N行 | #1,#2をimport |
検証コマンド: [flutter analyze / swift build / tsc --noEmit 等]
承認なしに分割を開始してはならない。
判断に迷う場合(どこで切るか、命名、ディレクトリ構造等)は AskUserQuestion で確認する。
| 言語 | import修正 | アクセス修飾子 | 注意点 |
|---|---|---|---|
| Dart | package: importに統一 | private(_)→publicにする場合は確認 | part/part of は使わない |
| Swift | module内はimport不要 | internal→public が必要な場合あり | @testable import への影響確認 |
| TypeScript | 相対パス or エイリアス | export の追加 | barrel file (index.ts) の更新 |
| その他 | 言語の慣習に従う | — | — |
依存関係の順序で抽出する(依存される側を先に):
ファイル数が多い場合は complex-orchestrator で並列実行。
検証結果?
│
├─ ✅ ビルド成功 ──► 分割結果サマリーを報告。終了
└─ ❌ エラー ─────► 参照漏れを修正(import/export/アクセス修飾子)
検証コマンド例:
flutter analyze / dart analyzeswift build / xcodebuildtsc --noEmit / bun run buildnpx claudepluginhub xmgrex/ccx-arsenal --plugin agent-coreSplits monolithic files over 1000 lines into focused, maintainable modules with import updates and build verification.
Safe multi-file refactoring with automatic rollback: rename, extract, inline, move, split, and merge code while preserving type/test baselines.
Renames, extracts, splits, moves, or restructures code safely using graph-aware impact analysis and automated rename tools. Covers checklists for each refactoring type.