Orchestrate Background Jobs and AI Workflows
Trigger.dev background jobs, AI workflows, and scheduled tasks in TypeScript, with fixes for common pitfalls.
Why it matters
Build reliable, background job processing and AI-driven workflows with Trigger.dev. Ensure durable execution, automatic retries, and seamless integration with your existing tools.
Outcomes
What it gets done
Implement background tasks with automatic retries
Integrate AI models for long-running tasks
Schedule recurring jobs using cron syntax
Handle webhook events with idempotency
Install
Add it to your toolbox
Run in your project directory:
curl -fsSL https://spark.entire.vc/get/ag-trigger-dev | bash Overview
Trigger.dev Integration
Covers Trigger.dev for durable background jobs and AI workflows in TypeScript: task/schedule/webhook patterns plus ten sharp-edge pitfalls (serialization, timeouts, env sync, idempotency, concurrency) with concrete fixes. Use for background jobs, AI async tasks, scheduled/cron work, or webhook processing with Trigger.dev; routes Redis queues, pure event-driven, and workflow-orchestration needs to other specialist skills.
What it does
This skill covers Trigger.dev for building durable, retryable background jobs and AI workflows in TypeScript, built on the principle that tasks are independently retryable, runs survive crashes, and integrations should use Trigger.dev's built-in API wrappers rather than raw SDKs. It shows concrete patterns: basic task setup (trigger.config.ts plus a task() definition, fire-and-forget vs handle.wait() for the result), AI tasks using the built-in @trigger.dev/openai integration (automatic retries baked in), scheduled/cron tasks (schedules.task() for daily cleanup or weekly reports), rate-limited batch processing with queue.concurrencyLimit and wait.for() between items, and idempotent webhook handling (Stripe events deduplicated via idempotencyKeys.create()).
Its most valuable content is a set of ten "sharp edges" with severity ratings and concrete fixes: task timeouts killing execution silently (log progress at each step, use a larger machine.preset, or split into subtasks via triggerAndWait); non-serializable payloads (Date objects, class instances, circular references) silently corrupting data (always pass ISO strings and plain objects); environment variables not syncing to Trigger.dev's cloud separately from Vercel/Railway (push them explicitly with trigger.dev env push); SDK/CLI version mismatches breaking task registration; retries causing duplicate side effects like triple-sent emails or charges (fix with idempotency keys); unbounded concurrency overwhelming downstream APIs like OpenAI (set conservative concurrencyLimit); trigger.config.ts not found in monorepos (must sit at the package root, not repo root); wait.for() inside loops bloating task state (batch instead of per-item waits); using raw SDKs instead of Trigger.dev's wrapped integrations (losing automatic retry/rate-limit handling); and triggering tasks with no local dev server running (silent no-op).
When to use - and when NOT to
Use this skill for background jobs, AI-powered async tasks, scheduled/cron work, webhook processing, and batch data processing built with Trigger.dev's TypeScript SDK. It explicitly routes adjacent needs elsewhere: Redis-backed queues to bullmq-specialist, pure event-driven architectures to inngest, workflow orchestration to temporal-craftsman, and infrastructure concerns to infra-architect.
It is not the tool for those adjacent architectures - if the actual need is a traditional Redis queue, pure event sourcing, or long-running stateful workflow orchestration, one of those alternatives fits better than Trigger.dev's managed task model.
Inputs and outputs
Input is an async job to run reliably - an AI generation task, a scheduled report, a batch of items to process, or a webhook to handle idempotently. Output is a Trigger.dev task definition with appropriate retry configuration, concurrency limits, logging, and (where relevant) idempotency keys, deployable to Trigger.dev's cloud or self-hosted/Docker.
npx trigger.dev@latest dev
Integrations
Built on @trigger.dev/sdk/v3 and the trigger.dev CLI, with framework support for Next.js, Remix, Express, and Hono, and first-class integrations for OpenAI, Anthropic, Resend, Stripe, Slack, and Supabase. Composes with llm-architect, nextjs-app-router, supabase-backend, stripe-integration, and email-systems in workflows like AI background processing or a webhook-to-notification pipeline.
Who it's for
Developers building AI background jobs, scheduled tasks, or reliable webhook/batch processing in TypeScript who want durable, retryable execution without hand-rolling idempotency, concurrency control, and retry logic themselves.
FAQ
Common questions
Discussion
Questions & comments · 0
Sign In Sign in to leave a comment.