🛠️ ワークフロー統括パターン集
複雑なシステムで複数の処理を自動で連携・
📺 まず動画で見る(YouTube)
▶ 【衝撃】最強のAIエージェント「Claude Code」の最新機能・使い方・プログラミングをAIで効率化する超実践術を解説! ↗
※ jpskill.com 編集部が参考用に選んだ動画です。動画の内容と Skill の挙動は厳密には一致しないことがあります。
📜 元の英語説明(参考)
Master workflow orchestration architecture with Temporal, covering fundamental design decisions, resilience patterns, and best practices for building reliable distributed systems.
🇯🇵 日本人クリエイター向け解説
複雑なシステムで複数の処理を自動で連携・
※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。
下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o workflow-orchestration-patterns.zip https://jpskill.com/download/3721.zip && unzip -o workflow-orchestration-patterns.zip && rm workflow-orchestration-patterns.zip
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/3721.zip -OutFile "$d\workflow-orchestration-patterns.zip"; Expand-Archive "$d\workflow-orchestration-patterns.zip" -DestinationPath $d -Force; ri "$d\workflow-orchestration-patterns.zip"
完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。
💾 手動でダウンロードしたい(コマンドが難しい人向け)
- 1. 下の青いボタンを押して
workflow-orchestration-patterns.zipをダウンロード - 2. ZIPファイルをダブルクリックで解凍 →
workflow-orchestration-patternsフォルダができる - 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-17
- 取得日時
- 2026-05-17
- 同梱ファイル
- 1
💬 こう話しかけるだけ — サンプルプロンプト
- › Workflow Orchestration Pattern を使って、最小構成のサンプルコードを示して
- › Workflow Orchestration Pattern の主な使い方と注意点を教えて
- › Workflow Orchestration Pattern を既存プロジェクトに組み込む方法を教えて
これをClaude Code に貼るだけで、このSkillが自動発動します。
📖 Skill本文(日本語訳)
※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。
ワークフローオーケストレーションパターン
Temporal を用いたワークフローオーケストレーションアーキテクチャを習得し、信頼性の高い分散システムを構築するための基本的な設計上の決定、回復性パターン、およびベストプラクティスを網羅します。
このスキルを使用する場面
- ワークフローオーケストレーションパターンのタスクやワークフローに取り組んでいる場合
- ワークフローオーケストレーションパターンのガイダンス、ベストプラクティス、またはチェックリストが必要な場合
このスキルを使用しない場面
- タスクがワークフローオーケストレーションパターンと無関係な場合
- この範囲外の異なるドメインやツールが必要な場合
指示
- 目標、制約、および必要な入力を明確にしてください。
- 関連するベストプラクティスを適用し、結果を検証してください。
- 実用的な手順と検証を提供してください。
- 詳細な例が必要な場合は、
resources/implementation-playbook.mdを開いてください。
ワークフローオーケストレーションを使用するタイミング
理想的なユースケース (出典: docs.temporal.io)
- マシン/サービス/データベースにまたがる複数ステップのプロセス
- 全か無かのセマンティクスを必要とする分散トランザクション
- 自動的な状態永続化を伴う長時間実行されるワークフロー (数時間から数年)
- 最後の成功したステップから再開する必要がある障害回復
- ビジネスプロセス: 予約、注文、キャンペーン、承認
- エンティティライフサイクル管理: 在庫追跡、アカウント管理、カートワークフロー
- インフラストラクチャ自動化: CI/CD パイプライン、プロビジョニング、デプロイ
- タイムアウトとエスカレーションを必要とするヒューマン・イン・ザ・ループシステム
使用しないタイミング
- 単純な CRUD 操作 (直接 API 呼び出しを使用)
- 純粋なデータ処理パイプライン (Airflow、バッチ処理を使用)
- ステートレスなリクエスト/レスポンス (標準 API を使用)
- リアルタイムストリーミング (Kafka、イベントプロセッサを使用)
重要な設計上の決定: ワークフロー vs アクティビティ
基本的なルール (出典: temporal.io/blog/workflow-engine-principles):
- ワークフロー = オーケストレーションロジックと意思決定
- アクティビティ = 外部との相互作用 (API、データベース、ネットワーク呼び出し)
ワークフロー (オーケストレーション)
特徴:
- ビジネスロジックと調整を含む
- 決定論的である必要があります (同じ入力 → 同じ出力)
- 直接的な外部呼び出しを実行できません
- 障害発生時にも状態が自動的に保持されます
- インフラストラクチャの障害にもかかわらず、何年も実行できます
ワークフローのタスク例:
- 実行するステップを決定する
- 補償ロジックを処理する
- タイムアウトと再試行を管理する
- 子ワークフローを調整する
アクティビティ (外部との相互作用)
特徴:
- すべての外部システムとの相互作用を処理します
- 非決定論的である可能性があります (API 呼び出し、DB 書き込み)
- 組み込みのタイムアウトと再試行ロジックが含まれます
- 冪等である必要があります (N 回呼び出すことは 1 回呼び出すことと同じ)
- 短命です (通常、数秒から数分)
アクティビティのタスク例:
- 決済ゲートウェイ API を呼び出す
- データベースに書き込む
- メールや通知を送信する
- 外部サービスを照会する
設計決定フレームワーク
外部システムに触れますか? → アクティビティ
オーケストレーション/決定ロジックですか? → ワークフロー
コアワークフローパターン
1. 補償を伴う Saga パターン
目的: ロールバック機能を備えた分散トランザクションを実装する
パターン (出典: temporal.io/blog/compensating-actions-part-of-a-complete-breakfast-with-sagas):
各ステップについて:
1. 実行する前に補償を登録する
2. ステップを実行する (アクティビティ経由)
3. 失敗した場合、すべての補償を逆順 (LIFO) で実行する
例: 支払いワークフロー
- 在庫を予約する (補償: 在庫を解放する)
- 支払いを請求する (補償: 支払いを返金する)
- 注文を履行する (補償: 履行をキャンセルする)
重要な要件:
- 補償は冪等である必要があります
- ステップを実行する前に補償を登録します
- 補償を逆順で実行します
- 部分的な障害を適切に処理します
2. エンティティワークフロー (アクターモデル)
目的: 単一のエンティティインスタンスを表す長時間実行されるワークフロー
パターン (出典: docs.temporal.io/evaluate/use-cases-design-patterns):
- 1 つのワークフロー実行 = 1 つのエンティティ (カート、アカウント、在庫品目)
- ワークフローはエンティティのライフタイムの間永続します
- 状態変更のシグナルを受信します
- 現在の状態のクエリをサポートします
ユースケース例:
- ショッピングカート (アイテムの追加、チェックアウト、有効期限)
- 銀行口座 (預金、引き出し、残高確認)
- 製品在庫 (在庫更新、予約)
利点:
- エンティティの動作をカプセル化します
- エンティティごとの一貫性を保証します
- 自然なイベントソーシング
3. ファンアウト/ファンイン (並列実行)
目的: 複数のタスクを並列で実行し、結果を集約する
パターン:
- 子ワークフローまたは並列アクティビティを生成する
- すべての完了を待つ
- 結果を集約する
- 部分的な障害を処理する
スケーリングルール (出典: temporal.io/blog/workflow-engine-principles):
- 個々のワークフローをスケーリングしないでください
- 100万タスクの場合: 1K の子ワークフロー × 各 1K タスクを生成します
- 各ワークフローを制限された状態に保ちます
4. 非同期コールバックパターン
目的: 外部イベントまたは人間の承認を待つ
パターン:
- ワークフローがリクエストを送信し、シグナルを待つ
- 外部システムが非同期で処理する
- ワークフローを再開するシグナルを送信する
- ワークフローが応答で続行する
ユースケース:
- 人間による承認ワークフロー
- Webhook コールバック
- 長時間実行される外部プロセス
状態管理と決定論
自動状態永続化
Temporal の仕組み (出典: docs.temporal.io/workflows):
- 完全なプログラム状態が自動的に保持されます
- イベント履歴はすべてのコマンドとイベントを記録します
- クラッシュからのシームレスな回復
- アプリケーションは障害発生前の状態を復元します
決定論の制約
ワークフローはステートマシンとして実行されます:
- リプレイ動作は一貫している必要があります
- 同じ入力 → 常に同じ出力
ワークフローで禁止されているもの (出典: docs.temporal.io/workflows):
- ❌ スレッド、ロック、同期プリミティブ
- ❌ 乱数生成 (
random()) - ❌ グローバル状態または静的変数
- ❌ システム時間 (
datetime.now()) - ❌ 直接的なファイル I/O またはネットワーク呼び出し
- ❌ 非決定論的なライブラリ
ワークフローで許可されているもの:
- ✅ `wor
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開
Workflow Orchestration Patterns
Master workflow orchestration architecture with Temporal, covering fundamental design decisions, resilience patterns, and best practices for building reliable distributed systems.
Use this skill when
- Working on workflow orchestration patterns tasks or workflows
- Needing guidance, best practices, or checklists for workflow orchestration patterns
Do not use this skill when
- The task is unrelated to workflow orchestration patterns
- 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.
When to Use Workflow Orchestration
Ideal Use Cases (Source: docs.temporal.io)
- Multi-step processes spanning machines/services/databases
- Distributed transactions requiring all-or-nothing semantics
- Long-running workflows (hours to years) with automatic state persistence
- Failure recovery that must resume from last successful step
- Business processes: bookings, orders, campaigns, approvals
- Entity lifecycle management: inventory tracking, account management, cart workflows
- Infrastructure automation: CI/CD pipelines, provisioning, deployments
- Human-in-the-loop systems requiring timeouts and escalations
When NOT to Use
- Simple CRUD operations (use direct API calls)
- Pure data processing pipelines (use Airflow, batch processing)
- Stateless request/response (use standard APIs)
- Real-time streaming (use Kafka, event processors)
Critical Design Decision: Workflows vs Activities
The Fundamental Rule (Source: temporal.io/blog/workflow-engine-principles):
- Workflows = Orchestration logic and decision-making
- Activities = External interactions (APIs, databases, network calls)
Workflows (Orchestration)
Characteristics:
- Contain business logic and coordination
- MUST be deterministic (same inputs → same outputs)
- Cannot perform direct external calls
- State automatically preserved across failures
- Can run for years despite infrastructure failures
Example workflow tasks:
- Decide which steps to execute
- Handle compensation logic
- Manage timeouts and retries
- Coordinate child workflows
Activities (External Interactions)
Characteristics:
- Handle all external system interactions
- Can be non-deterministic (API calls, DB writes)
- Include built-in timeouts and retry logic
- Must be idempotent (calling N times = calling once)
- Short-lived (seconds to minutes typically)
Example activity tasks:
- Call payment gateway API
- Write to database
- Send emails or notifications
- Query external services
Design Decision Framework
Does it touch external systems? → Activity
Is it orchestration/decision logic? → Workflow
Core Workflow Patterns
1. Saga Pattern with Compensation
Purpose: Implement distributed transactions with rollback capability
Pattern (Source: temporal.io/blog/compensating-actions-part-of-a-complete-breakfast-with-sagas):
For each step:
1. Register compensation BEFORE executing
2. Execute the step (via activity)
3. On failure, run all compensations in reverse order (LIFO)
Example: Payment Workflow
- Reserve inventory (compensation: release inventory)
- Charge payment (compensation: refund payment)
- Fulfill order (compensation: cancel fulfillment)
Critical Requirements:
- Compensations must be idempotent
- Register compensation BEFORE executing step
- Run compensations in reverse order
- Handle partial failures gracefully
2. Entity Workflows (Actor Model)
Purpose: Long-lived workflow representing single entity instance
Pattern (Source: docs.temporal.io/evaluate/use-cases-design-patterns):
- One workflow execution = one entity (cart, account, inventory item)
- Workflow persists for entity lifetime
- Receives signals for state changes
- Supports queries for current state
Example Use Cases:
- Shopping cart (add items, checkout, expiration)
- Bank account (deposits, withdrawals, balance checks)
- Product inventory (stock updates, reservations)
Benefits:
- Encapsulates entity behavior
- Guarantees consistency per entity
- Natural event sourcing
3. Fan-Out/Fan-In (Parallel Execution)
Purpose: Execute multiple tasks in parallel, aggregate results
Pattern:
- Spawn child workflows or parallel activities
- Wait for all to complete
- Aggregate results
- Handle partial failures
Scaling Rule (Source: temporal.io/blog/workflow-engine-principles):
- Don't scale individual workflows
- For 1M tasks: spawn 1K child workflows × 1K tasks each
- Keep each workflow bounded
4. Async Callback Pattern
Purpose: Wait for external event or human approval
Pattern:
- Workflow sends request and waits for signal
- External system processes asynchronously
- Sends signal to resume workflow
- Workflow continues with response
Use Cases:
- Human approval workflows
- Webhook callbacks
- Long-running external processes
State Management and Determinism
Automatic State Preservation
How Temporal Works (Source: docs.temporal.io/workflows):
- Complete program state preserved automatically
- Event History records every command and event
- Seamless recovery from crashes
- Applications restore pre-failure state
Determinism Constraints
Workflows Execute as State Machines:
- Replay behavior must be consistent
- Same inputs → identical outputs every time
Prohibited in Workflows (Source: docs.temporal.io/workflows):
- ❌ Threading, locks, synchronization primitives
- ❌ Random number generation (
random()) - ❌ Global state or static variables
- ❌ System time (
datetime.now()) - ❌ Direct file I/O or network calls
- ❌ Non-deterministic libraries
Allowed in Workflows:
- ✅
workflow.now()(deterministic time) - ✅
workflow.random()(deterministic random) - ✅ Pure functions and calculations
- ✅ Calling activities (non-deterministic operations)
Versioning Strategies
Challenge: Changing workflow code while old executions still running
Solutions:
- Versioning API: Use
workflow.get_version()for safe changes - New Workflow Type: Create new workflow, route new executions to it
- Backward Compatibility: Ensure old events replay correctly
Resilience and Error Handling
Retry Policies
Default Behavior: Temporal retries activities forever
Configure Retry:
- Initial retry interval
- Backoff coefficient (exponential backoff)
- Maximum interval (cap retry delay)
- Maximum attempts (eventually fail)
Non-Retryable Errors:
- Invalid input (validation failures)
- Business rule violations
- Permanent failures (resource not found)
Idempotency Requirements
Why Critical (Source: docs.temporal.io/activities):
- Activities may execute multiple times
- Network failures trigger retries
- Duplicate execution must be safe
Implementation Strategies:
- Idempotency keys (deduplication)
- Check-then-act with unique constraints
- Upsert operations instead of insert
- Track processed request IDs
Activity Heartbeats
Purpose: Detect stalled long-running activities
Pattern:
- Activity sends periodic heartbeat
- Includes progress information
- Timeout if no heartbeat received
- Enables progress-based retry
Best Practices
Workflow Design
- Keep workflows focused - Single responsibility per workflow
- Small workflows - Use child workflows for scalability
- Clear boundaries - Workflow orchestrates, activities execute
- Test locally - Use time-skipping test environment
Activity Design
- Idempotent operations - Safe to retry
- Short-lived - Seconds to minutes, not hours
- Timeout configuration - Always set timeouts
- Heartbeat for long tasks - Report progress
- Error handling - Distinguish retryable vs non-retryable
Common Pitfalls
Workflow Violations:
- Using
datetime.now()instead ofworkflow.now() - Threading or async operations in workflow code
- Calling external APIs directly from workflow
- Non-deterministic logic in workflows
Activity Mistakes:
- Non-idempotent operations (can't handle retries)
- Missing timeouts (activities run forever)
- No error classification (retry validation errors)
- Ignoring payload limits (2MB per argument)
Operational Considerations
Monitoring:
- Workflow execution duration
- Activity failure rates
- Retry attempts and backoff
- Pending workflow counts
Scalability:
- Horizontal scaling with workers
- Task queue partitioning
- Child workflow decomposition
- Activity batching when appropriate
Additional Resources
Official Documentation:
- Temporal Core Concepts: docs.temporal.io/workflows
- Workflow Patterns: docs.temporal.io/evaluate/use-cases-design-patterns
- Best Practices: docs.temporal.io/develop/best-practices
- Saga Pattern: temporal.io/blog/saga-pattern-made-easy
Key Principles:
- Workflows = orchestration, Activities = external calls
- Determinism is non-negotiable for workflows
- Idempotency is critical for activities
- State preservation is automatic
- Design for failure and recovery
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.