{
 "schema": "aiblocks-page/1",
 "id": "set-up-redis-bullmq-job-queue-builder-prompt",
 "type": "prompt",
 "name": "Redis BullMQ job queue code planner",
 "summary": "Get a coding brief for a Redis and BullMQ job queue: connection, queue, worker and a test script, with steps to run it and check it works.",
 "headline": "Redis BullMQ job queue code planner",
 "subhead": "Get a coding brief for a Redis and BullMQ job queue, with scoped jobs, retries and failed-job handling.",
 "job": {
  "id": "build-software",
  "name": "Build and ship software"
 },
 "level": "intermediate",
 "thinking": "medium",
 "tested": true,
 "updated": "2026-11-03",
 "first_published": "2026-10-25",
 "inputs": [
  {
   "type": "codebase",
   "required": true,
   "label": "Codebase",
   "what": "a project's code, in a folder or repo the AI can open"
  }
 ],
 "outputs": [
  {
   "type": "code_change",
   "required": true,
   "label": "Code change",
   "what": "a change to the code, with what it fixes and how it was checked"
  }
 ],
 "you_give": [
  "Your code project, open in Claude Code",
  "A running Redis server and its REDIS_URL, saved in .env.local"
 ],
 "you_get": [
  "A connection file, a queue file, a worker file and a test script",
  "A plain explanation of priority, retries and concurrency",
  "A test run that shows three jobs completed. The agent names and account ID in the test are placeholders to swap for real ones."
 ],
 "use_when": [
  "You are building an app that needs background work, such as agent tasks or emails.",
  "You want a first queue that you can test in a few minutes.",
  "You are new to coding and want each part explained simply."
 ],
 "skip_when": [
  "You need a production queue with strict TLS checks: set up certificate checks first, or use a managed queue service.",
  "You only need one task to run later or on a timer: use a simple scheduled job from your host instead.",
  "You do not have a code project or a Redis server yet: set up the project and Redis first, then come back."
 ],
 "output_sample": {
  "input": [
   "Your code project, opened in a coding AI such as Claude Code",
   "Your Redis link in a .env.local file (REDIS_URL)",
   "Which jobs the queue should run (optional)"
  ],
  "prerequisites": [
   "An AI that can read and edit files in your project",
   "A running Redis server, either local or a cloud one such as Upstash",
   "Permission to install the bullmq and ioredis packages",
   "An AI that can run code, to use the scripts that come with this skill"
  ],
  "output": [
   {
    "name": "lib/queue/connection.ts",
    "contains": "One shared Redis connection that reads REDIS_URL, stops with a clear error if it is missing, and handles cloud links."
   },
   {
    "name": "lib/queue/agent-queue.ts",
    "contains": "A queue named agent-jobs and an enqueueJob function that adds a job with a priority and returns its ID."
   },
   {
    "name": "lib/queue/worker.ts",
    "contains": "A worker that runs three jobs at once, logs each job, and logs when a job completes or fails."
   },
   {
    "name": "scripts/test-queue.ts",
    "contains": "A script that adds three test jobs, waits five seconds, then prints Done."
   },
   {
    "name": "Plain explanation",
    "contains": "Short notes on why to use a queue, what priority means, how retries work and what concurrency means."
   }
  ]
 },
 "how_to_use": [
  "Open your code project in an AI that can edit files, such as Claude Code.",
  "Make sure Redis is running and REDIS_URL is in your .env.local file.",
  "Paste the prompt from the download and ask the AI to list anything missing before it writes code.",
  "Run the test script with npx tsx scripts/test-queue.ts and check that all three jobs log as completed.",
  "The prompt keeps certificate checks on for rediss:// links. If your Redis server uses a self-signed certificate, tell the AI, and it turns the checks off for testing only. Turn them back on before real use.",
  "Once the three test jobs complete, ask the AI to replace the logging in the worker with your real job code."
 ],
 "checks": [],
 "next": [
  {
   "name": "Recoverable agent job queue builder",
   "url": "https://useaiblocks.com/skills/the-job-queue-where-agents-actually-run-implementation-planner",
   "why": "Build it"
  }
 ],
 "source": null,
 "credits": [],
 "files": [
  "references/worked-example.md"
 ],
 "links": {
  "page": "https://useaiblocks.com/prompts/set-up-redis-bullmq-job-queue-builder-prompt",
  "markdown": "https://useaiblocks.com/prompts/set-up-redis-bullmq-job-queue-builder-prompt.md",
  "json": "https://useaiblocks.com/prompts/set-up-redis-bullmq-job-queue-builder-prompt.json",
  "instructions": "https://useaiblocks.com/skills/set-up-redis-bullmq-job-queue-builder-prompt/SKILL.md",
  "download": "https://useaiblocks.com/skills/set-up-redis-bullmq-job-queue-builder-prompt.zip",
  "api_item": "https://useaiblocks.com/api/v1/items/set-up-redis-bullmq-job-queue-builder-prompt",
  "api_document": "https://useaiblocks.com/api/v1/documents/prompt/set-up-redis-bullmq-job-queue-builder-prompt",
  "mcp": "https://useaiblocks.com/mcp"
 }
}
