skills/safe-refactoring/SKILL.md
コードスメルの検出、安全なリファクタリング手順の設計、レガシーコード改善を行う。 リファクタリング計画の作成、テストなしコードの段階的改善、Tidy First?による日常的な整頓、 大規模リファクタリング戦略の選定が必要な場合に使用する。
npx skillsauth add togswr/agent-skills safe-refactoringInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
権威ある書籍に基づいた安全なリファクタリングの原則と手法。状況に応じた判断フローで適切なアプローチを選択する。
"Refactoring is a disciplined technique for restructuring an existing body of code, altering its internal structure without changing its external behavior." — Martin Fowler
リファクタリングと機能追加を同時に行わない。
| 帽子 | 目的 | テスト | |-----|------|-------| | リファクタリング | 構造改善 | 既存テストが通り続ける | | 機能追加 | 振る舞い変更 | 新しいテストを追加 |
頻繁に帽子を切り替えるが、同時には被らない。
templates/characterization-test.md)リファクタリング作業を始める前に、以下のフローで適切なアプローチを選択する。
テストがあるか?
├─ Yes → 変更規模は?
│ ├─ 小さい整頓(数分〜1時間)→ 「Tidy First? アプローチ」へ
│ ├─ 中規模の改善(数日) → 「通常リファクタリング」へ
│ └─ 大規模な移行(数週間〜) → 「大規模リファクタリング戦略」へ
└─ No → 「レガシーコード対応」へ(まずテストを配置する)
コードスメル(問題の兆候)が見つかったら references/code-smells.md で該当するスメルを特定し、推奨される対策リファクタリングを references/refactoring-catalog.md で確認する。
テストが存在する状態で行う標準的なリファクタリング。タイミングに応じて4種類に分かれる。
具体的なリファクタリング手法は references/refactoring-catalog.md を参照。
小さな整頓(Tidying)をいつ行うかの判断フレームワーク。
| 選択 | 判断基準 | |------|---------| | First | 整頓で直後の変更が著しく容易になる場合 | | After | 変更後に構造改善の機会が見える場合 | | Later | 今は価値がないが将来的に有益な場合 | | Never | コストが利益を上回る場合 |
"Structure changes are reversible. Behavior changes are not." — Kent Beck
15のTidyingsの詳細と経済的判断基準は references/tidy-first.md を参照。
"Legacy code is simply code without tests." — Michael Feathers
テストのないコードを変更する手順(Legacy Code Change Algorithm):
レガシーコードを直接変更せず、安全に拡張する手法:
| パターン | 用途 | |---------|------| | Sprout Method | 新機能を新メソッドとして追加 | | Sprout Class | 新機能を新クラスとして追加 | | Wrap Method | 既存メソッドをラップして前後に処理追加 | | Wrap Class | Decoratorパターンで拡張 |
依存関係解消テクニック、Seamsの詳細は references/legacy-techniques.md を参照。
特性テスト作成の手順は templates/characterization-test.md を参照。
| パターン | 用途 | 時間目安 | |---------|------|---------| | Boy Scout Rule | 小さなコード改善 | 数分 | | Branch by Abstraction | モジュール/ライブラリの置き換え | 数日〜数週間 | | Parallel Change | API変更(後方互換性必要) | 数週間 | | Strangler Fig | レガシーシステム全体の置き換え | 数ヶ月 |
各パターンの詳細と適用手順は references/large-scale-refactoring.md を参照。
testing
テスト設計・レビュー・改善を、観測可能な振る舞いと決定性を軸に実行する。 テスト戦略の再設計、フレーキー修正、テストダブル方針の整理、回帰防止強化が必要な依頼で使用する。
development
Maintainer-only workflow for handling GitHub Secret Scanning alerts on OpenClaw. Use when Codex needs to triage, redact, clean up, and resolve secret leakage found in issue comments, issue bodies, PR comments, or other GitHub content.
development
Maintainer workflow for OpenClaw releases, prereleases, changelog release notes, and publish validation. Use when Codex needs to prepare or verify stable or beta release steps, align version naming, assemble release notes, check release auth requirements, or validate publish-time commands and artifacts.
development
Run, watch, debug, and extend OpenClaw QA testing with qa-lab and qa-channel. Use when Codex needs to execute the repo-backed QA suite, inspect live QA artifacts, debug failing scenarios, add new QA scenarios, or explain the OpenClaw QA workflow. Prefer the live OpenAI lane with regular openai/gpt-5.4 in fast mode; do not use gpt-5.4-pro or gpt-5.4-mini unless the user explicitly overrides that policy.