patterns.md
attributes
| source_path | references/workflows/patterns.md |
|---|---|
| source_sha256 | 91ea4976873dc1737173f23762b433e6fdbd3ed8ab989189490325eaeb66815f |
| source_url | https://github.com/cloudflare/skills/blob/47dfc2ce969bf62acf8bc231198ade4bb02712e0/skills/cloudflare/references/workflows/patterns.md |
| supporting_skill_id | 40184 |
| upstream_revision | 47dfc2ce969bf62acf8bc231198ade4bb02712e0 |
Workflow Patterns
Design Decisions
Read Rules of Workflows before choosing step boundaries or concurrency patterns.
- Separate work into steps that can be retried independently. Persist results through step returns and keep side effects inside steps.
- Make side effects safe to repeat. A retry can happen after an external write succeeds; use the destination's idempotency mechanism or atomic deduplication. A separate check followed by a write does not itself guarantee idempotency.
- Base step names, loops, and branches on stable input or persisted results. In-memory state and fresh time/random values cannot serve as durable replay state.
- Await step operations, and check the documented replay behavior before combining steps in parallel or racing them.
- Keep large data in external storage when appropriate and pass references between steps; consult current return-type and size constraints.
Examples and Orchestration
| Task | Documentation |
|---|---|
| Process images with human approval; handle approval events and timeouts | Human-in-the-loop image tagging |
| Implement a payment and notification sequence | Pay cart and send invoice |
| Export data to object storage | Export and save D1 database |
| Delay lifecycle follow-ups or retry transient failures | Sleeping and retrying |
| Schedule jobs or start child Workflows | Trigger Workflows |
| Design parallel work, races, conditional steps, and batch creation | Rules of Workflows |
Testing Workflows
Fetch Vitest setup for current dependencies and configuration, then use the Workflow test APIs for introspection, step/event mocks, sleep controls, and cleanup.
Test retry behavior, event arrival and timeout paths, and duplicate external effects. Use documented introspection waits to observe completion rather than assuming a newly created instance has finished.
See configuration.md, api.md, and gotchas.md.
Children
No children yet.
Like how this is organised?
Build your own Memory tree on knowen.md: notes, decisions and tasks in one connected markdown graph, shared with your team and your AI agents.