mcpField
G
gitnexus-refactoring

gitnexus-refactoring

github.com/arenukvern開発39447 回インストール2 週間前に更新
リポジトリ

gitnexus-refactoring について

gitnexus-refactoringは、コードのリファクタリングを計画・実行するGitNexusスキルです。依存関係の分析、段階的な編集、変更確認を通じて、名前変更や抽出、分割を支援します。

主な機能

  1. 01上流依存関係のマッピング
  2. 02実行フローと参照の検索
  3. 03複数ファイルの名前変更をプレビュー・適用
  4. 04変更ファイルと影響を受ける処理の確認
  5. 05リファクタリング用チェックリスト

活用シーン

  1. 01シンボルを複数ファイルで安全に改名
  2. 02コードをモジュールへ抽出
  3. 03関数やサービスを分割
  4. 04リファクタリングの変更範囲を確認

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/arenukvern/mcp_flutter --skill gitnexus-refactoring

インストール後、Claude Code で/gitnexus-refactoringを入力して読み込まれたか確認します。

詳細

GitNexus を使ったリファクタリング

使用する場面

  • 「この関数の名前を安全に変更する」
  • 「これをモジュールとして切り出す」
  • 「このサービスを分割する」
  • 「これを新しいファイルに移動する」
  • コードの名前変更、切り出し、分割、再構成を伴うあらゆるタスク

ワークフロー

1. impact({target: "X", direction: "upstream"})  → Map all dependents
2. query({search_query: "X"})                            → Find execution flows involving X
3. context({name: "X"})                           → See all incoming/outgoing refs
4. Plan update order: interfaces → implementations → callers → tests

「インデックスが古い」と表示された場合 → ターミナルで node .gitnexus/run.cjs analyze を実行してください。

チェックリスト

シンボルの名前変更
- [ ] rename({symbol_name: "oldName", new_name: "newName", dry_run: true}) — preview all edits
- [ ] Review graph edits (high confidence) and text_search edits (review carefully)
- [ ] If satisfied: rename({..., dry_run: false}) — apply edits
- [ ] detect_changes() — verify only expected files changed
- [ ] Run tests for affected processes
モジュールの切り出し
- [ ] context({name: target}) — see all incoming/outgoing refs
- [ ] impact({target, direction: "upstream"}) — find all external callers
- [ ] Define new module interface
- [ ] Extract code, update imports
- [ ] detect_changes() — verify affected scope
- [ ] Run tests for affected processes
関数/サービスの分割
- [ ] context({name: target}) — understand all callees
- [ ] Group callees by responsibility
- [ ] impact({target, direction: "upstream"}) — map callers to update
- [ ] Create new functions/services
- [ ] Update callers
- [ ] detect_changes() — verify affected scope
- [ ] Run tests for affected processes

ツール

rename — 複数ファイルの名前を自動変更します:

rename({symbol_name: "validateUser", new_name: "authenticateUser", dry_run: true})
→ 12 edits across 8 files
→ 10 graph edits (high confidence), 2 text_search edits (review)
→ Changes: [{file_path, edits: [{line, old_text, new_text, confidence}]}]

impact — まずすべての依存先をマッピングします:

impact({target: "validateUser", direction: "upstream"})
→ d=1: loginHandler, apiMiddleware, testUtils
→ Affected Processes: LoginFlow, TokenRefresh

detect_changes — リファクタリング後に変更を検証します:

detect_changes({scope: "all"})
→ Changed: 8 files, 12 symbols
→ Affected processes: LoginFlow, TokenRefresh
→ Risk: MEDIUM

cypher — カスタム参照クエリ:

MATCH (caller)-[:CodeRelation {type: 'CALLS'}]->(f:Function {name: "validateUser"})
RETURN caller.name, caller.filePath ORDER BY caller.filePath

リスクに関するルール

リスク要因対策
呼び出し元が多い(>5)自動更新には rename を使用します
領域をまたぐ参照スコープの検証に、後から detect_changes を使用します
文字列/動的な参照見つけるには query を使用します
外部/パブリック API適切にバージョン管理し、非推奨にします

例:validateUser を authenticateUser に名前変更する

1. rename({symbol_name: "validateUser", new_name: "authenticateUser", dry_run: true})
   → 12 edits: 10 graph (safe), 2 text_search (review)
   → Files: validator.ts, login.ts, middleware.ts, config.json...

2. Review text_search edits (config.json: dynamic reference!)

3. rename({symbol_name: "validateUser", new_name: "authenticateUser", dry_run: false})
   → Applied 12 edits across 8 files

4. detect_changes({scope: "all"})
   → Affected: LoginFlow, TokenRefresh
   → Risk: MEDIUM — run tests for these flows

コメント