Claude Templates / A-tier · High leverage

Infrastructure

The Trigger.dev Worker Playbook

The three-file pattern for anything that can't finish inside an HTTP request.

TRIGGER-DEV-WORKER-PLAYBOOK.md · 12 sections · 2,590 words · 21 KB · markdown

Any task that can exceed 60 seconds has to leave the request cycle. This is the pattern for doing it without losing work: a worker, a dispatch route, and a bridge — plus orphan recovery, refund-on-failure, and mount-time resume so a closed browser tab doesn't strand a job.

What's inside

When to use it

The moment a task can exceed 60 seconds.

Build these first

App Infrastructure

Straight from the file

Browser-bound generation paths and /api/generate-style routes that await long providers are banned. Tab close mid-render orphans the pipeline row, burns credit, and silently corrupts state. The pattern below eliminates that entire class of bug.

Table of contents

  1. 0. The universal rule
  2. 1. Use this spec
  3. 2. Architecture
  4. 3. The three-file pattern
  5. 4. Worker self-heal (Vara incident pattern)
  6. 5. Generic status endpoint — [/api/jobs/[runId]/route.ts](file:///<reference-app>/src/app/api/jobs/[runId]/route.ts)
  7. 6. trigger.config.ts — build extensions
  8. 7. Mount-time orphan recovery (pipeline page wiring)
  9. 8. Auto-deploy rule (mandatory)
  10. 9. The audit-orphan-charges cron (final safety net)
  11. 10. Common pitfalls
  12. 11. Kickoff prompt

How to run it

Drop TRIGGER-DEV-WORKER-PLAYBOOK.md into your repo, then tell Claude Code: “Read TRIGGER-DEV-WORKER-PLAYBOOK.md and implement it in this codebase.” It's written for an agent to execute end to end. Search the file for angle-bracket placeholders and swap in your own project names, domains, and keys before the first run.

↓ Download the playbook

More infrastructure playbooks

← All 28 Claude templates