
trigger-cost-savings
โ 15,576by triggerdotdev ยท part of triggerdotdev/trigger.dev
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).
This is the playbook your agent receives when the skill activates โ you don't need to read it to use the skill, but it's here to audit before installing.
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).
Analysis workflow
Step 1: Static analysis (source code)
Scan task files for:
- Oversized machines โ tasks on
large-1x/large-2xwithout clear need. - Missing
maxDurationโ no execution-time limit (runaway-cost risk). - Excessive retries โ
maxAttempts> 5 withoutAbortTaskRunErrorfor known-permanent failures. - Missing debounce โ high-frequency triggers without debounce.
- Missing idempotency โ payment/critical tasks without idempotency keys.
- Polling instead of waits โ
setTimeout/setInterval/sleep loops instead ofwait.for(). - Short waits โ
wait.for()under 5 seconds (not checkpointed, wastes compute). - Sequential instead of batch โ multiple
triggerAndWait()calls that could bebatchTriggerAndWait(). - Over-scheduled crons โ schedules firing more often than needed.
Step 2: Run analysis (requires MCP tools)
- 2a. Expensive tasks โ
list_runsoverperiod: "30d"/"7d"; find high total compute (duration ร count), high failure rates, and large machines with short durations (over-provisioned). - 2b. Failure patterns โ
list_runswithstatus: "FAILED"/"CRASHED"; separate transient (retryable) from permanent; suggestAbortTaskRunErrorfor the latter; estimate wasted retry compute. - 2c. Machine utilization โ
get_run_detailson sample runs; if alarge-2xtask consistently runs in under a second, or is I/O-bound (API/DB), it's over-provisioned. - 2d. Schedule frequency โ
get_current_workerto 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 minutesMachine 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-1xis 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.
AbortTaskRunErrorstops 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/.
npx skills add triggerdotdev/trigger.dev --skill "trigger-cost-savings" --full-depthRun this in your project โ your agent picks the skill up automatically.
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 statusget_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-mcpWithout the MCP tools you can still do the static source analysis below; do not fabricate run data.
No common issues documented yet. If you hit a problem, the repository's GitHub Issues page is the best place to look.
Licensed under Apache-2.0โ you can use, modify, and redistribute it under that license's terms.
View the full license file on GitHub โ