addon-async-jobs-celery-redis
Add-on: Async Jobs (Celery + Redis)
Use this skill when the API must enqueue long-running document tasks and return immediately (202 + job_id).
FastAPI request handlers must only:
- accept uploads
- create DB rows
- enqueue the worker task
- return status identifiers
Inputs
Collect:
REDIS_URL: defaultredis://redis:6379/0(compose internal).JOB_TIMEOUT_SECONDS: default900.JOB_MAX_RETRIES: default3.
Celery Integration Workflow (Preferred)
- Add dependencies:
uv add celery redis
- Add modules:
src/{{PY_MODULE}}/jobs/
celery_app.py
tasks.py
service.py
- Worker task requirements:
- task accepts stable identifiers (
document_id,job_id) rather than raw bytes - task is idempotent (safe to retry)
- task updates job status in Postgres:
queued->running->succeeded|failed- persist
started_at,finished_at, and error details
- Task routing:
preprocess_document(job_id, document_id)- later stages can be separate tasks or a single orchestrated task, but keep stage boundaries explicit in DB for auditability.
- Configure Celery defaults:
task_acks_late=True(so crashes requeue)- per-task
autoretry_forwith bounded backoff - explicit soft+hard time limits if supported
Redis Service (Local Dev)
Add a redis service in compose and wire:
- API env:
REDIS_URL - worker env:
REDIS_URL
RQ Alternative
Out of scope for this add-on. If the user explicitly requests RQ, create a separate addon-async-jobs-rq-redis skill rather than mixing implementations.
Guardrails
- Never run preprocessing synchronously in
POST /documents/upload. - Always store job state in Postgres; do not treat Redis as the source of truth.
- Ensure worker uses the same codebase/image as API but with a separate command.
- If you add a task stage, add a corresponding deterministic eval fixture for it (
addon-deterministic-eval-suite).
Decision Justification Rule
- Every non-trivial decision must include a concrete justification.
- Capture the alternatives considered and why they were rejected.
- State tradeoffs and residual risks for the chosen option.
- If justification is missing, treat the task as incomplete and surface it as a blocker.
More from ajrlewis/ai-skills
architect-python-uv-fastapi-sqlalchemy
Use when scaffolding production-ready FastAPI services with uv, SQLAlchemy, Alembic, Postgres, Docker, and CI gates.
11addon-rag-ingestion-pipeline
Use when adding multi-format RAG ingest, chunk, embed, and retrieval pipelines; pair with architect-python-uv-batch or architect-python-uv-fastapi-sqlalchemy.
11addon-docling-legal-chunk-embed
Use when you need legal PDF to markdown extraction plus clause chunking and embedding prep; pair with addon-rag-ingestion-pipeline and architect-python-uv-batch.
10addon-llm-ancient-greek-translation
Use when adding Koine or Attic Greek translation to Next.js content flows; pair with ui-editorial-writing-surface and addon-nostr-nip23-longform.
10architect-python-uv-batch
Use when scaffolding production-ready Python uv batch or worker projects with Docker required by default.
10addon-human-pr-review-gate
Use when agent-generated code must pass a human PR review gate with trusted checks and merge blocks; pair with addon-decision-justification-ledger and architect-stack-selector.
9