Skip to content
Skillv1.0.0

trigger-dev

You are an expert in Trigger.dev, the open-source background jobs platform for TypeScript. You help developers build reliable long-running tasks, scheduled jobs, webhook handlers, and event-driven wor

by terminalskills(0) 0 installs
Free
Sign in to install

Free account. Installing gives you the manifest plus copy-paste snippets.

See reviews

About

Imported from terminalskills/skills (skills/trigger-dev/SKILL.md). Install upstream with npx skills add terminalskills/skills --skill trigger-dev. Copyright stays with the author (Apache-2.0).

Trigger.dev — Background Jobs for TypeScript

You are an expert in Trigger.dev, the open-source background jobs platform for TypeScript. You help developers build reliable long-running tasks, scheduled jobs, webhook handlers, and event-driven workflows with automatic retries, concurrency control, real-time logs, and deployment to serverless infrastructure — replacing BullMQ/Redis setups with a fully managed or self-hosted solution purpose-built for modern TypeScript apps.

Core Capabilities

Task Definition

// trigger/tasks/process-order.ts
import { task, wait, logger, retry } from "@trigger.dev/sdk/v3";

export const processOrder = task({
  id: "process-order",
  retry: {
    maxAttempts: 3,
    factor: 2,
    minTimeoutInMs: 1000,
    maxTimeoutInMs: 30000,
  },
  run: async (payload: { orderId: string; userId: string }) => {
    logger.info("Processing order", { orderId: payload.orderId });

    // Step 1: Validate
    const order = await db.orders.findById(payload.orderId);
    if (!order) throw new Error(`Order ${payload.orderId} not found`);

    // Step 2: Charge payment (auto-retries on failure)
    const payment = await retry.onThrow(
      async () => stripe.paymentIntents.create({
        amount: order.total * 100,
        currency: "usd",
        customer: order.stripeCustomerId,
      }),
      { maxAttempts: 3, randomize: true },
    );

    logger.info("Payment charged", { paymentId: payment.id });

    // Step 3: Wait for webhook confirmation (durable wait)
    const confirmation = await wait.for({ seconds: 300 });

    // Step 4: Send notification
    await sendEmail(order.userEmail, "order-confirmed", { orderId: order.id });

    return { orderId: order.id, paymentId: payment.id, status: "completed" };
  },
});

// Scheduled task (cron)
export const dailyReport = task({
  id: "daily-report",
  run: async () => {
    const stats = await db.orders.aggregate({
      today: { count: true, sum: "total" },
    });
    await sendSlackMessage("#reports", `Daily: ${stats.count} orders, $${stats.sum}`);
  },
});

Triggering Tasks

// From your API route
import { tasks } from "@trigger.dev/sdk/v3";

// Trigger and forget
await tasks.trigger("process-order", {
  orderId: "ord-123",
  userId: "usr-456",
});

// Trigger and wait for result
const result = await tasks.triggerAndWait("process-order", {
  orderId: "ord-123",
  userId: "usr-456",
});

// Batch trigger
await tasks.batchTrigger("process-order", [
  { payload: { orderId: "ord-1", userId: "usr-1" } },
  { payload: { orderId: "ord-2", userId: "usr-2" } },
  { payload: { orderId: "ord-3", userId: "usr-3" } },
]);

// Schedule
await tasks.schedule("daily-report", {
  cron: "0 9 * * *",                     // Daily at 9 AM
  timezone: "America/New_York",
});

// Delayed
await tasks.trigger("send-reminder", {
  userId: "usr-456",
}, {
  delay: "24h",                           // Run in 24 hours
});

Webhook Handler

import { task } from "@trigger.dev/sdk/v3";

export const handleStripeWebhook = task({
  id: "stripe-webhook",
  run: async (payload: { type: string; data: any }) => {
    switch (payload.type) {
      case "payment_intent.succeeded":
        await db.orders.update(payload.data.metadata.orderId, { status: "paid" });
        await tasks.trigger("ship-order", { orderId: payload.data.metadata.orderId });
        break;
      case "customer.subscription.deleted":
        await handleChurn(payload.data.customer);
        break;
    }
  },
});

Installation

npx trigger.dev@latest init               # Initialize in existing project
npx trigger.dev@latest dev                 # Local development
npx trigger.dev@latest deploy              # Deploy to Trigger.dev cloud

Best Practices

  1. Idempotent tasks — Design tasks to be safely retried; use unique IDs for payment/email operations
  2. Structured logging — Use logger.info/warn/error with objects; visible in Trigger.dev dashboard
  3. Retry configuration — Set appropriate retry strategies per task; payment tasks need different retries than emails
  4. Concurrency limits — Set concurrencyLimit to prevent overwhelming downstream services
  5. Wait for events — Use wait.for for durable waits; task resumes even after server restarts
  6. Batch for throughput — Use batchTrigger for bulk operations; processed in parallel with concurrency control
  7. Environment separation — Use dev/staging/prod environments; preview deployments for testing
  8. Self-hosted option — Deploy Trigger.dev on your own infra with Docker; full control over data and execution

Use it

Copy one of these into your project. Installing also returns the manifest and these snippets.

yaml
targets:
  - https://api.opensmartroute.ai/api/v1/registry/terminalskills-skills-trigger-dev/manifest   # or paste the manifest below

Manifest

An Open Capability Manifest: the router reads it to know what this does, what it costs and when to pick it.

terminalskills-skills-trigger-dev.ocm.jsonjson
{
  "ocm": "1",
  "id": "terminalskills-skills-trigger-dev",
  "kind": "skill",
  "name": "trigger-dev",
  "description": "You are an expert in Trigger.dev, the open-source background jobs platform for TypeScript. You help developers build reliable long-running tasks, scheduled jobs, webhook handlers, and event-driven workflows with automatic retries, concurrency control, real-time logs, and deployment to serverless infrastructure — replacing BullMQ/Redis setups with a fully managed or self-hosted solution purpose-built for modern TypeScript apps.",
  "publisher": "terminalskills",
  "version": "1.0.0",
  "capabilities": {
    "domains": [
      "coding"
    ],
    "tags": [
      "skill-md",
      "background-jobs",
      "serverless",
      "durable",
      "typescript",
      "cron",
      "event-driven",
      "skills-sh"
    ],
    "languages": [
      "en"
    ]
  },
  "quality_prior": 0.6,
  "examples": [
    "You are an expert in Trigger.dev, the open-source background jobs platform for TypeScript. You help developers build reliable long-running tasks, scheduled jobs, webhook handlers, and event-driven workflows with automatic retries, concurrency control, real-time logs, and deployment to serverless infrastructure — replacing BullMQ/Redis setups with a fully managed or self-hosted solution purpose-built for modern TypeScript apps."
  ],
  "primary": false,
  "metadata": {
    "source": {
      "provider": "skills.sh",
      "repository": "https://github.com/terminalskills/skills",
      "path": "skills/trigger-dev/SKILL.md",
      "ref": "HEAD",
      "url": "https://github.com/terminalskills/skills/blob/HEAD/skills/trigger-dev/SKILL.md",
      "key": "terminalskills/skills/skills/trigger-dev/SKILL.md"
    },
    "license": "Apache-2.0"
  },
  "instructions": "# Trigger.dev — Background Jobs for TypeScript\n\nYou are an expert in Trigger.dev, the open-source background jobs platform for TypeScript. You help developers build reliable long-running tasks, scheduled jobs, webhook handlers, and event-driven workflows with automatic retries, concurrency control, real-time logs, and deployment to serverless infrastructure — replacing BullMQ/Redis setups with a fully managed or self-hosted solution purpose-built for modern TypeScript apps.\n\n## Core Capabilities\n\n### Task Definition\n\n```typescript\n// trigger/tasks/process-order.ts\nimport { task, wait, logger, ",
  "cost": {
    "context_tokens": 1164
  }
}

Fetch it by URL: GET /api/v1/registry/terminalskills-skills-trigger-dev/manifest?version=1.0.0

Reviews

Star ratings from people who tried it. One review per account; edit yours any time.

No reviews yet. Install it, try it, and be the first to rate it.