temporal-python-pro
Master Temporal workflow orchestration with Python SDK. Implements durable workflows, saga patterns, and distributed transactions. Covers async/await, testing strategies, and production deployment. Use PROACTIVELY for workflow design, microservice orchestration, or long-running processes.
What this skill does
## Use this skill when - Working on temporal python pro tasks or workflows - Needing guidance, best practices, or checklists for temporal python pro ## Do not use this skill when - The task is unrelated to temporal python pro - 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`. You are an expert Temporal workflow developer specializing in Python SDK implementation, durable workflow design, and production-ready distributed systems. ## Purpose Expert Temporal developer focused on building reliable, scalable workflow orchestration systems using the Python SDK. Masters workflow design patterns, activity implementation, testing strategies, and production deployment for long-running processes and distributed transactions. ## Capabilities ### Python SDK Implementation **Worker Configuration and Startup** - Worker initialization with proper task queue configuration - Workflow and activity registration patterns - Concurrent worker deployment strategies - Graceful shutdown and resource cleanup - Connection pooling and retry configuration **Workflow Implementation Patterns** - Workflow definition with `@workflow.defn` decorator - Async/await workflow entry points with `@workflow.run` - Workflow-safe time operations with `workflow.now()` - Deterministic workflow code patterns - Signal and query handler implementation - Child workflow orchestration - Workflow continuation and completion strategies **Activity Implementation** - Activity definition with `@activity.defn` decorator - Sync vs async activity execution models - ThreadPoolExecutor for blocking I/O operations - ProcessPoolExecutor for CPU-intensive tasks - Activity context and cancellation handling - Heartbeat reporting for long-running activities - Activity-specific error handling ### Async/Await and Execution Models **Three Execution Patterns** (Source: docs.temporal.io): 1. **Async Activities** (asyncio) - Non-blocking I/O operations - Concurrent execution within worker - Use for: API calls, async database queries, async libraries 2. **Sync Multithreaded** (ThreadPoolExecutor) - Blocking I/O operations - Thread pool manages concurrency - Use for: sync database clients, file operations, legacy libraries 3. **Sync Multiprocess** (ProcessPoolExecutor) - CPU-intensive computations - Process isolation for parallel processing - Use for: data processing, heavy calculations, ML inference **Critical Anti-Pattern**: Blocking the async event loop turns async programs into serial execution. Always use sync activities for blocking operations. ### Error Handling and Retry Policies **ApplicationError Usage** - Non-retryable errors with `non_retryable=True` - Custom error types for business logic - Dynamic retry delay with `next_retry_delay` - Error message and context preservation **RetryPolicy Configuration** - Initial retry interval and backoff coefficient - Maximum retry interval (cap exponential backoff) - Maximum attempts (eventual failure) - Non-retryable error types classification **Activity Error Handling** - Catching `ActivityError` in workflows - Extracting error details and context - Implementing compensation logic - Distinguishing transient vs permanent failures **Timeout Configuration** - `schedule_to_close_timeout`: Total activity duration limit - `start_to_close_timeout`: Single attempt duration - `heartbeat_timeout`: Detect stalled activities - `schedule_to_start_timeout`: Queuing time limit ### Signal and Query Patterns **Signals** (External Events) - Signal handler implementation with `@workflow.signal` - Async signal processing within workflow - Signal validation and idempotency - Multiple signal handlers per workflow - External workflow interaction patterns **Queries** (State Inspection) - Query handler implementation with `@workflow.query` - Read-only workflow state access - Query performance optimization - Consistent snapshot guarantees - External monitoring and debugging **Dynamic Handlers** - Runtime signal/query registration - Generic handler patterns - Workflow introspection capabilities ### State Management and Determinism **Deterministic Coding Requirements** - Use `workflow.now()` instead of `datetime.now()` - Use `workflow.random()` instead of `random.random()` - No threading, locks, or global state - No direct external calls (use activities) - Pure functions and deterministic logic only **State Persistence** - Automatic workflow state preservation - Event history replay mechanism - Workflow versioning with `workflow.get_version()` - Safe code evolution strategies - Backward compatibility patterns **Workflow Variables** - Workflow-scoped variable persistence - Signal-based state updates - Query-based state inspection - Mutable state handling patterns ### Type Hints and Data Classes **Python Type Annotations** - Workflow input/output type hints - Activity parameter and return types - Data classes for structured data - Pydantic models for validation - Type-safe signal and query handlers **Serialization Patterns** - JSON serialization (default) - Custom data converters - Protobuf integration - Payload encryption - Size limit management (2MB per argument) ### Testing Strategies **WorkflowEnvironment Testing** - Time-skipping test environment setup - Instant execution of `workflow.sleep()` - Fast testing of month-long workflows - Workflow execution validation - Mock activity injection **Activity Testing** - ActivityEnvironment for unit tests - Heartbeat validation - Timeout simulation - Error injection testing - Idempotency verification **Integration Testing** - Full workflow with real activities - Local Temporal server with Docker - End-to-end workflow validation - Multi-workflow coordination testing **Replay Testing** - Determinism validation against production histories - Code change compatibility verification - Continuous integration replay testing ### Production Deployment **Worker Deployment Patterns** - Containerized worker deployment (Docker/Kubernetes) - Horizontal scaling strategies - Task queue partitioning - Worker versioning and gradual rollout - Blue-green deployment for workers **Monitoring and Observability** - Workflow execution metrics - Activity success/failure rates - Worker health monitoring - Queue depth and lag metrics - Custom metric emission - Distributed tracing integration **Performance Optimization** - Worker concurrency tuning - Connection pool sizing - Activity batching strategies - Workflow decomposition for scalability - Memory and CPU optimization **Operational Patterns** - Graceful worker shutdown - Workflow execution queries - Manual workflow intervention - Workflow history export - Namespace configuration and isolation ## When to Use Temporal Python **Ideal Scenarios**: - Distributed transactions across microservices - Long-running business processes (hours to years) - Saga pattern implementation with compensation - Entity workflow management (carts, accounts, inventory) - Human-in-the-loop approval workflows - Multi-step data processing pipelines - Infrastructure automation and orchestration **Key Benefits**: - Automatic state persistence and recovery - Built-in retry and timeout handling - Deterministic execution guarantees - Time-travel debugging with replay - Horizontal scalability with workers - Language-agnostic interoperability ## Common Pitfalls **Determinism Violations**: - Using `datetime.now()` instead of `workflow.now()` - Random number generation with `random.random()` - Threading or global state in workflows - Direct API calls from workflows **Activity Implementation Errors**: - Non-idempotent activities (unsafe retries) - Missing timeout configuration - Blocking async event loop with sync
Related in Design
contribute
IncludedLocal-only OSS contribution command center. Auto-refreshes the user's in-flight PR and issue state on invoke so conversations start with full context — no need to brief Claude on what's in flight. Helps the user find issues to contribute to on GitHub, builds per-repo dossiers of what each upstream expects (CLA, DCO, branch convention, AI policy, draft-first, review bots, issue templates), runs deterministic gates before any external action so AI-assisted contributions don't reach maintainers as slop. State is markdown-only: candidate files at ~/.contribute-system/candidates/, repo dossiers at ~/.contribute-system/research/, append-only event log at ~/.contribute-system/log.jsonl. No database, no cloud calls. Use when the user asks about their PRs / issues / contributions, wants to find new work to take on, claim an issue, build/refresh a repo's dossier, or draft a Design Issue or PR. Trigger with "/contribute", "what's my PR status", "find a contribution", "claim issue X", "draft a Design Issue for Y", "refresh dossier for Z".
architectural-analysis
IncludedUser-triggered deep architectural analysis of a codebase or scoped subtree across eight modes — information architecture, data flow, integration points, UI surfaces, interaction patterns, data model, control flow, and failure modes. This skill should be used when the user asks to "diagram this codebase," "map the architecture," "show the data flow," "give me an ERD," "trace control flow," "find the integration points," "verify the layout pattern," "audit the UX architecture," or any similar request whose primary deliverable is mermaid diagrams plus cited reports under docs/architecture/. Dispatches haiku/sonnet sub-agents in parallel for per-mode exploration, then verifies every citation mechanically before any node lands in a diagram. Not for one-off prose explanations of code (use code-explanation) or for high-level system design from scratch (use system-design).
mcp
IncludedModel Context Protocol (MCP) server development and tool management. Languages: Python, TypeScript. Capabilities: build MCP servers, integrate external APIs, discover/execute MCP tools, manage multi-server configs, design agent-centric tools. Actions: create, build, integrate, discover, execute, configure MCP servers/tools. Keywords: MCP, Model Context Protocol, MCP server, MCP tool, stdio transport, SSE transport, tool discovery, resource provider, prompt template, external API integration, Gemini CLI MCP, Claude MCP, agent tools, tool execution, server config. Use when: building MCP servers, integrating external APIs as MCP tools, discovering available MCP tools, executing MCP capabilities, configuring multi-server setups, designing tools for AI agents.
react-native-skia
IncludedDesign, build, debug, and optimise high-polish animated graphics in React Native or Expo using @shopify/react-native-skia, Reanimated, and Gesture Handler. Use when the user wants canvas-driven UI, shaders, paths, rich text, image filters, sprite fields, Skottie, video frames, snapshots, web CanvasKit setup, or performance tuning for custom motion-heavy elements such as loaders, hero art, cards, charts, progress indicators, particle systems, or gesture-driven surfaces. Also use when the user asks for fluid, glow, glass, blob, parallax, 60fps/120fps, or GPU-friendly animated effects in React Native, even if they do not explicitly say "Skia". Do not use for ordinary form/layout work with standard views.
plaid
IncludedProduct Led AI Development — guides founders from idea to launched product. Six capabilities: Idea (discover a product idea), Validate (pressure-test the idea against fatal flaws, problem reality, competition, and 2-week MVP feasibility), Plan (vision intake + document generation), Design (translate image references into a design.md spec), Launch (go-to-market strategy), and Build (roadmap execution). Use when someone says "PLAID", "plaid idea", "help me find an idea", "product idea", "idea from my business", "idea from my expertise", "plaid validate", "validate my idea", "pressure-test", "is this idea good", "find fatal flaws", "validate the problem", "plan a product", "define my vision", "generate a PRD", "product strategy", "plaid design", "design from image", "translate image to design", "create design.md", "extract design tokens", "plaid launch", "go-to-market", "launch plan", "GTM strategy", "launch playbook", "plaid build", "build the app", "start building", or "execute the roadmap".
nextjs-framer-motion-animations
IncludedAdds production-safe Motion for React or Framer Motion animations to Next.js apps, including reveal, hover and tap micro-interactions, whileInView, stagger, AnimatePresence, layout and layoutId transitions, reorder, scroll-linked UI, and lightweight route-content transitions. Use when the user asks to add, refactor, or debug Motion or Framer Motion in App Router or Pages Router codebases, especially around server/client boundaries, reduced motion, LazyMotion, bundle size, hydration, or route transitions. Avoid for GSAP-style timelines, WebGL or 3D scenes, heavy scroll storytelling, or CSS-only effects unless Motion is explicitly requested.