SkilVaultSign inStart free

Catalogue / typed-background-task-design

typed-background-task-design

Older skill: source not recordedSignedDesigns Trigger.dev tasks for reliable TypeScript background work, including AI pipelines, schedules, integrations, webhooks, queues, and batches. Use for task implementation or retry and concurrency problems. Not for deploying jobs or calling production services without approval.
---
name: typed-background-task-design
description: >-
  Designs Trigger.dev tasks for reliable TypeScript background work, including AI pipelines, schedules, integrations, webhooks, queues, and batches. Use for task implementation or retry and concurrency problems. Not for deploying jobs or calling production services without approval.
---

Typed background task design

Inspect the local application's framework, Trigger.dev SDK and CLI versions, configuration location, and existing task examples. The source describes a Next.js setup and a package-root trigger.config.ts; verify these against the installed workspace layout. Use local SDK types and examples to determine supported APIs rather than inventing version-specific imports.

Preview the proposed tasks and obtain explicit human confirmation before writing files, installing or updating packages, altering cloud configuration, scheduling work, deploying, invoking a task, or contacting an external service. Ask the owner to configure cloud secrets through the approved interface; do not inspect or copy credential files.

Divide work by retry boundary

For basic setup, identify the package root, task discovery configuration, typed payload, handler, and caller. Keep request handling short: validate the request and enqueue an authorized task rather than running a long job inside an HTTP response. Return a run identifier and expose progress through the application's existing mechanism.

Split a long AI or integration pipeline into meaningful tasks with explicit inputs and outputs. For an OpenAI stage, use the integration supported by the installed version, identify which retries it provides, and coordinate those with task retries so a nested retry loop does not multiply calls. Log sanitized stage transitions and request identifiers, excluding prompts with private content or tokens.

Use plain serializable payloads. Replace class instances, functions, streams, and circular objects with identifiers or validated ordinary data. Pass large data by protected reference rather than repeating it across tasks. Set an explicit execution timeout and document how cancellation and partial progress are handled; a killed task must have a discoverable failure outcome.

Control when and how work runs

A scheduled task needs a cron expression, explicit time zone, overlap policy, and missed-run behavior verified in local SDK configuration. A webhook handler needs signature validation, deduplication, and durable enqueueing before acknowledgment. Batch work needs bounded batch sizes and queue concurrency aligned with downstream capacity.

Do not build a massive handler that retries every completed effect after one final failure. Use stable idempotency keys for externally visible effects, derived from the business operation rather than the retry attempt. Confirm how completed work is recognized before retrying. Account for built-in integrations instead of reimplementing them without a reason.

The source warns about repeated wait.for use in loops. Prefer bounded batches or the installed SDK's supported bulk waiting mechanism; verify behavior locally rather than assuming all versions have the same memory characteristic.

Check configuration and failures

Keep CLI and SDK compatibility under review together; propose coordinated changes rather than silently upgrading either. Compare declared environment-variable names between local configuration and the cloud task setup without revealing values. An owner must provision missing secrets through the approved mechanism before execution.

Test task contracts offline with synthetic payloads: malformed input, non-serializable data, timeout, retry after a partial effect, duplicate webhook, and concurrency saturation. Confirm logging covers startup, stages, retries, and final outcome. Report installed-version assumptions, queue limits, timeout policy, idempotency strategy, and any untested cloud behavior.

Never

  • Send non-serializable payloads or leave timeouts and queue limits implicit.
  • Retry side effects without deduplication or omit operational logs.
  • Expose secrets, copy credential files, or assume local configuration is present in the cloud.
  • Install, edit, schedule, invoke, synchronize configuration, or deploy without explicit human confirmation.