jpskill.com
🛠️ 開発・MCP コミュニティ 🔴 エンジニア向け 👤 エンジニア・AI開発者

🛠️ TDDWorkflowsTDDリファクタリング

tdd-workflows-tdd-refactor

テスト駆動開発(TDD)のワークフローにおいて、リファクタリングを効率的に進めるためのSkill。

⏱ ボイラープレート実装 半日 → 30分

📺 まず動画で見る(YouTube)

▶ 【衝撃】最強のAIエージェント「Claude Code」の最新機能・使い方・プログラミングをAIで効率化する超実践術を解説! ↗

※ jpskill.com 編集部が参考用に選んだ動画です。動画の内容と Skill の挙動は厳密には一致しないことがあります。

📜 元の英語説明(参考)

Use when working with tdd workflows tdd refactor

🇯🇵 日本人クリエイター向け解説

一言でいうと

テスト駆動開発(TDD)のワークフローにおいて、リファクタリングを効率的に進めるためのSkill。

※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。

⚡ おすすめ: コマンド1行でインストール(60秒)

下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。

🍎 Mac / 🐧 Linux
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o tdd-workflows-tdd-refactor.zip https://jpskill.com/download/3577.zip && unzip -o tdd-workflows-tdd-refactor.zip && rm tdd-workflows-tdd-refactor.zip
🪟 Windows (PowerShell)
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/3577.zip -OutFile "$d\tdd-workflows-tdd-refactor.zip"; Expand-Archive "$d\tdd-workflows-tdd-refactor.zip" -DestinationPath $d -Force; ri "$d\tdd-workflows-tdd-refactor.zip"

完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。

💾 手動でダウンロードしたい(コマンドが難しい人向け)
  1. 1. 下の青いボタンを押して tdd-workflows-tdd-refactor.zip をダウンロード
  2. 2. ZIPファイルをダブルクリックで解凍 → tdd-workflows-tdd-refactor フォルダができる
  3. 3. そのフォルダを C:\Users\あなたの名前\.claude\skills\(Win)または ~/.claude/skills/(Mac)へ移動
  4. 4. Claude Code を再起動

⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。

🎯 このSkillでできること

下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。

📦 インストール方法 (3ステップ)

  1. 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
  2. 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
  3. 3. 展開してできたフォルダを、ホームフォルダの .claude/skills/ に置く
    • · macOS / Linux: ~/.claude/skills/
    • · Windows: %USERPROFILE%\.claude\skills\

Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。

詳しい使い方ガイドを見る →
最終更新
2026-05-17
取得日時
2026-05-17
同梱ファイル
1

💬 こう話しかけるだけ — サンプルプロンプト

  • Tdd Workflows Tdd Refactor を使って、最小構成のサンプルコードを示して
  • Tdd Workflows Tdd Refactor の主な使い方と注意点を教えて
  • Tdd Workflows Tdd Refactor を既存プロジェクトに組み込む方法を教えて

これをClaude Code に貼るだけで、このSkillが自動発動します。

📖 Claude が読む原文 SKILL.md(中身を展開)

この本文は AI(Claude)が読むための原文(英語または中国語)です。日本語訳は順次追加中。

Use this skill when

  • Working on tdd workflows tdd refactor tasks or workflows
  • Needing guidance, best practices, or checklists for tdd workflows tdd refactor

Do not use this skill when

  • The task is unrelated to tdd workflows tdd refactor
  • You need a different domain or tool outside this scope

Instructions

  • Clarify goals, constraints, and required inputs.
  • Apply relevant best practices and validate outcomes.
  • Provide actionable steps and verification.
  • If detailed examples are required, open resources/implementation-playbook.md.

Refactor code with confidence using comprehensive test safety net:

[Extended thinking: This tool uses the tdd-orchestrator agent (opus model) for sophisticated refactoring while maintaining all tests green. It applies design patterns, improves code quality, and optimizes performance with the safety of comprehensive test coverage.]

Usage

Use Task tool with subagent_type="tdd-orchestrator" to perform safe refactoring.

Prompt: "Refactor this code while keeping all tests green: $ARGUMENTS. Apply TDD refactor phase:

Core Process

1. Pre-Assessment

  • Run tests to establish green baseline
  • Analyze code smells and test coverage
  • Document current performance metrics
  • Create incremental refactoring plan

2. Code Smell Detection

  • Duplicated code → Extract methods/classes
  • Long methods → Decompose into focused functions
  • Large classes → Split responsibilities
  • Long parameter lists → Parameter objects
  • Feature Envy → Move methods to appropriate classes
  • Primitive Obsession → Value objects
  • Switch statements → Polymorphism
  • Dead code → Remove

3. Design Patterns

  • Apply Creational (Factory, Builder, Singleton)
  • Apply Structural (Adapter, Facade, Decorator)
  • Apply Behavioral (Strategy, Observer, Command)
  • Apply Domain (Repository, Service, Value Objects)
  • Use patterns only where they add clear value

4. SOLID Principles

  • Single Responsibility: One reason to change
  • Open/Closed: Open for extension, closed for modification
  • Liskov Substitution: Subtypes substitutable
  • Interface Segregation: Small, focused interfaces
  • Dependency Inversion: Depend on abstractions

5. Refactoring Techniques

  • Extract Method/Variable/Interface
  • Inline unnecessary indirection
  • Rename for clarity
  • Move Method/Field to appropriate classes
  • Replace Magic Numbers with constants
  • Encapsulate fields
  • Replace Conditional with Polymorphism
  • Introduce Null Object

6. Performance Optimization

  • Profile to identify bottlenecks
  • Optimize algorithms and data structures
  • Implement caching where beneficial
  • Reduce database queries (N+1 elimination)
  • Lazy loading and pagination
  • Always measure before and after

7. Incremental Steps

  • Make small, atomic changes
  • Run tests after each modification
  • Commit after each successful refactoring
  • Keep refactoring separate from behavior changes
  • Use scaffolding when needed

8. Architecture Evolution

  • Layer separation and dependency management
  • Module boundaries and interface definition
  • Event-driven patterns for decoupling
  • Database access pattern optimization

9. Safety Verification

  • Run full test suite after each change
  • Performance regression testing
  • Mutation testing for test effectiveness
  • Rollback plan for major changes

10. Advanced Patterns

  • Strangler Fig: Gradual legacy replacement
  • Branch by Abstraction: Large-scale changes
  • Parallel Change: Expand-contract pattern
  • Mikado Method: Dependency graph navigation

Output Requirements

  • Refactored code with improvements applied
  • Test results (all green)
  • Before/after metrics comparison
  • Applied refactoring techniques list
  • Performance improvement measurements
  • Remaining technical debt assessment

Safety Checklist

Before committing:

  • ✓ All tests pass (100% green)
  • ✓ No functionality regression
  • ✓ Performance metrics acceptable
  • ✓ Code coverage maintained/improved
  • ✓ Documentation updated

Recovery Protocol

If tests fail:

  • Immediately revert last change
  • Identify breaking refactoring
  • Apply smaller incremental changes
  • Use version control for safe experimentation

Example: Extract Method Pattern

Before:

class OrderProcessor {
  processOrder(order: Order): ProcessResult {
    // Validation
    if (!order.customerId || order.items.length === 0) {
      return { success: false, error: "Invalid order" };
    }

    // Calculate totals
    let subtotal = 0;
    for (const item of order.items) {
      subtotal += item.price * item.quantity;
    }
    let total = subtotal + (subtotal * 0.08) + (subtotal > 100 ? 0 : 15);

    // Process payment...
    // Update inventory...
    // Send confirmation...
  }
}

After:

class OrderProcessor {
  async processOrder(order: Order): Promise<ProcessResult> {
    const validation = this.validateOrder(order);
    if (!validation.isValid) return ProcessResult.failure(validation.error);

    const orderTotal = OrderTotal.calculate(order);
    const inventoryCheck = await this.inventoryService.checkAvailability(order.items);
    if (!inventoryCheck.available) return ProcessResult.failure(inventoryCheck.reason);

    await this.paymentService.processPayment(order.paymentMethod, orderTotal.total);
    await this.inventoryService.reserveItems(order.items);
    await this.notificationService.sendOrderConfirmation(order, orderTotal);

    return ProcessResult.success(order.id, orderTotal.total);
  }

  private validateOrder(order: Order): ValidationResult {
    if (!order.customerId) return ValidationResult.invalid("Customer ID required");
    if (order.items.length === 0) return ValidationResult.invalid("Order must contain items");
    return ValidationResult.valid();
  }
}

Applied: Extract Method, Value Objects, Dependency Injection, Async patterns

Code to refactor: $ARGUMENTS"

Limitations

  • Use this skill only when the task clearly matches the scope described above.
  • Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
  • Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.