Loading...
Loading...
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. Requires Trigger.dev MCP tools for run analysis.
npx skill4agent add triggerdotdev/skills trigger-cost-savingslist_runsget_run_detailsget_current_workerTo analyze your runs, you need the Trigger.dev MCP server installed.
Run this command to install it:
npx trigger.dev@latest install-mcp
This launches an interactive wizard that configures the MCP server for your AI client.WebFetch: https://trigger.dev/docs/how-to-reduce-your-spendreferences/cost-reduction.mdlarge-1xlarge-2xmaxDurationmaxAttemptsAbortTaskRunErrorsetTimeoutsetIntervalwait.for()wait.for()triggerAndWait()batchTriggerAndWait()list_runs with filters:
- period: "30d" or "7d"
- Sort by duration or cost
- Check across different task IDslist_runs with status: "FAILED" or "CRASHED"AbortTaskRunErrorget_run_details for sample runs of each tasklarge-2xget_current_worker to list scheduled tasks and their cron patterns## Cost Optimization Report
### High Impact
1. **Right-size `process-images` machine** — Currently `large-2x`, average run 2s.
Switching to `small-2x` could reduce this task's cost by ~16x.
```ts
machine: { preset: "small-2x" } // was "large-2x"sync-user-datadebounce: { key: `user-${userId}`, delay: "5s" }maxDurationgenerate-reportmaxDuration: 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** — default `small-1x` is right for most tasks
- **I/O-bound tasks don't need big machines** — API calls, DB queries wait on network
- **Debounce saves the most on high-frequency tasks** — consolidates bursts into single runs
- **Idempotency prevents duplicate work** — especially important for expensive operations
- **`AbortTaskRunError` stops wasteful retries** — don't retry permanent failures
See `references/cost-reduction.md` for detailed strategies with code examples.