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

🛠️ TemporalGolangプロ

temporal-golang-pro

Temporal Go SDKを使って、システムが停止しても処理

⏱ テスト計画作成 2時間 → 20分

📺 まず動画で見る(YouTube)

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

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

📜 元の英語説明(参考)

Use when building durable distributed systems with Temporal Go SDK. Covers deterministic workflow rules, mTLS worker configs, and advanced patterns.

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

一言でいうと

Temporal Go SDKを使って、システムが停止しても処理

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

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

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

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

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

💾 手動でダウンロードしたい(コマンドが難しい人向け)
  1. 1. 下の青いボタンを押して temporal-golang-pro.zip をダウンロード
  2. 2. ZIPファイルをダブルクリックで解凍 → temporal-golang-pro フォルダができる
  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

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

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

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

📖 Skill本文(日本語訳)

※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。

Temporal Go SDK (temporal-golang-pro)

概要

Temporal Go SDK を使用して、回復力があり、スケーラブルで、決定論的な分散システムを構築するための専門家レベルのガイドです。このスキルは、漠然としたオーケストレーション要件を、耐久性のある実行、厳密な決定論、およびエンタープライズ規模のワーカー構成に焦点を当てた、本番環境対応の Go 実装に変換します。

このスキルを使用する場面

  • 分散システムの設計: 耐久性のある状態と信頼性の高いオーケストレーションを必要とするマイクロサービスを構築する場合。
  • 複雑なワークフローの実装: Go SDK を使用して、長時間実行されるプロセス(数日/数ヶ月)や複雑な Saga パターンを処理する場合。
  • パフォーマンスの最適化: ワーカーが細かく調整された並行性、mTLS セキュリティ、またはカスタムインターセプターを必要とする場合。
  • 信頼性の確保: べき等なアクティビティ、優雅なエラー処理、および洗練された再試行ポリシーを実装する場合。
  • メンテナンスと進化: 実行中のワークフローのバージョン管理や、ゼロダウンタイムのワーカー更新を実行する場合。

このスキルを使用しない場面

  • 他の SDK(Python、Java、TypeScript)で Temporal を使用する場合 - それぞれの -pro スキルを参照してください。
  • 耐久性や調整の必要がない単純なリクエスト/レスポンスのタスクの場合。
  • 実装を伴わない高レベルの設計の場合(workflow-orchestration-patterns を使用してください)。

ステップバイステップガイド

  1. コンテキストの収集: 以下の情報を積極的に尋ねてください。
    • ターゲットの Temporal Cluster(Cloud vs. Self-hosted)と Namespace
    • Task Queue 名と予想されるスループット。
    • セキュリティ要件(mTLS パス、認証)。
    • 障害モードと望ましい再試行/タイムアウトポリシー。
  2. 決定論の検証: ワークフローコードを提案する前に、以下の5つのルールに照らして検証してください。
    • ネイティブな Go の並行処理(goroutines)を使用しない。
    • ネイティブな時間(time.Nowtime.Sleep)を使用しない。
    • 非決定論的なマップイテレーションを使用しない(キーをソートする必要がある)。
    • 直接的な外部 I/O またはネットワーク呼び出しを行わない。
    • 非決定論的な乱数を使用しない。
  3. 段階的な実装: 共有の Protobuf/データクラスから始め、次にアクティビティ、次にワークフロー、最後にワーカーを実装します。
  4. リソースの活用: 実装が高度なパターン(Sagas、Interceptors、Replay Testing)を必要とする場合は、実装プレイブックとテスト戦略を明示的に参照してください。

機能

Go SDK の実装

  • ワーカー管理: MaxConcurrentActivityTaskPollersWorkerStopTimeoutStickyScheduleToStartTimeout を含む worker.Options に関する深い知識。
  • インターセプター: クロスカッティングな関心事(ロギング、トレース、認証)のためのクライアント、ワーカー、ワークフローインターセプターの実装。
  • カスタムデータコンバーター: Protobuf、暗号化されたペイロード、またはカスタム JSON マーシャリングの統合。

高度なワークフローパターン

  • 耐久性のある並行処理: ネイティブなプリミティブの代わりに workflow.Goworkflow.Channelworkflow.Selector を使用する。
  • バージョン管理: workflow.GetVersionworkflow.GetReplaySafeLogger を使用した安全なコード進化の実装。
  • 大規模処理: 履歴サイズ制限(デフォルト:50MB または 50K イベント)を管理するための ContinueAsNew のパターン。
  • 子ワークフロー: ライフサイクル、キャンセル、および親子シグナル伝播の管理。

テストと可観測性

  • テストスイートの習熟: 決定論的な時間制御による単体テストおよび機能テストのための WorkflowTestSuite の使用。
  • モック: 洗練されたアクティビティおよび子ワークフローのモック戦略。
  • リプレイテスト: 本番環境のイベント履歴に対するコード変更の検証。
  • メトリクス: ワーカーのパフォーマンス追跡のための Prometheus/OpenTelemetry エクスポーターの構成。

例 1: バージョン管理されたワークフロー(決定論的)

// Note: imports omitted. Requires 'go.temporal.io/sdk/workflow', 'go.temporal.io/sdk/temporal', and 'time'.
func SubscriptionWorkflow(ctx workflow.Context, userID string) error {
    // 1. Versioning for logic evolution (v1 = DefaultVersion)
    v := workflow.GetVersion(ctx, "billing_logic", workflow.DefaultVersion, 2)

    for i := 0; i < 12; i++ {
        ao := workflow.ActivityOptions{
            StartToCloseTimeout: 5 * time.Minute,
            RetryPolicy: &temporal.RetryPolicy{MaximumAttempts: 3},
        }
        ctx = workflow.WithActivityOptions(ctx, ao)

        // 2. Activity Execution (Always handle errors)
        err := workflow.ExecuteActivity(ctx, ChargePaymentActivity, userID).Get(ctx, nil)
        if err != nil {
            workflow.GetLogger(ctx).Error("Payment failed", "Error", err)
            return err
        }

        // 3. Durable Sleep (Time-skipping safe)
        sleepDuration := 30 * 24 * time.Hour
        if v >= 2 {
            sleepDuration = 28 * 24 * time.Hour
        }

        if err := workflow.Sleep(ctx, sleepDuration); err != nil {
            return err
        }
    }
    return nil
}

例 2: 完全な mTLS ワーカー設定

func RunSecureWorker() error {
    // 1. Load Client Certificate and Key
    cert, err := tls.LoadX509KeyPair("client.pem", "client.key")
    if err != nil {
        return fmt.Errorf("failed to load client keys: %w", err)
    }

    // 2. Load CA Certificate for Server verification (Proper mTLS)
    caPem, err := os.ReadFile("ca.pem")
    if err != nil {
        return fmt.Errorf("failed to read CA cert: %w", err)
    }
    certPool := x509.NewCertPool()
    if !certPool.AppendCertsFromPEM(caPem) {
        return fmt.Errorf("failed to parse CA cert")
    }

    // 3. Dial Cluster with full TLS config
    c, err := client.Dial(client.Options{
        HostPort:  "temporal.example.com:7233",
        Namespace: "production",
        ConnectionOptions: client.ConnectionOptions{
            TLS: &tls.Config{
                Certificates: []tls.Certificate{cert},
                RootCAs:      certPool,
            },
        },
    })
    if err != nil {
        return fmt.Errorf("failed to dial temporal: %w", err)
    }
    defer c.Close()

    w := worker.New(c, "payment-queue", worker.Options{})
    w.RegisterWorkflow(SubscriptionWorkflow)

    i
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開

Temporal Go SDK (temporal-golang-pro)

Overview

Expert-level guide for building resilient, scalable, and deterministic distributed systems using the Temporal Go SDK. This skill transforms vague orchestration requirements into production-grade Go implementations, focusing on durable execution, strict determinism, and enterprise-scale worker configuration.

When to Use This Skill

  • Designing Distributed Systems: When building microservices that require durable state and reliable orchestration.
  • Implementing Complex Workflows: Using the Go SDK to handle long-running processes (days/months) or complex Saga patterns.
  • Optimizing Performance: When workers need fine-tuned concurrency, mTLS security, or custom interceptors.
  • Ensuring Reliability: Implementing idempotent activities, graceful error handling, and sophisticated retry policies.
  • Maintenance & Evolution: Versioning running workflows or performing zero-downtime worker updates.

Do not use this skill when

  • Using Temporal with other SDKs (Python, Java, TypeScript) - refer to their specific -pro skills.
  • The task is a simple request/response without durability or coordination needs.
  • High-level design without implementation (use workflow-orchestration-patterns).

Step-by-Step Guide

  1. Gather Context: Proactively ask for:
    • Target Temporal Cluster (Cloud vs. Self-hosted) and Namespace.
    • Task Queue names and expected throughput.
    • Security requirements (mTLS paths, authentication).
    • Failure modes and desired retry/timeout policies.
  2. Verify Determinism: Before suggesting workflow code, verify against these 5 Rules:
    • No native Go concurrency (goroutines).
    • No native time (time.Now, time.Sleep).
    • No non-deterministic map iteration (must sort keys).
    • No direct external I/O or network calls.
    • No non-deterministic random numbers.
  3. Implement Incrementally: Start with shared Protobuf/Data classes, then Activities, then Workflows, and finally Workers.
  4. Leverage Resources: If the implementation requires advanced patterns (Sagas, Interceptors, Replay Testing), explicitly refer to the implementation playbook and testing strategies.

Capabilities

Go SDK Implementation

  • Worker Management: Deep knowledge of worker.Options, including MaxConcurrentActivityTaskPollers, WorkerStopTimeout, and StickyScheduleToStartTimeout.
  • Interceptors: Implementing Client, Worker, and Workflow interceptors for cross-cutting concerns (logging, tracing, auth).
  • Custom Data Converters: Integrating Protobuf, encrypted payloads, or custom JSON marshaling.

Advanced Workflow Patterns

  • Durable Concurrency: Using workflow.Go, workflow.Channel, and workflow.Selector instead of native primitives.
  • Versioning: Implementing safe code evolution using workflow.GetVersion and workflow.GetReplaySafeLogger.
  • Large-scale Processing: Pattern for ContinueAsNew to manage history size limits (defaults: 50MB or 50K events).
  • Child Workflows: Managing lifecycle, cancellation, and parent-child signal propagation.

Testing & Observability

  • Testsuite Mastery: Using WorkflowTestSuite for unit and functional testing with deterministic time control.
  • Mocking: Sophisticated activity and child workflow mocking strategies.
  • Replay Testing: Validating code changes against production event histories.
  • Metrics: Configuring Prometheus/OpenTelemetry exporters for worker performance tracking.

Examples

Example 1: Versioned Workflow (Deterministic)

// Note: imports omitted. Requires 'go.temporal.io/sdk/workflow', 'go.temporal.io/sdk/temporal', and 'time'.
func SubscriptionWorkflow(ctx workflow.Context, userID string) error {
    // 1. Versioning for logic evolution (v1 = DefaultVersion)
    v := workflow.GetVersion(ctx, "billing_logic", workflow.DefaultVersion, 2)

    for i := 0; i < 12; i++ {
        ao := workflow.ActivityOptions{
            StartToCloseTimeout: 5 * time.Minute,
            RetryPolicy: &temporal.RetryPolicy{MaximumAttempts: 3},
        }
        ctx = workflow.WithActivityOptions(ctx, ao)

        // 2. Activity Execution (Always handle errors)
        err := workflow.ExecuteActivity(ctx, ChargePaymentActivity, userID).Get(ctx, nil)
        if err != nil {
            workflow.GetLogger(ctx).Error("Payment failed", "Error", err)
            return err
        }

        // 3. Durable Sleep (Time-skipping safe)
        sleepDuration := 30 * 24 * time.Hour
        if v >= 2 {
            sleepDuration = 28 * 24 * time.Hour
        }

        if err := workflow.Sleep(ctx, sleepDuration); err != nil {
            return err
        }
    }
    return nil
}

Example 2: Full mTLS Worker Setup

func RunSecureWorker() error {
    // 1. Load Client Certificate and Key
    cert, err := tls.LoadX509KeyPair("client.pem", "client.key")
    if err != nil {
        return fmt.Errorf("failed to load client keys: %w", err)
    }

    // 2. Load CA Certificate for Server verification (Proper mTLS)
    caPem, err := os.ReadFile("ca.pem")
    if err != nil {
        return fmt.Errorf("failed to read CA cert: %w", err)
    }
    certPool := x509.NewCertPool()
    if !certPool.AppendCertsFromPEM(caPem) {
        return fmt.Errorf("failed to parse CA cert")
    }

    // 3. Dial Cluster with full TLS config
    c, err := client.Dial(client.Options{
        HostPort:  "temporal.example.com:7233",
        Namespace: "production",
        ConnectionOptions: client.ConnectionOptions{
            TLS: &tls.Config{
                Certificates: []tls.Certificate{cert},
                RootCAs:      certPool,
            },
        },
    })
    if err != nil {
        return fmt.Errorf("failed to dial temporal: %w", err)
    }
    defer c.Close()

    w := worker.New(c, "payment-queue", worker.Options{})
    w.RegisterWorkflow(SubscriptionWorkflow)

    if err := w.Run(worker.InterruptCh()); err != nil {
        return fmt.Errorf("worker run failed: %w", err)
    }
    return nil
}

Example 3: Selector & Signal Integration

func ApprovalWorkflow(ctx workflow.Context) (string, error) {
    var approved bool
    signalCh := workflow.GetSignalChannel(ctx, "approval-signal")

    // Use Selector to wait for multiple async events
    s := workflow.NewSelector(ctx)
    s.AddReceive(signalCh, func(c workflow.ReceiveChannel, _ bool) {
        c.Receive(ctx, &approved)
    })

    // Add 72-hour timeout timer
    s.AddReceive(workflow.NewTimer(ctx, 72*time.Hour).GetChannel(), func(c workflow.ReceiveChannel, _ bool) {
        approved = false
    })

    s.Select(ctx)

    if !approved {
        return "rejected", nil
    }
    return "approved", nil
}

Best Practices

  • Do: Always handle errors from ExecuteActivity and client.Dial.
  • Do: Use workflow.Go and workflow.Channel for concurrency.
  • Do: Sort map keys before iteration to maintain determinism.
  • Do: Use activity.RecordHeartbeat for activities lasting > 1 minute.
  • Do: Test logic compatibility using replayer.ReplayWorkflowHistoryFromJSON.
  • Don't: Swallow errors with _ or log.Fatal in production workers.
  • Don't: Perform direct Network/Disk I/O inside a Workflow function.
  • Don't: Rely on native time.Now() or rand.Int().
  • Don't: Apply this to simple cron jobs that don't require durability.

Troubleshooting

  • Panic: Determinism Mismatch: Usually caused by logic changes without workflow.GetVersion or non-deterministic code (e.g., native maps).
  • Error: History Size Exceeded: History limit reached (default 50K events). Ensure ContinueAsNew is implemented.
  • Worker Hang: Check WorkerStopTimeout and ensure all activities handle context cancellation.

Limitations

  • Does not cover Temporal Cloud UI navigation or TLS certificate provisioning workflows.
  • Does not cover Temporal Java, Python, or TypeScript SDKs; refer to their dedicated -pro skills.
  • Assumes Temporal Server v1.20+ and Go SDK v1.25+; older SDK versions may have different APIs.
  • Does not cover experimental Temporal features (e.g., Nexus, Multi-cluster Replication).
  • Does not address global namespace configuration or multi-region failover setup.
  • Does not cover Temporal Worker versioning via the worker-versioning feature flag (experimental).

Resources

Related Skills

  • grpc-golang - Internal transport protocol and Protobuf design.
  • golang-pro - General Go performance tuning and advanced syntax.
  • workflow-orchestration-patterns - Language-agnostic orchestration strategy.