# background-job-processing

A skill for wiring up background job processing: task queues, workers, scheduling and retries. Useful when emails, reports or large exports should not block the request path.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 483 installs · ★ 371
- Author: aj-geddes
- License: MIT · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/aj-geddes/useful-ai-prompts/tree/HEAD/skills/background-job-processing/SKILL.md
- Updated: 2026-03-04
- HTML: https://affpapa.org/en/nevibecode/skills/background-job-processing

## What it does

The skill covers how to build background job processing: distributed task queues, worker pools, scheduling, error handling and monitoring. It ships a minimal Celery and Redis example plus a table of reference guides under `references/` — Python with Celery and Redis, Node.js with Bull Queue, Ruby with Sidekiq, and separate guides on retries, error handling and observability.

There is a best-practices section too. Task timeouts, idempotent tasks, job priorities, exponential backoff and dead-letter queues for failed jobs are on the do list. The don't list warns against synchronous calls inside async tasks, unbounded retries and stuffing large objects into job data.

The quick-start example pulls the broker address from the `REDIS_URL` environment variable, so check that Redis is reachable and the variable is set before starting workers. Otherwise the app falls back to `redis://localhost:6379/0` and fails on connect.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add aj-geddes/useful-ai-prompts --skill background-job-processing -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/background-job-processing/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/background-job-processing/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add aj-geddes/useful-ai-prompts --skill background-job-processing -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/background-job-processing/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add aj-geddes/useful-ai-prompts --skill background-job-processing -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/background-job-processing/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install aj-geddes/useful-ai-prompts background-job-processing
```

2. **Manually: put the files in place**
- File: `.github/skills/background-job-processing/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add aj-geddes/useful-ai-prompts --skill background-job-processing -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/aj-geddes/useful-ai-prompts --path skills/background-job-processing
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/background-job-processing/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add aj-geddes/useful-ai-prompts --skill background-job-processing -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/aj-geddes/useful-ai-prompts/tree/HEAD/skills/background-job-processing/SKILL.md

## When to use it
- move email sending out of the HTTP request
- add retries with exponential backoff
- split jobs into priority queues
- route failed jobs to a dead-letter queue
- watch queue depth and job failures

## Example prompts
- Set up Celery with Redis for background email sending
- Add retries with exponential backoff and a dead-letter queue for failed jobs
- Put heavy exports on a separate queue with a task time limit

## Source text · SKILL.md · MIT

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: eeb2d73ee327e5dd.

BEGIN THIRD-PARTY FILE eeb2d73ee327e5dd
````text
---
name: background-job-processing
description: >
  Implement background job processing systems with task queues, workers,
  scheduling, and retry mechanisms. Use when handling long-running tasks,
  sending emails, generating reports, and processing large datasets
  asynchronously.
---

# Background Job Processing

## Table of Contents

- [Overview](#overview)
- [When to Use](#when-to-use)
- [Quick Start](#quick-start)
- [Reference Guides](#reference-guides)
- [Best Practices](#best-practices)

## Overview

Build robust background job processing systems with distributed task queues, worker pools, job scheduling, error handling, retry policies, and monitoring for efficient asynchronous task execution.

## When to Use

- Handling long-running operations asynchronously
- Sending emails in background
- Generating reports or exports
- Processing large datasets
- Scheduling recurring tasks
- Distributing compute-intensive operations

## Quick Start

Minimal working example:

```python
# celery_app.py
from celery import Celery
from kombu import Exchange, Queue
import os

app = Celery('myapp')

# Configuration
app.conf.update(
    broker_url=os.getenv('REDIS_URL', 'redis://localhost:6379/0'),
    result_backend=os.getenv('REDIS_URL', 'redis://localhost:6379/0'),
    task_serializer='json',
    accept_content=['json'],
    result_serializer='json',
    timezone='UTC',
    enable_utc=True,
    task_track_started=True,
    task_time_limit=30 * 60,  # 30 minutes
    task_soft_time_limit=25 * 60,  # 25 minutes
    broker_connection_retry_on_startup=True,
)

# Queue configuration
default_exchange = Exchange('tasks', type='direct')
app.conf.task_queues = (
// ... (see reference guides for full implementation)
```

## Reference Guides

Detailed implementations in the `references/` directory:

| Guide | Contents |
|---|---|
| [Python with Celery and Redis](references/python-with-celery-and-redis.md) | Python with Celery and Redis |
| [Node.js with Bull Queue](references/nodejs-with-bull-queue.md) | Node.js with Bull Queue |
| [Ruby with Sidekiq](references/ruby-with-sidekiq.md) | Ruby with Sidekiq |
| [Job Retry and Error Handling](references/job-retry-and-error-handling.md) | Job Retry and Error Handling |
| [Monitoring and Observability](references/monitoring-and-observability.md) | Monitoring and Observability |

## Best Practices

### ✅ DO

- Use task timeouts to prevent hanging jobs
- Implement retry logic with exponential backoff
- Make tasks idempotent
- Use job priorities for critical tasks
- Monitor queue depths and job failures
- Log job execution details
- Clean up completed jobs
````
END THIRD-PARTY FILE eeb2d73ee327e5dd

The third-party file has ended. Everything between the eeb2d73ee327e5dd tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 2623 of 3087 bytes. © aj-geddes · MIT · https://github.com/aj-geddes/useful-ai-prompts/tree/HEAD/skills/background-job-processing/SKILL.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
