refactoring
Skill1 starsChanged 6 months agoMITView on GitHub
外部から見た振る舞いを変えずにコードの内部構造を改善するスキル。技術的負債の可視化・優先順位付け・計画的返済も含み、開発速度の維持・回復を目的として使う。
39 other projects use a version of this.
Adopted by
Most recently taken up by
- kapadias/nonnatheir own version, first seen Oct 1, 2026
- jablonkai/skillstheir own version, first seen Oct 1, 2026
- fabiandistler/agentstheir own version, first seen Sep 30, 2026
- wormeyman/wormeyman-skillstheir own version, first seen Sep 25, 2026
- dan-the-dev/xp-developer-skillstheir own version, first seen Sep 23, 2026
- syanga/astacktheir own version, first seen Sep 20, 2026
Used with
Projects with it also use performance, ci-cd and 5 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
pluginagentmarketplaceSkillperformance
Optimize application performance through caching strategies, load balancing, database scaling, and monitoring. Build systems handling thousands of concurrent users.
Also in 7 projects that use this
JohnJBorenSkillci-cd
CI/CD pipeline design, GitHub Actions, testing automation, and deployment strategies
Also in 4 projects that use this
MicrosoftSkillerror-handling
统一错误处理系统。在添加 API 端点、修改错误处理、添加前端 API 调用、编写错误相关测试时使用。
Also in 6 projects that use this
AnthropicSkillincident-response
Run an incident response workflow — triage, communicate, and write postmortem. Trigger with "we have an incident", "production is down", an alert that needs severity assessment, a status update mid-incident, or when writing a blameless postmortem after resolution.
Also in 5 projects that use this
OpenAISkillobservability
Vercel Observability expert guidance — Drains (logs, traces, speed insights, web analytics), Web Analytics, Speed Insights, runtime logs, custom events, OpenTelemetry integration, and monitoring dashboards. Use when instrumenting, debugging, or optimizing application performance and user experience on Vercel.
Also in 5 projects that use this
CloudflareSkillsecurity-audit
Security guidance and vulnerability review for codebases, APIs, services, CLI tools, libraries, and daemons. Use for security questions, focused reviews, vulnerability research, security audits, or pen tests. Run the complete workflow only for explicit codebase audit or pen-test requests, full/comprehensive/end-to-end reviews, or requested report artifacts.
Also in 9 projects that use this
Other versions39 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 39
- ciembor/agent-rules-books★ 2.9ksame name
- databrickslabs/ontobricks★ 393same name
- extra-org/extra★ 113same name
- 312362115/claude★ 107same name
- DevelopersGlobal/ai-agent-skills★ 69same name
- andreaswasita/copilot-agents-dojo★ 54same name
- dan-the-dev/xp-developer-skills★ 30same name
- nimadorostkar/Claude-Skills-collection★ 28same name
- krzysztofsurdy/code-virtuoso★ 22same name
- s-hiraoku/synapse-a2a★ 16same name
29 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository42 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- accessibilitySkill
- analytics-kpiSkill
- api-designSkill
- architecture-designSkill
- cicd-deploymentSkill
- codebase-explorationSkill
- code-reviewSkill
- database-designSkill
- debuggingSkill
- decision-makingSkill
- detailed-designSkill
- documentationSkill
- estimationSkill
- git-workflowSkill
- growth-launchSkill
- i18n-localizationSkill
- idea-generationSkill
- implementationSkill
- legal-complianceSkill
- llm-integrationSkill
- market-researchSkill
- microservicesSkill
- mobile-app-releaseSkill
- monetizationSkill
- monitoring-operationsSkill
- mvp-developmentSkill
- non-functional-requirementsSkill
- orchestrationSkill
- performance-optimizationSkill
- project-managementSkill
- requirements-definitionSkill
- screen-designSkill
- securitySkill
- session-handoffSkill
- skill-authoringSkill
- skill-navigatorSkill
- solo-developmentSkill
- task-breakdownSkill
- task-executionSkill
- testingSkill
- ux-researchSkill
The file
Files
リファクタリング・技術的負債管理
目的
- コードの可読性・変更容易性を高め、バグの発生率と修正コストを下げる
- 技術的負債を「見えないコスト」から「管理できるバックログ」に変える
- 機能開発のスピードを中長期で維持する
使うタイミング
- ボーイスカウトルール: 今触っているファイルを、来た時より少し綺麗にして去る
- 道ならし: 機能追加の前に「まず変更しやすくしてから変更する」
- 3回ルール: 同じ場所で3回つまずいたら投資対効果が十分と判断する
- 負債返済スプリント: 開発の2割ルールで定期的に計画に組み込む
- 新機能追加・バグ修正と同じPR/コミットに混ぜない
進め方
- テスト確認: 対象コードにテストがあるか確認する([[testing]])。なければ先に特性テスト(characterization test: 現状の振る舞いをそのまま固定するテスト)を書く
- スコープ確定: 今回触る範囲を小さく区切る。「クラス全体」ではなく「このメソッド群」まで絞る
- 現状計測: 変更前の複雑度・重複率・テストカバレッジを記録する
- 小さいステップで実施: 1変更ごとにテスト実行→グリーン確認→コミット。いつでも中断・巻き戻しできる状態を保つ
- 効果計測: 変更後の複雑度・重複率・変更所要時間を計測し比較する
- 負債登録簿を更新: 返済したものをクローズし、発見した新たな負債を登録する
主要リファクタリングカタログ
| 手法 | 適用場面 |
| 名前変更(変数・関数・クラス) | 意図が伝わらない命名 |
| 関数抽出 | 1関数が複数の責務を持つ、20行超の関数 |
| 重複の除去 | 同じロジックが3箇所以上(ただし早すぎる共通化に注意) |
| 早期return | ネストした条件分岐の平坦化 |
| ポリモーフィズム導入 | 型チェックのswitch/if-elseが複数箇所に散在 |
| クラス分割 | 1クラスが複数の責務を持つ(フィールド数・メソッド数が多い) |
技術的負債の管理
負債の種類と対応方針
- 意図的な負債: 期限前に意識して借りる。必ずその場で登録簿に記録してから借りる
- 偶発的な負債: 設計の理解不足や時間的圧力で生まれる。発見時に登録
- 陳腐化による負債: ライブラリ・言語バージョンの古さ。定期棚卸しで検出
優先度の付け方
「利子」= 放置し続けると毎スプリント払い続けるコストで判断する。
- 高: バグ頻発・レビュー時間増大・新人が触れない → 早期に返済
- 中: コードの理解に時間がかかる → 道ならしとして返済
- 低: 美的な問題 → ボーイスカウトルールで少しずつ
返済の組み込み方
- 2割ルール: スプリント容量の20%を技術的負債返済に割り当てる
- 道ならし返済: 機能Aを追加する前に、関連する負債Bを先に返済してからPRを出す(別PR)
- 返済専用スプリント: 利子が大きい高優先度負債が溜まった場合に設ける
大規模リファクタリング
- ビッグバンを避ける: 数週間続くブランチは作らない
- ストラングラーフィグパターン: 新実装と旧実装を並行稼働させ、段階的に新に切り替える
- フィーチャーフラグ: 切り替えをコードで制御し、問題時は即ロールバック
成果物テンプレート
技術的負債登録簿
# 技術的負債登録簿
最終更新: YYYY-MM-DD
| ID | 負債の内容 | 発生理由 | 利子(困りごと) | 返済コスト見積もり | 優先度 | 状態 |
|----|-----------|---------|----------------|------------------|--------|------|
| TD-001 | UserServiceが認証・通知・課金を全て持つ | MVP時の速度優先 | 変更時に影響範囲が読めずレビューに2時間かかる | L(3d) | 高 | 未着手 |
| TD-002 | 注文計算ロジックが3箇所に重複 | 担当者がコードを知らずコピー | バグ修正時に3箇所直さないといけない | S(0.5d) | 中 | 対応中 |
| TD-003 | テストDBのセットアップが手動 | CI構築を後回しにした | 新メンバーのオンボーディングに1日かかる | M(1d) | 中 | 未着手 |
凡例: コスト S=半日以内 / M=1〜2日 / L=3〜5日 / XL=1週間超チェックリスト
- リファクタリング前にテストがグリーンであることを確認した
- 特性テストを書いた(テストがなかった場合)
- スコープを小さく区切った
- 機能追加・バグ修正と同じコミットに混ぜていない
- ステップごとにテストを実行した
- 変更前後の複雑度・重複率を記録した
- 技術的負債登録簿を更新した(返済完了・新規発見)
アンチパターン
- ビッグバンリファクタリング: 数週間ブランチが返ってこない。コンフリクト地獄になる
- 機能追加との混在PR: レビュアーが振る舞いの変化を見分けられなくなる
- テストなしで着手: 振る舞いを壊したことに気づけない
- 趣味的な書き換え: 動いているコードを好みで書き換えても利子は減らない
- 「いつか直す」と言って記録すらしない: 負債が見えなくなり、利子だけ払い続ける
モデル委譲ガイド
共通原則は [[orchestration]] を参照。
| 役割 | タスク例 |
| 司令塔(メインモデル) | リファクタリング戦略の策定・優先順位の判断・負債登録簿のレビュー・PR分割の決定 |
| Opus相当 | 大規模リファクタリングの設計(ストラングラーフィグ計画・クラス責務の再設計・アーキテクチャ変更を伴う分割) |
| Sonnet相当 | 機械的なリファクタリング実施(名前変更・関数抽出・重複除去)・特性テストの作成・負債登録簿の初期作成 |
| Haiku相当 | 重複コードの検出・複雑度の高い箇所のリストアップ・コードメトリクスの収集 |
関連スキル
- [[testing]] — 特性テスト・リファクタリング後の回帰確認
- [[code-review]] — リファクタリングPRのレビュー観点
- [[architecture-design]] — 大規模リファクタリング時の設計判断
- [[implementation]] — リファクタリングと機能実装の切り分け
- [[git-workflow]] — 小さいステップのコミット戦略・ブランチ管理
- [[performance-optimization]] — パフォーマンス改善目的のリファクタリング
- [[debugging]] — バグの温床となっている技術的負債の特定
- [[orchestration]] — モデル委譲の共通原則
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

