queue-patterns
Guides the implementation and management of message queue handlers and job enqueuing.
Install
mkdir -p .claude/skills/queue-patterns && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/15777" && unzip -o skill.zip -d .claude/skills/queue-patterns && rm skill.zipInstalls to .claude/skills/queue-patterns
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
How the @repo/queue package works in this repo. BullMQ queue + worker pattern. Use when: adding new job types, creating handlers, enqueuing jobs, or debugging queue issues.Key capabilities
- →Define payload types for new job types
- →Add handler functions for specific job types
- →Enqueue jobs from any application
- →Enqueue jobs with a specified delay
- →Configure worker concurrency
How it works
The skill uses BullMQ with Redis to define job payload types, implement handlers, and enqueue jobs, ensuring strict typing and background processing.
Inputs & outputs
When to use queue-patterns
- →Adding new job types
- →Implementing queue handlers
- →Debugging queue issues
About this skill
Queue Patterns — @repo/queue
Architecture
Any app (producer) apps/worker (consumer)
────────────────── ──────────────────────
QueueService.addJob() ──► Redis ──► WorkerService ──► handler function
- QueueService — enqueues jobs (used in any app)
- WorkerService — consumes jobs and runs handler functions (runs in
apps/worker) - Both use BullMQ under the hood and share the same Redis server + queue name
Adding a new job type
Step 1 — Define the payload type
File: packages/queue/src/types.ts
export interface JobPayloadMap {
"email.send": { to: string; subject: string; body: string }
"bulk.email.send": { to: string; subject: string; body: string }[]
// ↓ add new types here
"your.job": { yourField: string }
}
Step 2 — Add a handler
File: apps/worker/src/handlers/index.ts
export const handlers: JobHandlerMap = {
// ... existing handlers ...
"your.job": async (payload, logger) => {
// payload is strictly typed from JobPayloadMap
logger.info(`Processing ${payload.yourField}`)
}
}
TypeScript enforces that every key in JobPayloadMap has a matching handler.
Step 3 — Enqueue from any app
import { QueueService } from "@repo/queue"
const queue = new QueueService({ redis, logger })
await queue.addJob("your.job", { yourField: "value" })
// With delay:
await queue.addJob("your.job", { yourField: "value" }, { delay: 60_000 })
Key details
QueueServiceusesredis.client.duplicate()internally — the RedisClient namespace does NOT affect queue keys- BullMQ manages its own keys (e.g.
bull:default:*) — separate from the caching namespace - The worker creates its own
RedisClientbecause it's a separate process - Queue name is configurable via
QUEUE_NAMEenv var (defaults to"default") - Worker concurrency is configurable via
WORKER_CONCURRENCYenv var
Worker env
REDIS_URL=redis://localhost:6379
QUEUE_NAME=default
WORKER_CONCURRENCY=3
Prerequisites
Limitations
- →Requires a Redis server
- →Relies on BullMQ for queue management
How it compares
This skill provides a structured pattern for queue management with type enforcement and separate services for enqueuing and consuming jobs, unlike direct message queue interactions.
Compared to similar skills
queue-patterns side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| queue-patterns (this skill) | 0 | 6mo | No flags | Intermediate |
| telegram-bot-builder | 106 | 6mo | Review | Intermediate |
| workflow-orchestration-patterns | 10 | 2mo | No flags | Advanced |
| bullmq-specialist | 25 | 6mo | No flags | Intermediate |
Try saying
Example prompts that trigger this skill in your AI assistant.
You might also like
telegram-bot-builder
davila7
Expert in building Telegram bots that solve real problems - from simple automation to complex AI-powered bots. Covers bot architecture, the Telegram Bot API, user experience, monetization strategies, and scaling bots to thousands of users. Use when: telegram bot, bot api, telegram automation, chat bot telegram, tg bot.
workflow-orchestration-patterns
wshobson
Design durable workflows with Temporal for distributed systems. Covers workflow vs activity separation, saga patterns, state management, and determinism constraints. Use when building long-running processes, distributed transactions, or microservice orchestration.
bullmq-specialist
davila7
BullMQ expert for Redis-backed job queues, background processing, and reliable async execution in Node.js/TypeScript applications. Use when: bullmq, bull queue, redis queue, background job, job queue.
workflow
vercel
Creates durable, resumable workflows using Vercel's Workflow DevKit. Use when building workflows that need to survive restarts, pause for external events, retry on failure, or coordinate multi-step operations over time. Triggers on mentions of "workflow", "durable functions", "resumable", "workflow devkit", or step-based orchestration.
trigger-dev
davila7
Trigger.dev expert for background jobs, AI workflows, and reliable async execution with excellent developer experience and TypeScript-first design. Use when: trigger.dev, trigger dev, background task, ai background job, long running task.
convex-cron-jobs
waynesutton
Scheduled function patterns for background tasks including interval scheduling, cron expressions, job monitoring, retry strategies, and best practices for long-running tasks