refactoring
Perform safe structural refactoring with step-by-step validation and dependency audits.
Install
mkdir -p .claude/skills/refactoring-tettuan && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/16477" && unzip -o skill.zip -d .claude/skills/refactoring-tettuan && rm skill.zipInstalls to .claude/skills/refactoring-tettuan
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Use when refactoring code, reorganizing modules, renaming types, deleting old paths, or migrating architecture. MUST read before any structural code change. Prevents incomplete refactoring that silently breaks downstream consumers.Key capabilities
- →Audit existing code for deletion targets and consumers
- →Trace entry, filter, runner, and handler paths for gateways
- →Design verification methods for new paths
- →Execute refactoring in atomic commits
- →Verify the absence of old paths and documentation references
How it works
This skill guides a multi-phase refactoring process, starting with auditing deletion targets and consumers, designing verification, executing changes in atomic commits, and finally verifying the complete removal of old paths and documentation references.
Inputs & outputs
When to use refactoring
- →Rename modules safely
- →Migrate legacy paths
- →Remove dead code after migration
About this skill
新パスが旧パスの全契約を継承したことを証明してから削除する。証明できなければ削除しない。
過去の事故
| 事故 | 原因 |
|---|---|
| ハンドラがthrowスタブ化 | 旧パス削除時に新パス未実装 |
| キャッシュが古いバージョンを返す | --reload 未実行 |
| importエラー | アダプタ未作成でV1 export削除 |
| 設定互換性喪失 | 移行猶予なくレガシーエイリアス削除 |
Phase 1: 棚卸し
- 削除対象の一覧 — 何を削除するか、誰が消費しているか、どのパラメータを受けるかを列挙する
- ゲートウェイ監査 — エントリ→フィルタ→ランナー→ハンドラの経路を追跡し、新パスが全パラメータを通すことを確認する
- 消費者監査 —
grepで全import/呼び出し箇所を特定し、移行先を決める。移行先のない消費者がいれば削除不可
Phase 2: 契約と検証設計
- Before/After表 — 旧パスの各動作に対し、新パスでの実現方法を記述する。After列が空なら未完了
- 検証設計 — パス特性に応じ、直線→コードレビュー / 分岐・フィルタ→自動テスト / 外部依存→E2Eで証明する
Phase 3: 実行
1コミット=1関心事(新パス追加→消費者移行→旧パス削除→docs更新)。各コミットでCI通過必須。デッドコードは同一PRで削除する。
Phase 4: 検証
deno cache --reload <entry-point> # キャッシュクリア
grep -r "OldName" --include='*.ts' | grep -v test # 消費者の残存確認(空であること)
grep -r "OldName" --include='*.md' # docs内の参照確認(空であること)
アンチパターン
| Bad | Good |
|---|---|
| 旧パス削除→新パスは後で | 新パス完成→旧パス削除 |
| 「誰も使ってない」と推測 | grepで消費者を証拠確認 |
| リファクタと機能追加を同一PR | bisect可能に分離 |
関連: /fix-checklist(根本原因分析)、/docs-consistency(Phase 4のdocs更新)
When not to use it
- →Refactoring and feature addition in the same pull request
- →Deleting old paths before new paths are fully implemented
- →Assuming no one is using a piece of code without verification
Limitations
- →MUST read before any structural code change.
- →Prevents incomplete refactoring that silently breaks downstream consumers.
- →Each commit must pass CI.
How it compares
This skill enforces a structured, auditable, and verifiable refactoring workflow, preventing incomplete changes and silent breakage, unlike ad-hoc code modifications.
Compared to similar skills
refactoring side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| refactoring (this skill) | 0 | 6mo | Review | Advanced |
| effective-go | 323 | 10mo | No flags | Beginner |
| solid-principles | 57 | 9mo | No flags | Intermediate |
| typescript-review | 39 | 2mo | No flags | Intermediate |
Try saying
Example prompts that trigger this skill in your AI assistant.
You might also like
effective-go
openshift
Apply Go best practices, idioms, and conventions from golang.org/doc/effective_go. Use when writing, reviewing, or refactoring Go code to ensure idiomatic, clean, and efficient implementations.
solid-principles
SmidigStorm
Enforce SOLID principles (Single Responsibility, Open/Closed, Liskov Substitution, Interface Segregation, Dependency Inversion) in object-oriented design. Use when writing or reviewing classes and modules.
typescript-review
metabase
Review TypeScript and JavaScript code changes for compliance with Metabase coding standards, style violations, and code quality issues. Use when reviewing pull requests or diffs containing TypeScript/JavaScript code.
ast-grep
ast-grep
Guide for writing ast-grep rules to perform structural code search and analysis. Use when users need to search codebases using Abstract Syntax Tree (AST) patterns, find specific code structures, or perform complex code queries that go beyond simple text search. This skill should be used when users ask to search for code patterns, find specific language constructs, or locate code with particular structural characteristics.
serena
massgen
This skill provides symbol-level code understanding and navigation using Language Server Protocol (LSP). Enables IDE-like capabilities for finding symbols, tracking references, and making precise code edits at the symbol level.
typescript
lobehub
TypeScript code style and optimization guidelines. Use when writing TypeScript code (.ts, .tsx, .mts files), reviewing code quality, or implementing type-safe patterns. Triggers on TypeScript development, type safety questions, or code style discussions.