workflow-orchestration-patterns
Skill35 starsChanged 6 months agoMITView on GitHub
Durable workflow orchestration with Temporal for distributed systems across Java 21, Python 3.14, and NestJS 11.x. Covers Workflow vs Activity separation, Saga pattern, Entity workflows, Fan-out/Fan-in, determinism constraints, retry policies, and idempotency. Use when building long-running, failure-resilient distributed business processes.
- Installs packages
7 other projects use a version of this.
Adopted by
Most recently taken up by
- lgzarturo/codeconductortheir own version, first seen Oct 18, 2026
- xfstudio/skillstheir own version, first seen Oct 13, 2026
- Samueladewole/claude-skillstheir own version, first seen Oct 13, 2026
- NorkzYT/claude-code-autopilottheir own version, first seen Jun 11, 2026
- ai4brands-design/claude-skillstheir own version, first seen Mar 22, 2026
- CodeWithBehnam/cc-docstheir own version, first seen Mar 15, 2026
Other versions7 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 7
- xfstudio/skills★ 9same name
- ai4brands-design/claude-skills★ 2same name
- CodeWithBehnam/cc-docs★ 2same name
- NorkzYT/claude-code-autopilot★ 2same name
- lgzarturo/codeconductor★ 0same name
- ohadPA/ClaudeCode★ 0same name
- Samueladewole/claude-skills★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository157 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- a2ui-angularSkill
- accessibility-auditSkill
- adk-deploy-guideSkill
- adk-dev-guideSkill
- adk-eval-guideSkill
- adk-observability-guideSkill
- agentic-ai-coding-standardSkill
- agentic-ai-devSkill
- ai-auditSkill
- ai-chatSkill
- ai-decision-recordSkill
- ai-incident-responseSkill
- ai-launch-checkSkill
- ai-playbookSkill
- angular-best-practicesSkill
- angularSkill
- angular-spaSkill
- angular-ui-patternsSkill
- api-design-principlesSkill
- app-store-optimizationSkill
- architect-reviewSkill
- architecture-decision-recordsSkill
- architecture-designSkill
- asc-cli-usageSkill
- asc-crash-triageSkill
- asc-id-resolverSkill
- asc-release-flowSkill
- asc-signing-setupSkill
- asc-submission-healthSkill
- asc-testflight-orchestrationSkill
- browser-testingSkill
- changelog-generatorSkill
- claude-actions-auditorSkill
- clean-codeSkill
- codebase-onboardingSkill
- code-explainerSkill
- code-reviewerSkill
- code-simplifierSkill
- comment-analyzerSkill
- database-schema-designerSkill
- ddd-architectSkill
- decision-frameworksSkill
- dedup-code-agentSkill
- deployment-ci-cdSkill
- design-systemSkill
- dockerSkill
- documentation-generationSkill
- domain-finderSkill
- error-detectiveSkill
- eval-guideSkill
- feature-forgeSkill
- firebase-basicsSkill
- firebase-hosting-basicsSkill
- fixing-accessibilitySkill
- fixing-motion-performanceSkill
- flutter-animationsSkill
- flutter-genuiSkill
- flutter-mobileSkill
- flutter-security-expertSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
3 rules. 0 are common, 3 are distinctive, and 0 are very specific to this project.
0
Common
Most of the 7 edited versions we read keep these.
3
Distinctive
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 86
Before generating code, consult these sources for current SDK APIs:
- Distinctive: line 132
Idempotency rule: every activity MUST be safe to call N times.
- Distinctive: line 136
After writing Temporal workflow code, dispatch these reviewer agents:
“Common” is measured: kept by at least 6 in 10 of the 7 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Iron Law
NO WORKFLOW WITHOUT DETERMINISM ENFORCEMENT AND IDEMPOTENT ACTIVITIES — non-deterministic workflow code causes replay failures; non-idempotent activities cause duplicate charges, double-sends, and data corruption
Workflow Orchestration Patterns — Temporal + Java 21 / Python 3.14 / NestJS 11.x
Quick Scaffold
# Start Temporal server locally (Docker)
docker run -d --name temporal \
-p 7233:7233 -p 8080:8080 \
temporalio/auto-setup:1.24
# Java 21 / Spring Boot — add to pom.xml
# io.temporal:temporal-sdk:1.25.0
# io.temporal:temporal-spring-boot-autoconfigure-alpha:0.6.0
# Python 3.14 — uv add
uv add temporalio==1.7.0 fastapi uvicorn
# NestJS 11.x — npm
npm install @temporalio/client @temporalio/worker @temporalio/workflow @temporalio/activityProcess
- Deploy Temporal — local Docker or Temporal Cloud (cloud.temporal.io)
- Define Activities — external interactions (API calls, DB writes, emails) — must be idempotent
- Define Workflow — orchestration logic only — must be deterministic (no I/O, no
Date.now(), no random) - Configure Retry Policies — initial interval, backoff coefficient, max attempts, non-retryable errors
- Register Worker — binds workflow + activity implementations to task queues
- Start Execution — client sends
startWorkflow()with typed input - Add Signals/Queries — external state mutations (signals) and reads (queries) on running workflows
- Implement Saga — register compensations BEFORE each step; run in reverse (LIFO) on failure
- Add Heartbeats — long-running activities must call
heartbeat()periodically - Write Tests — use Temporal test environment with time-skipping for deterministic test execution
Key Patterns
| Pattern | When to Use | Reference |
| Saga + Compensation | Distributed transactions needing rollback | reference/implementation-playbook.md#saga |
| Entity Workflow (Actor) | One workflow per entity lifecycle (cart, account, order) | reference/implementation-playbook.md#entity |
| Fan-Out / Fan-In | Parallel execution of N tasks with result aggregation | reference/implementation-playbook.md#fanout |
| Async Callback / Signal | Waiting for external event or human approval | reference/implementation-playbook.md#signals |
| Activity Heartbeat | Long-running activities (>30s) with progress tracking | reference/implementation-playbook.md#heartbeat |
| Workflow Versioning | Safe code changes while old executions still running | reference/implementation-playbook.md#versioning |
| Child Workflows | Decompose large workflows for scalability (1M tasks = 1K x 1K) | reference/implementation-playbook.md#child |
Workflow vs Activity Decision Rule
Does the code touch an external system? (API, DB, file, email, network)
YES -> Activity
NO -> Workflow (orchestration/decision logic only)Prohibited in Workflow code:
new Date()/datetime.now()/LocalDateTime.now()— useWorkflow.currentTimeMillis()/workflow.now()Math.random()/random.random()— useWorkflow.newRandom()/workflow.random()- HTTP calls, DB queries, file I/O — move to Activity
- Threading, locks,
Thread.sleep()— useWorkflow.sleep() - Non-deterministic libraries
Conventions & Rules
For per-SDK implementation templates (Java, Python, NestJS), read
reference/implementation-playbook.md
Documentation Sources
Before generating code, consult these sources for current SDK APIs:
| Source | URL / Tool | Purpose |
| Temporal Docs | https://docs.temporal.io/dev-guide | Core concepts, SDK APIs, best practices |
| Java SDK | https://www.javadoc.io/doc/io.temporal/temporal-sdk/latest/ | Java workflow/activity annotations |
| Python SDK | https://python.temporal.io/ | Python asyncio API reference |
| TypeScript SDK | https://typescript.temporal.io/ | NestJS/TypeScript worker and client APIs |
| Context7 MCP | resolve-library-id: temporalio | Latest Temporal Python patterns |
Reference Files
| File | Content | When to Use |
reference/implementation-playbook.md | Full workflow + activity code for Java, Python, NestJS; Saga, Entity, Fan-out, Signal, Heartbeat, Versioning, Child Workflow patterns | Any Temporal implementation |
Common Commands
# View Temporal Web UI (workflows, history, task queues)
open http://localhost:8080
# Java — run worker
mvn spring-boot:run
# Python — run worker
uvicorn src.main:app --reload &
python -m src.worker # separate process
# NestJS — run worker
npm run start:worker # defined in package.json scripts
# Run Temporal test suite (time-skipping enabled)
# Java: mvn test
# Python: pytest -q
# NestJS: npm testError Handling
For retry policy templates and non-retryable error classification per SDK, read
reference/implementation-playbook.md#retry
Activity retry rule: classify every exception before throwing. Validation errors and business rule violations -> ApplicationFailure.newNonRetryableFailure(). Transient network/timeout errors -> retryable (default).
Workflow failure rule: workflows do not catch activity exceptions unless implementing compensation. Let Temporal's retry engine handle transient failures. Only catch ActivityFailure when running saga compensations.
Idempotency rule: every activity MUST be safe to call N times. Use idempotency keys, upsert patterns, and check-then-act with unique constraints. Verify with: "If this activity runs twice with the same input, is the final state identical?"
Post-Code Review
After writing Temporal workflow code, dispatch these reviewer agents:
architect-review— workflow boundaries, saga completeness, entity lifecycle correctnesssecurity-reviewer— activity input validation, no secrets in workflow state, payload size limits (2MB)
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

