Borrowing it
Nothing to install: this file belongs to Kewton/CommandMate. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.
curl -O https://raw.githubusercontent.com/Kewton/CommandMate/main/.claude/commands/refactoring.mdgit clone --depth 1 https://github.com/Kewton/CommandMateWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/commands/kewton/commandmate/refactoring)<a href="https://agentmods.dev/commands/kewton/commandmate/refactoring"><img src="https://agentmods.dev/badge/commands/kewton/commandmate/refactoring/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/commands/kewton/commandmate/refactoring"><img src="https://agentmods.dev/badge/commands/kewton/commandmate/refactoring.svg" alt="Reviewed on agentmods" width="80" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00020 | $0.00825 |
| Opus 5.5 | $0.00008 | $0.00330 |
| Sonnet 5.5 | $0.00004 | $0.00165 |
| Haiku 4.5 | $0.00002 | $0.00082 |
Grade B, and why
refactoring scanned grade B with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 1mo ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Reads agent configuration directoriesmediumAgent snooping
.claude/, .codex/, .gemini/ hold keys, settings and other credentials a mod has no legitimate need for.
cat .claude/prompts/refactoring-core.md What it actually says
リファクタリングスキル
概要
コード品質を改善し、SOLID原則に基づく設計パターンを適用して、技術的負債を解消するスキルです。
このスキルはスラッシュコマンドモードで動作します(ユーザーが直接実行)。
使用方法
/refactoring [対象ファイル/クラス]- 「[ファイル名]をリファクタリングしてください」
- 「コンポーネントを分割してください」
実行内容
共通プロンプトを読み込んで実行します:
cat .claude/prompts/refactoring-core.md
↑ このプロンプトの内容に従って、リファクタリングを実行してください。
動作モード
スラッシュコマンドモード:
- ユーザーから対話的に情報を取得
- リファクタリング対象、改善目標、適用パターンなどを確認
- コード品質分析を実行
- リファクタリングを段階的に適用
- 結果をターミナルに表示
リファクタリング原則
- SOLID: Single Responsibility, Open/Closed, Liskov Substitution, Interface Segregation, Dependency Inversion
- KISS: Keep It Simple, Stupid
- DRY: Don't Repeat Yourself
- YAGNI: You Aren't Gonna Need It
リファクタリングパターン
メソッド抽出
長いメソッドを小さなメソッドに分割
クラス抽出
大きなクラスを責任ごとに分割
重複コード削除
共通処理を関数/クラスに抽出
命名改善
意図を明確に表す命名に変更
設計パターン適用
- Repository Pattern
- Factory Pattern
- Strategy Pattern
- Dependency Injection
完了条件
以下をすべて満たすこと:
- すべてのテストが引き続き成功
- 品質メトリクスが改善(カバレッジ、複雑度)
- 静的解析エラーがゼロ
- コミットが完了
出力例
リファクタリング完了
## リファクタリング内容
- 長いメソッドの分割
- 重複コードの削除
- 命名の改善
## 品質メトリクス改善
| 指標 | Before | After | 改善 |
|------|--------|-------|------|
| Coverage | 75.0% | 85.0% | +10.0% |
| ESLint errors | 5 | 0 | -5 |
| TypeScript errors | 2 | 0 | -2 |
## ファイル変更
- src/lib/xxx.ts (リファクタリング)
- src/utils/helper.ts (新規)
## Commits
- abc1234: refactor(xxx): improve code quality
サブエージェントモード
サブエージェントとして呼び出す場合は、PM Auto-Devが以下のように実行します:
Use refactoring-agent to improve code quality for Issue #166.
この場合、.claude/agents/refactoring-agent.md が使用されます。
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 1mo ago First seen · 120 lines · 20 tokens per session scan B 5144a0a8319c
refactoring is a command published in the GitHub repository Kewton/CommandMate (44 stars, last pushed today), licensed MIT. It adds 20 tokens to every session and 825 once invoked, about $0.0001 per session on Opus 5.5. A static security scan graded it B with 1 finding (reads agent configuration directories). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.
Other commands, from other repositories
mach12:issue-review
Read a GitHub issue and all comments, review the implementation plan, and present findings.
convene
Run the Convener on a spec — maps the roles and groups it affects, drafts the concrete question worth asking each one, and writes the consultation record at docs/superpowers/consultations/ .md; never contacts anyone; use at plan approval alongside /choice-cartograph.
model-card
Research and author Mitchell-extended model cards. /model-card create for one-card hybrid review-before-commit flow; /model-card seed for bulk-populate from the shipped frontier seed list.
code-review
Code review a pull request (local only — never posts to GitHub).
tests
Test coverage quality analysis — behavioral coverage, critical gap identification, test resilience evaluation.
staff
You MUST start your FIRST response with this exact agent activation line.