Home › Temporal workflows › Temporal workflows AGENTS.md

Temporal workflows AGENTS.md

AGENTS.md for Temporal applications: deterministic workflows, idempotent activities, retries and timeouts, versioning safe changes, and replay tests.

AGENTS.mdTemporal workflows

How to use

Save this as AGENTS.md in your repository root, commit it, and your agent will pick it up automatically. Edit the commands to match your project.

Note: Review and test before use. Provided as is, without warranty. See Terms.

AGENTS.mdDownload  
# AGENTS.md: Temporal workflows

## Commands
- Local server: `temporal server start-dev` (UI at http://localhost:8233)
- Run worker: see `package.json`/`Makefile` (e.g. `npm run worker`, `go run ./worker`, `python -m app.worker`)
- Tests: the SDK's test environment (time-skipping) via the normal test command.
- Inspect: `temporal workflow list`, `temporal workflow show --workflow-id <id>`.

## Code map
`workflows/` (orchestration only) · `activities/` (all I/O) · `worker` entrypoint registering both on a named task queue · `client` code that starts workflows.

## Workflow rules (determinism)
- Workflow code must be deterministic: no network, DB, file I/O, random numbers, system time, threads or non-deterministic iteration. Use SDK APIs instead (`workflow.now()`, `workflow.sleep()`, SDK random/UUID helpers).
- All side effects happen in activities. Workflows only orchestrate: call activities, child workflows, timers, signals, queries and updates.
- Changing workflow code that already has running executions needs versioning (`patched`/`GetVersion`/Worker Versioning). Never reorder or remove activity calls without it.
- Keep workflow inputs and history small: pass IDs, not large payloads; use `continueAsNew` for long-running or looping workflows.
- Use stable, business-meaningful workflow IDs to get deduplication.

## Activity rules
- Activities are idempotent (safe to retry): use idempotency keys or upserts.
- Always set `startToCloseTimeout` (and `heartbeatTimeout` + heartbeats for long activities); configure `RetryPolicy` with backoff and mark permanent failures non-retryable.
- No business secrets in workflow inputs or results; payloads are stored in history (use a codec for encryption if needed).

## Tests
Unit-test activities directly; test workflows with the SDK test environment and mocked activities; add a replay test against saved histories when changing workflow code.

## Done
Tests and replay tests pass and the worker starts against the dev server.

More: all Temporal workflows rules · all AGENTS.md rules

Related rules

REST API design AGENTS.md

AGENTS.md for designing consistent HTTP/JSON APIs: resource naming, status codes, errors, pagination, and versioning.

AGENTS.mdAPI design

Blazor (.NET 10) AGENTS.md

AGENTS.md for Blazor Web Apps on .NET 10: render modes, components, forms and validation, state, and bUnit tests.

AGENTS.md.NET / ASP.NET Core

Celery background jobs AGENTS.md

AGENTS.md for Celery 5 task queues in Python/Django: idempotent tasks, retries, time limits, and safe enqueueing.

AGENTS.mdPython

Deno 2 AGENTS.md

AGENTS.md for Deno 2 projects: deno.json tasks, JSR and npm imports, permissions, and built-in tooling.

AGENTS.mdDeno

Effect TypeScript AGENTS.md

AGENTS.md for TypeScript codebases built on Effect: typed errors, services and Layers, Schema validation, resource safety, and @effect/vitest tests.

AGENTS.mdEffect (TypeScript)

Express 5 API AGENTS.md

AGENTS.md for Express 5 REST APIs in TypeScript with zod validation, error middleware, and supertest.

AGENTS.mdNode.js / TypeScript

Get the best new AI prompts every week

One short email a week: the best new prompts and rules for ChatGPT, Claude, Gemini, Midjourney, Cursor and more, plus what changed in the tools. Free, unsubscribe anytime.

Finishes on our newsletter page at beehiiv (opens in a new tab). Or subscribe directly.