add-celery-task

Generate Celery task scaffolds with session lifecycle and metrics.

Updated Feb 3, 2026
One-click install
npx skills add https://github.com/michaelayoade/dotmac_crm --skill add-celery-task
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: add-celery-task
Source: https://github.com/michaelayoade/dotmac_crm/tree/main/.claude/skills/add-celery-task
Command: npx skills add https://github.com/michaelayoade/dotmac_crm --skill add-celery-task

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Creating new Celery tasks often leads to inconsistent patterns, circular imports, missing metrics/logging, and brittle error handling that breaks batch processing.

Core Features & Use Cases

  • Determines the right task module and execution type: Guides you to parse task intent to choose the correct app/tasks/{module}.py destination and whether the task should be scheduled (beat) or run on-demand.
  • Implements a production-ready orchestration template: Establishes a standardized Celery task structure with SessionLocal() lifecycle management, safe per-item exception handling, logging at start/end, and metrics via observe_job().
  • Registers the task for discovery and optional beat scheduling: Ensures celery_app.autodiscover_tasks(["app.tasks"]) discovery and documents how to add a beat schedule using scheduler configuration or Celery beat settings.

Quick Start

Ask to generate a Celery task for syncing subscribers named "sync_subscribers for Splynx reconciliation" that follows the repository’s existing app/tasks/subscribers.py pattern, includes correct DB session handling and per-item error resilience, and returns processing statistics.

Frequently Asked Questions about add-celery-task

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create a Celery background task that avoids circular imports and handles database sessions safely?

Generate Celery background tasks by importing services inside the task function to avoid circular imports, and manage database sessions safely using SessionLocal() for proper lifecycle control.

What is the best way to add observability and error handling to a Python Celery task?

Add observability and error handling to Python Celery tasks by emitting start and end logs, using observe_job for metrics, and implementing per-item exception handling with database rollback for resilient batch processing.

How do I set up Celery beat scheduling and autodiscovery for periodic background jobs?

Set up Celery beat scheduling and autodiscovery by ensuring celery_app.autodiscover_tasks(["app.tasks"]) is configured, then adding periodic background jobs via scheduler configuration or Celery beat settings.

Why does my Celery batch processing break when one item fails, and how do I prevent it?

Your Celery batch processing breaks when one item fails due to unhandled exceptions. Prevent this by implementing per-item exception handling with database rollback to isolate failures and allow the batch to continue.

Can I use SQLAlchemy with Celery for on-demand and periodic domain tasks?

Yes, you can use SQLAlchemy with Celery by applying SessionLocal() lifecycle management, allowing you to build both on-demand and periodic domain tasks that process data safely.

How do I structure a new Celery task to match existing repository patterns?

Structure a new Celery task by reading existing task patterns in your repository, placing the module in app/tasks/{module}.py, and applying consistent orchestration rules for logging, metrics, and error handling.