Skip to content

CLI Commands Reference

Fresh

Complete reference for all Trigger.dev CLI commands.

Installation

bash
# Always use latest
npx trigger.dev@latest [command]

# Or install globally
npm install -g trigger.dev

Core Commands

init — Initialize a Project

bash
npx trigger.dev@latest init
OptionDescription
--project-ref -pProject reference (skips selection prompt)
--trigger-dirCustom directory for trigger files
--skip-package-installDon't install npm packages

What it does:

  • Optionally installs MCP server for AI assistants
  • Logs you in (if not already)
  • Lets you select your project
  • Installs @trigger.dev/sdk
  • Creates /trigger directory with example task
  • Creates trigger.config.ts

dev — Start Dev Server

bash
npx trigger.dev@latest dev
OptionDescription
--config -cConfig file path (default: trigger.config.ts)
--project-ref -pProject ref (if no config file)
--env-fileLoad env vars from file
--skip-update-checkSkip @trigger.dev/* package update check
--analyzeShow import timing analysis

Common options (all commands):

OptionDescription
--profileLogin profile to use (default: "default")
--api-url -aOverride API URL
--log-level -ldebug, info, log, warn, error, none
--skip-telemetryOpt out of telemetry
--help -hShow help
--version -vShow version

deploy — Deploy to Production

bash
npx trigger.dev@latest deploy
OptionDescription
--envEnvironment: prod (default) or staging
--skip-promotionDeploy without making it the current version
--force-local-buildBuild locally using Docker instead of remote
--dry-runBuild and inspect without deploying
--log-level debugVerbose debug output

login / logout — Authentication

bash
npx trigger.dev@latest login
npx trigger.dev@latest logout

# Use a specific profile
npx trigger.dev@latest login --profile staging

promote — Promote a Version

bash
npx trigger.dev@latest promote 20260221.1

Makes a previously deployed (but not current) version the active current version.


whoami — Check Auth Status

bash
npx trigger.dev@latest whoami

Concurrently (Running Dev + App Server Together)

Install concurrently as a dev dependency, then add to package.json:

json
{
  "scripts": {
    "dev": "concurrently --raw --kill-others npm:dev:*",
    "dev:trigger": "npx trigger.dev@latest dev",
    "dev:next": "next dev"
  }
}

Environment Variables

VariableDescription
TRIGGER_SECRET_KEYAPI key for triggering tasks (tr_dev_xxx or tr_prod_xxx)
TRIGGER_API_URLOverride API endpoint
TRIGGER_VERSIONPin all tasks to a specific version
TRIGGER_PREVIEW_BRANCHSet preview branch name
TRIGGER_TELEMETRY_DISABLEDOpt out of telemetry (set to any non-empty value)

SDK Quick Reference

Triggering

ts
import { tasks, batch } from "@trigger.dev/sdk";

// Single task (from backend, no import needed)
await tasks.trigger("task-id", payload);

// Batch same task
await tasks.batchTrigger("task-id", items.map(p => ({ payload: p })));

// Batch different tasks
await batch.trigger([
  { id: "task-1", payload: data1 },
  { id: "task-2", payload: data2 },
]);

Triggering from Inside a Task

ts
import { task } from "@trigger.dev/sdk";
import { childTask } from "./child-task";

export const parentTask = task({
  id: "parent",
  run: async (payload) => {
    // Fire and forget
    await childTask.trigger(data);

    // Wait for result
    const result = await childTask.triggerAndWait(data);

    // Batch + wait
    const results = await childTask.batchTriggerAndWait(items);

    // Mixed tasks + wait
    const mixed = await batch.triggerAndWait([
      { id: "task-a", payload: dataA },
      { id: "task-b", payload: dataB },
    ]);
  }
});

Trigger Options

ts
await myTask.trigger(payload, {
  delay: "1h",                    // Delay execution
  ttl: "30m",                     // Expire if not started
  idempotencyKey: "unique-key",   // Prevent duplicates
  debounce: {                     // Debounce
    key: "user-123",
    delay: "5s",
    mode: "trailing",             // "leading" (default) or "trailing"
    maxDelay: "1m"
  },
  queue: {
    name: "priority-queue",
    concurrencyLimit: 10
  },
  concurrencyKey: userId,         // Per-entity queues
  maxAttempts: 5,                 // Override retry count
  machine: "large-1x",           // Machine preset
  region: "eu-central-1",        // Run region
  version: "20260221.1",         // Pin version
});

Task Configuration Cheatsheet

ts
export const myTask = task({
  id: "my-task",                  // Required, unique
  retry: {
    maxAttempts: 3,               // Default: 3
    factor: 2,                    // Backoff multiplier
    minTimeoutInMs: 1000,
    maxTimeoutInMs: 30000,
    randomize: true,
  },
  queue: {
    concurrencyLimit: 5,          // Global limit for this task
  },
  machine: {
    preset: "large-1x",           // micro, small-1x, medium-1x, large-1x, etc.
  },
  maxDuration: 300,               // Seconds — stop if exceeded
  run: async (payload, { ctx }) => {
    // ctx.run.id, ctx.run.attempt.number, etc.
    return { result: "done" };
  },
});

Built from official Trigger.dev documentation