All skills
triggerdotdev avatar

/trigger-cost-savings

@354e38c official
by Trigger.devtriggerdotdev/skills32 stars
7

Analyze Trigger.dev tasks, schedules, and runs for cost optimization opportunities. Use when asked to reduce spend, optimize costs, audit usage, right-size machines, or review task efficiency. Combines static source analysis with live run analysis via the Trigger.dev MCP tools (list_runs, get_run_details, get_current_worker).

Use this Skill: https://skilld.dev/gh/triggerdotdev/skills/trigger-cost-savings

This session only. Nothing lands on disk.

SKILL.md

β‰ˆ87 tokens always: the name and description. β‰ˆ1.2k when used: this file.

Trigger.dev Cost Savings Analysis

Analyze task runs and configurations to find cost reduction opportunities. This skill pairs static source analysis with live run analysis via the Trigger.dev MCP server.

Before you start: read the canonical guidance

The authoritative, version-pinned cost guidance ships beside this skill. Read it first so your recommendations match the installed SDK version:

  • @trigger.dev/sdk/docs/how-to-reduce-your-spend.mdx β€” the canonical "reduce your spend" guide (machine sizing, idempotency de-dup, parallelism, retries, maxDuration, checkpointed waits, debounce).
  • Supporting references: @trigger.dev/sdk/docs/machines.mdx, runs/max-duration.mdx, queue-concurrency.mdx, idempotency.mdx, triggering.mdx (debounce + batch), errors-retrying.mdx (AbortTaskRunError).

Prerequisites: MCP tools

Live run analysis needs the Trigger.dev MCP server. Verify these tools are available:

  • list_runs β€” list runs with filters (status, task, time period, machine size)
  • get_run_details β€” get run logs, duration, and status
  • get_current_worker β€” get registered tasks and their configurations

If they're not available, tell the user to install the MCP server:

npx trigger.dev@latest install-mcp

Without the MCP tools you can still do the static source analysis below; do not fabricate run data.

Analysis workflow

Step 1: Static analysis (source code)

Scan task files for:

  1. Oversized machines β€” tasks on large-1x/large-2x without clear need.
  2. Missing maxDuration β€” no execution-time limit (runaway-cost risk).
  3. Excessive retries β€” maxAttempts > 5 without AbortTaskRunError for known-permanent failures.
  4. Missing debounce β€” high-frequency triggers without debounce.
  5. Missing idempotency β€” payment/critical tasks without idempotency keys.
  6. Polling instead of waits β€” setTimeout/setInterval/sleep loops instead of wait.for().
  7. Short waits β€” wait.for() under 5 seconds (not checkpointed, wastes compute).
  8. Sequential instead of batch β€” multiple triggerAndWait() calls that could be batchTriggerAndWait().
  9. Over-scheduled crons β€” schedules firing more often than needed.

Step 2: Run analysis (requires MCP tools)

  • 2a. Expensive tasks β€” list_runs over period: "30d"/"7d"; find high total compute (duration Γ— count), high failure rates, and large machines with short durations (over-provisioned).
  • 2b. Failure patterns β€” list_runs with status: "FAILED"/"CRASHED"; separate transient (retryable) from permanent; suggest AbortTaskRunError for the latter; estimate wasted retry compute.
  • 2c. Machine utilization β€” get_run_details on sample runs; if a large-2x task consistently runs in under a second, or is I/O-bound (API/DB), it's over-provisioned.
  • 2d. Schedule frequency β€” get_current_worker to list cron patterns; flag schedules that are too frequent for their purpose.

Step 3: Generate recommendations

Present a prioritized report with estimated impact:

## Cost Optimization Report

### High impact
1. **Right-size `process-images`** β€” currently `large-2x`, average run 2s. `small-2x` could cut this task's cost by ~16x.
   `machine: { preset: "small-2x" }`  // was "large-2x"

### Medium impact
2. **Debounce `sync-user-data`** β€” 847 runs/day, often bursty.
   `debounce: { key: \`user-${userId}\`, delay: "5s" }`

### Low impact / best practice
3. **Add `maxDuration` to `generate-report`** β€” no timeout configured.
   `maxDuration: 300`  // 5 minutes

Machine preset costs (relative)

Larger machines cost proportionally more per second of compute:

Preset vCPU RAM Relative cost
micro 0.25 0.25 GB 0.25x
small-1x 0.5 0.5 GB 1x (baseline)
small-2x 1 1 GB 2x
medium-1x 1 2 GB 2x
medium-2x 2 4 GB 4x
large-1x 4 8 GB 8x
large-2x 8 16 GB 16x

Key principles

  • Waits > 5 seconds are free β€” checkpointed, no compute charge.
  • Start small, scale up β€” the default small-1x is right for most tasks.
  • I/O-bound tasks don't need big machines β€” API calls and DB queries wait on the network.
  • Debounce saves the most on high-frequency tasks β€” it consolidates bursts into single runs.
  • Idempotency prevents duplicate billed work β€” especially for expensive operations.
  • AbortTaskRunError stops wasteful retries β€” don't pay to retry permanent failures.

Version

This skill is bundled inside @trigger.dev/sdk and read directly from node_modules, so it always matches your installed SDK version (see the adjacent package.json). The full cost documentation ships alongside it under @trigger.dev/sdk/docs/.

Source: SKILL.md on GitHub

No alerts16d5 checks Β· Risk SAFE
  • Gen Agent Trust Hub16d

    The skill facilitates cost optimization for Trigger.dev by analyzing source code and run data. It is safe to use and follows standard vendor procedures, though it includes a potential surface for indirect prompt injection when processing run logs.

  • Socket16d

    No alerts

  • Snyk16d

    Risk: LOW Β· No issues

  • Runlayer7mo

    2/2 files flagged

  • ZeroLeaks5mo

    Score: 93/100 Β· 2 sections analyzed

Signed by skilld at 354e38c. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 months ago.

Activeupdated 2 months ago
type
core
library
trigger.dev
Other metadata
sources
[
  "docs/how-to-reduce-your-spend.mdx",
  "docs/machines.mdx",
  "docs/runs/max-duration.mdx",
  "docs/queue-concurrency.mdx",
  "docs/idempotency.mdx",
  "docs/triggering.mdx",
  "docs/errors-retrying.mdx",
  "docs/limits.mdx"
]
  • Infrastructure
  • trigger.dev
  • cost-optimization
  • performance-tuning
  • resource-management
  • task-scheduling
  • mcp-tools

README badge

README badge for triggerdotdev/skills/trigger-cost-savings

Analyzes Trigger.dev task runs, schedules, and configurations to identify cost optimization opportunities like oversized machines, excessive retries, missing debounce settings, and inefficient polling patterns. Requires the Trigger.dev MCP server to fetch live run data and provides prioritized recommendations with estimated cost impact.

Generated from the current SKILL.md.

Does this skill require Trigger.dev MCP tools?
Yes. The skill needs the Trigger.dev MCP server installed to analyze live run data via `list_runs`, `get_run_details`, and `get_current_worker`. Static source code analysis works without MCP, but full cost auditing requires it.
What kinds of cost issues does this skill detect?
It identifies oversized machine presets, missing execution time limits, excessive retries, high-frequency triggers without debounce, polling instead of waits, sequential calls that should batch, and schedules running too frequently. It also flags failure patterns that waste compute on retries.
How does the skill prioritize recommendations?
Recommendations are ranked by estimated cost impact. High-impact items like machine right-sizing are listed first, followed by medium-impact optimizations like debounce, then low-impact best practices like adding `maxDuration` constraints.
Can this skill analyze tasks without installing MCP?
Partially. Static analysis of source code (checking for oversized machines, missing timeouts, excessive retries) works without MCP. Live run analysis and failure pattern detection require the MCP server.

Generated from the current SKILL.md. These answers refresh after source changes.