refactor-assistant
コードをより良くするために、デザインパターンを提案したり、問題点を見つけたり、安全な修正方法を示したりすることで、プログラムの品質を向上させるSkill。
📜 元の英語説明(参考)
智能代码重构,提供设计模式建议、代码异味检测和保持行为不变的安全转换策略。
🇯🇵 日本人クリエイター向け解説
コードをより良くするために、デザインパターンを提案したり、問題点を見つけたり、安全な修正方法を示したりすることで、プログラムの品質を向上させるSkill。
※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。
下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o refactor-assistant.zip https://jpskill.com/download/16480.zip && unzip -o refactor-assistant.zip && rm refactor-assistant.zip
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/16480.zip -OutFile "$d\refactor-assistant.zip"; Expand-Archive "$d\refactor-assistant.zip" -DestinationPath $d -Force; ri "$d\refactor-assistant.zip"
完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。
💾 手動でダウンロードしたい(コマンドが難しい人向け)
- 1. 下の青いボタンを押して
refactor-assistant.zipをダウンロード - 2. ZIPファイルをダブルクリックで解凍 →
refactor-assistantフォルダができる - 3. そのフォルダを
C:\Users\あなたの名前\.claude\skills\(Win)または~/.claude/skills/(Mac)へ移動 - 4. Claude Code を再起動
⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。
🎯 このSkillでできること
下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。
📦 インストール方法 (3ステップ)
- 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
- 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
- 3. 展開してできたフォルダを、ホームフォルダの
.claude/skills/に置く- · macOS / Linux:
~/.claude/skills/ - · Windows:
%USERPROFILE%\.claude\skills\
- · macOS / Linux:
Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。
詳しい使い方ガイドを見る →- 最終更新
- 2026-05-18
- 取得日時
- 2026-05-18
- 同梱ファイル
- 1
📖 Skill本文(日本語訳)
※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。
Refactor Assistant Skill
説明
デザインパターンの推奨事項を用いて、体系的なリファクタリングを通じてコード品質を向上させます。
トリガー
/refactorコマンド- ユーザーがコードの改善を要求した場合
- ユーザーがデザインパターンについて質問した場合
プロンプト
あなたは、動作を維持しながらコード品質を向上させるリファクタリングのエキスパートです。
メソッドの抽出
// ❌ 以前: 複数の責務を持つ長いメソッド
function processOrder(order: Order) {
// 注文の検証
if (!order.items.length) throw new Error('Empty order');
if (!order.customer) throw new Error('No customer');
// 合計の計算
let total = 0;
for (const item of order.items) {
total += item.price * item.quantity;
if (item.discount) {
total -= item.discount;
}
}
// 税金の適用
const tax = total * 0.1;
total += tax;
// 保存と通知
db.save(order);
emailService.send(order.customer.email, `Order total: ${total}`);
}
// ✅ 以後: 小さく、焦点を絞ったメソッド
function processOrder(order: Order) {
validateOrder(order);
const total = calculateTotal(order);
saveAndNotify(order, total);
}
function validateOrder(order: Order): void {
if (!order.items.length) throw new Error('Empty order');
if (!order.customer) throw new Error('No customer');
}
function calculateTotal(order: Order): number {
const subtotal = order.items.reduce((sum, item) => {
const itemTotal = item.price * item.quantity - (item.discount ?? 0);
return sum + itemTotal;
}, 0);
return subtotal * 1.1; // 10%の税金を含む
}
Strategy パターン
// ❌ 以前: 異なる動作のための switch 文
function calculateShipping(order: Order): number {
switch (order.shippingMethod) {
case 'standard': return order.weight * 0.5;
case 'express': return order.weight * 1.5 + 10;
case 'overnight': return order.weight * 3 + 25;
default: throw new Error('Unknown method');
}
}
// ✅ 以後: Strategy パターン
interface ShippingStrategy {
calculate(order: Order): number;
}
class StandardShipping implements ShippingStrategy {
calculate(order: Order): number {
return order.weight * 0.5;
}
}
class ExpressShipping implements ShippingStrategy {
calculate(order: Order): number {
return order.weight * 1.5 + 10;
}
}
class ShippingCalculator {
constructor(private strategy: ShippingStrategy) {}
calculate(order: Order): number {
return this.strategy.calculate(order);
}
}
Factory パターン
// ✅ 異なる通知タイプを作成するための Factory
interface Notification {
send(message: string): Promise<void>;
}
class NotificationFactory {
static create(type: 'email' | 'sms' | 'push'): Notification {
switch (type) {
case 'email': return new EmailNotification();
case 'sms': return new SmsNotification();
case 'push': return new PushNotification();
}
}
}
// 使用例
const notification = NotificationFactory.create('email');
await notification.send('Hello!');
タグ
refactoring, design-patterns, code-quality, clean-code, architecture
互換性
- Codex: ✅
- Claude Code: ✅
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開
Refactor Assistant Skill
Description
Improve code quality through systematic refactoring with design pattern recommendations.
Trigger
/refactorcommand- User requests code improvement
- User asks about design patterns
Prompt
You are a refactoring expert that improves code quality while preserving behavior.
Extract Method
// ❌ Before: Long method with multiple responsibilities
function processOrder(order: Order) {
// Validate order
if (!order.items.length) throw new Error('Empty order');
if (!order.customer) throw new Error('No customer');
// Calculate total
let total = 0;
for (const item of order.items) {
total += item.price * item.quantity;
if (item.discount) {
total -= item.discount;
}
}
// Apply tax
const tax = total * 0.1;
total += tax;
// Save and notify
db.save(order);
emailService.send(order.customer.email, `Order total: ${total}`);
}
// ✅ After: Small, focused methods
function processOrder(order: Order) {
validateOrder(order);
const total = calculateTotal(order);
saveAndNotify(order, total);
}
function validateOrder(order: Order): void {
if (!order.items.length) throw new Error('Empty order');
if (!order.customer) throw new Error('No customer');
}
function calculateTotal(order: Order): number {
const subtotal = order.items.reduce((sum, item) => {
const itemTotal = item.price * item.quantity - (item.discount ?? 0);
return sum + itemTotal;
}, 0);
return subtotal * 1.1; // Include 10% tax
}
Strategy Pattern
// ❌ Before: Switch statement for different behaviors
function calculateShipping(order: Order): number {
switch (order.shippingMethod) {
case 'standard': return order.weight * 0.5;
case 'express': return order.weight * 1.5 + 10;
case 'overnight': return order.weight * 3 + 25;
default: throw new Error('Unknown method');
}
}
// ✅ After: Strategy pattern
interface ShippingStrategy {
calculate(order: Order): number;
}
class StandardShipping implements ShippingStrategy {
calculate(order: Order): number {
return order.weight * 0.5;
}
}
class ExpressShipping implements ShippingStrategy {
calculate(order: Order): number {
return order.weight * 1.5 + 10;
}
}
class ShippingCalculator {
constructor(private strategy: ShippingStrategy) {}
calculate(order: Order): number {
return this.strategy.calculate(order);
}
}
Factory Pattern
// ✅ Factory for creating different notification types
interface Notification {
send(message: string): Promise<void>;
}
class NotificationFactory {
static create(type: 'email' | 'sms' | 'push'): Notification {
switch (type) {
case 'email': return new EmailNotification();
case 'sms': return new SmsNotification();
case 'push': return new PushNotification();
}
}
}
// Usage
const notification = NotificationFactory.create('email');
await notification.send('Hello!');
Tags
refactoring, design-patterns, code-quality, clean-code, architecture
Compatibility
- Codex: ✅
- Claude Code: ✅