engineering-bullmq-game-queues
Use when implementing job queues, matchmaking systems, async game events, delayed jobs, or scheduled tasks with BullMQ. Triggers: queue, matchmaking, async events, jobs, workers, scheduling.
Best use case
engineering-bullmq-game-queues is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Use when implementing job queues, matchmaking systems, async game events, delayed jobs, or scheduled tasks with BullMQ. Triggers: queue, matchmaking, async events, jobs, workers, scheduling.
Teams using engineering-bullmq-game-queues should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/bullmq-game-queues/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How engineering-bullmq-game-queues Compares
| Feature / Agent | engineering-bullmq-game-queues | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Use when implementing job queues, matchmaking systems, async game events, delayed jobs, or scheduled tasks with BullMQ. Triggers: queue, matchmaking, async events, jobs, workers, scheduling.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# BullMQ Game Queues
## Purpose
Job queue patterns for games using BullMQ + Redis — matchmaking, async events, delayed jobs, scheduled tasks.
## When to Use
Trigger: job queue, matchmaking, async events, delayed jobs, scheduled tasks, BullMQ, background processing, game events, retry strategy, dead letter queue
## Prerequisites
- `redis-game-patterns` (Redis connection)
## Core Principles
> Will Wright: "Simulation systems benefit from decoupled event processing."
> Sid Meier: "Queue priorities ensure the most interesting events happen first."
1. **Every game action that can be deferred SHOULD be deferred to a queue** — keep the game loop responsive
2. **Idempotent job processors** — same job can run twice safely without side effects
3. **Use named queues per domain** (matchmaking, events, rewards, notifications)
4. **Exponential backoff for retries, dead letter for permanent failures**
5. **Priority queues for time-sensitive operations** (matchmaking > analytics)
6. **Delayed jobs for scheduled game events** (daily rewards, season changes)
7. **Rate limiting per player to prevent abuse**
## Step-by-Step Instructions
### 1. Install Dependencies
```bash
bun add bullmq ioredis
```
### 2. Configure Redis Connection
Use the connection from `redis-game-patterns`, or create a dedicated one for queues. See `templates/queue-config.ts` for the full configuration pattern.
### 3. Define Job Types
Start with the type definitions in `templates/job-types.ts`. These cover matchmaking, game events, rewards, notifications, and analytics job payloads.
### 4. Create Queues
Use `boilerplate/queues.ts` to define typed queues per domain. Each queue has its own retry strategy, concurrency, and priority settings.
### 5. Implement Workers
See `boilerplate/workers.ts` for worker implementations. Each worker processes jobs from a specific queue with proper error handling, logging, and result tracking.
### 6. Schedule Recurring Jobs
Use `boilerplate/scheduler.ts` to set up cron-based repeatable jobs (daily rewards, leaderboard snapshots, session cleanup) and delayed one-off jobs (season events, timed rewards).
### 7. Monitor & Observe
Add queue event listeners for completed, failed, and stalled jobs. Integrate with your monitoring stack via `monitoring-game-ops`.
## Code Examples
### Adding a matchmaking job
```typescript
import { matchmakingQueue } from './queues';
await matchmakingQueue.add('find-match', {
playerId: 'player_123',
skillRating: 1500,
region: 'us-east',
preferences: { mode: 'ranked', teamSize: 2 },
}, { priority: 1 });
```
### Scheduling a delayed reward
```typescript
import { rewardQueue } from './queues';
await rewardQueue.add('distribute-reward', {
playerId: 'player_123',
rewardType: 'daily-login',
payload: { currency: 100, items: ['item_rare_box'] },
}, { delay: 60_000 }); // 1 minute delay
```
### Processing game events
```typescript
import { gameEventQueue } from './queues';
await gameEventQueue.add('process-event', {
eventType: 'match-completed',
sessionId: 'session_456',
participants: ['player_123', 'player_456'],
outcome: { winnerId: 'player_123', duration: 300 },
});
```
See `boilerplate/queues.ts` for full queue definitions, `boilerplate/workers.ts` for worker implementations, and `boilerplate/scheduler.ts` for scheduled jobs.
## Cross-References
- `redis-game-patterns` for Redis connection and caching
- `postgres-game-schema` for persisting job results to the database
- `game-backend-architecture` for integrating queues with the game server
- `monitoring-game-ops` for queue monitoring and alerting
## Pitfalls & Anti-Patterns
- **Don't process game-critical logic synchronously when it can be queued** — matchmaking, reward distribution, and analytics should never block the game loop
- **Don't forget to handle job failures** — always set maxRetries + dead letter queue configuration
- **Don't use a single monolithic queue for everything** — separate queues per domain allow independent scaling and priority tuning
- **Don't store large payloads in jobs** — store IDs and fetch from the database in the worker; job data should be small and serializable
- **Don't skip idempotency** — network failures and retries mean jobs can run more than once; always check before mutating state
- **Don't ignore stalled jobs** — configure stall detection and alerts to catch stuck workers early
## Designer Philosophy
**Will Wright:** Simulation systems benefit from decoupled event processing. Queues let game systems communicate asynchronously, the same way SimCity processes zoning, traffic, and utilities independently. Each queue is a subsystem that can evolve without affecting others.
**Sid Meier:** Queue priorities ensure the most "interesting" events happen first. A player waiting for a match should never be blocked by analytics processing. Priority levels map directly to player-perceived responsiveness.
## Sources
- [BullMQ Official Documentation](https://docs.bullmq.io)
- [Redis Best Practices for Queues](https://redis.io/docs/data-types/streams-tutorial/)
- [BullMQ Patterns & Best Practices](https://docs.bullmq.io/patterns/idempotent-jobs)
- Game Server Architecture Patterns (GDC talks on scalable game backends)Related Skills
game-lore
Adds or updates a single world lore entry (faction, location, NPC, or event) — validates against existing lore for consistency, applies the right template, and updates docs/world-lore.md. Extract the entry type (faction/location/npc/event) and name from the user's message.
game-expand
Adds a new feature to an existing MVP plan — scoped architect interview, scope validation against original plan, and integration into the build sequence. Extract the feature name or description from the user's message. Requires docs/mvp-first-draft.md — run game-architect first.
game-build
Builds a game component from the MVP plan — production TypeScript + Vitest tests + mock dependencies + build registry tracking. Extract the component name from the user's message (or "status" to check progress). Requires docs/mvp-first-draft.md — run game-architect first.
game-balance
Analyzes a game system against design principles — economy health metrics, difficulty curve, reward schedules, and progression cost curves. Flags imbalances with severity levels. Use after creating an MVP plan with game-architect. Extract the analysis scope (economy/difficulty/progression/rewards/all) from the user's message.
game-architect
Comprehensive game MVP interviewer and planner. Interviews you in progressive groups, researches genre conventions and reference games, then produces an actionable MVP First Draft with starter project files. Use when starting a new game project from scratch.
narrative-story-structure-game
Use when designing interactive narratives, branching storylines, player agency systems, non-linear story structures, or act frameworks for games. Triggers: branching narrative, player agency, story arc, interactive story, dialogue.
infrastructure-monitoring-game-ops
Use when implementing game monitoring, structured logging, player telemetry, alerting rules, or performance budgets. Triggers: monitoring, logging, telemetry, alerts, observability, metrics.
infrastructure-claude-code-game-workflow
Use when starting a game project, choosing which skill to read, or navigating the game-dev skill ecosystem. Entry point for AI agents working on game development. Triggers: workflow, which skill, how to start, game project setup.
infrastructure-ci-cd-game
Use when setting up CI/CD pipelines, GitHub Actions workflows, deployment automation, migration safety, or staging environments for game projects. Triggers: CI/CD, GitHub Actions, deployment, pipeline, staging.
engineering-stripe-game-payments
Use when implementing game payments, in-app purchases, subscriptions, Stripe webhooks, or monetization flows. Triggers: payments, IAP, subscription, Stripe, checkout, webhooks, monetization.
engineering-redis-game-patterns
Use when implementing Redis patterns for games — caching, leaderboards, pub/sub messaging, session storage, rate limiting, or ephemeral game state. Triggers: Redis, cache, leaderboard, pub/sub, rate limit, session.
engineering-postgres-game-schema
Use when designing game database schemas, player data models, inventory systems, or working with Drizzle ORM and PostgreSQL for games. Triggers: database, schema, Drizzle, players, inventory, leaderboards, game data.