Command Palette

Search for a command to run...

YepAPI
Free · All Tools

Background Jobs Agent Skill

Queue workers with BullMQ/Inngest/Trigger.dev, job retries, dead letter queues, concurrency.

queuesjobsbullmqinngest

The Skill

Full content, every format. Copy it, download it, or install with one command.

SKILL.md
---
description: Queue workers with BullMQ/Inngest/Trigger.dev, job retries, dead letter queues, concurrency.
homepage: https://yepapi.com/skills/background-jobs
metadata:
  tags: [queues, jobs, bullmq, inngest]
---

# Background Jobs

## Rules

- Offload slow work to background jobs: emails, image processing, webhooks, reports, AI calls
- BullMQ for self-hosted Redis queues — Inngest or Trigger.dev for serverless/managed
- Every job must be idempotent — safe to retry without side effects (use idempotency keys)
- Retry with exponential backoff: 3-5 attempts, delays of 1s, 10s, 60s, 5min
- Dead letter queue (DLQ): after max retries, move to DLQ for investigation — never silently drop
- Set concurrency limits per queue — prevent worker overload (e.g., `concurrency: 5`)
- Job payloads should be small: pass IDs and references, not full objects
- Separate queues by priority: `critical` (payments), `default` (emails), `low` (analytics)
- Monitor queue depth and processing time — alert when queue backs up

## Patterns

```ts
// BullMQ pattern
import { Queue, Worker } from "bullmq";
const queue = new Queue("emails", { connection: redis });

await queue.add("welcome", { userId }, {
  attempts: 3,
  backoff: { type: "exponential", delay: 1000 },
});

const worker = new Worker("emails", async (job) => {
  await sendWelcomeEmail(job.data.userId);
}, { connection: redis, concurrency: 5 });
```

```ts
// Inngest serverless pattern
import { inngest } from "./client";

export const sendEmail = inngest.createFunction(
  { id: "send-welcome-email", retries: 3 },
  { event: "user/created" },
  async ({ event }) => { await sendWelcomeEmail(event.data.userId); }
);
```

## Avoid

- Processing slow tasks in API request handlers — respond fast, process in background
- Non-idempotent jobs — duplicate execution will cause double charges, double emails
- Unbounded concurrency — will exhaust database connections and memory
- Storing large payloads in the job queue — pass references instead

Install

Why Use the Background Jobs Skill?

Without this skill, your AI guesses at background jobs patterns. It might hallucinate deprecated APIs, use outdated conventions, or miss best practices entirely. With it, your AI follows a proven ruleset — every suggestion aligns with current standards.

Drop this skill into your project and your AI instantly knows the rules. Better code suggestions, fewer errors, faster shipping.

Try These Prompts

These prompts work better with the Background Jobs skill installed. Your AI knows the context and writes code that fits.

"Set up a BullMQ job queue with retries, dead letter queues, and a monitoring dashboard"

"Create background workers for email sending, image processing, and report generation"

"Build an Inngest-based event system with fan-out, throttling, and step functions"

Background Jobs skill — FAQ

It provides patterns for BullMQ, Inngest, and Trigger.dev queue workers with retries, dead letter queues, and concurrency control. Your AI sets up reliable background processing systems.

Run `npx skills add YepAPI/skills --skill background-jobs` in your project root. This copies the skill file into your repo where your AI coding tool can read it automatically.

The skill covers BullMQ for self-hosted Redis queues, Inngest for serverless event-driven jobs, and Trigger.dev for complex workflows. Choose based on your infrastructure and complexity needs.

Want more skills?

Browse all 110 free skills for builders.

See All Skills