Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Background Jobs?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/ansh44233-background-jobs)
---
description: Write reliable background jobs and queue consumers: idempotency, retries, timeouts, dead letters and observability
profile: standard
tags: backend, queues, reliability
---
# Background jobs
Use when adding or changing jobs, workers, cron tasks or queue consumers (Sidekiq, Celery, BullMQ, SQS, Kafka, Cloud Tasks).
## Make every job safe to run twice
Queues deliver at least once. Use an idempotency key, upserts, "already processed" markers, or conditional updates so a retry or duplicate does no harm. External side effects (emails, charges) need their own idempotency keys.
## Payloads
Pass ids and small values, not whole objects; load fresh data inside the job. Version the payload format if producers and consumers deploy separately.
## Enqueue after commit
Enqueue after the database transaction commits, or use an outbox table. Otherwise the job can run before the data exists, or run for data that was rolled back.
## Retries and failures
- Retry transient errors with exponential backoff and jitter; do not retry validation errors.
- Cap attempts and send exhausted jobs to a dead-letter queue that someone monitors.
- Set a timeout per job shorter than the queue's visibility timeout, so a slow job is not picked up twice.
## Scheduling and scale
- Cron jobs: guard against overlapping runs (locks) and make missed runs safe to catch up.
- Process large sets in batches with checkpoints so a failure resumes instead of restarting.
## Observe
Log job id, attempt and duration; track queue depth, age of the oldest message, failure rate and DLQ size.
## Verify
Tests that run the job twice (same result), a failing dependency (retries then DLQ), and enqueue-after-commit behaviour.