skills/django-celery-expert/SKILL.md
Expert Django and Celery guidance for asynchronous task processing. Use when designing background tasks, configuring workers, handling retries and errors, optimizing task performance, implementing periodic tasks, or setting up production monitoring. Follows Celery best practices with Django integration patterns.
npx skillsauth add agusabas/django-skills django-celery-expertInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
This skill provides expert guidance for Django applications using Celery for asynchronous task processing. It covers task design patterns, worker configuration, error handling, monitoring, and production deployment strategies.
Key Capabilities:
Invoke this skill when you encounter these triggers:
Task Design:
Configuration & Setup:
Error Handling:
Performance & Scaling:
Monitoring:
Follow this workflow when handling Django Celery requests:
Identify the task type:
Key questions:
Based on the task type, reference the appropriate bundled documentation:
references/django-integration.mdreferences/task-design-patterns.mdreferences/configuration-guide.mdreferences/error-handling.mdreferences/periodic-tasks.mdreferences/monitoring-observability.mdreferences/production-deployment.mdTask design principles:
Error handling:
Performance:
Before presenting the solution:
references/ - Comprehensive Celery documentation loaded into context as needed
references/django-integration.md
references/task-design-patterns.md
references/configuration-guide.md
references/error-handling.md
references/periodic-tasks.md
references/monitoring-observability.md
references/production-deployment.md
User Request:
"Send welcome emails in the background after user registration"
Implementation:
# tasks.py
from celery import shared_task
from django.core.mail import send_mail
@shared_task(bind=True, max_retries=3)
def send_welcome_email(self, user_id):
from users.models import User
try:
user = User.objects.get(id=user_id)
send_mail(
subject="Welcome!",
message=f"Hi {user.name}, welcome to our platform!",
from_email="[email protected]",
recipient_list=[user.email],
)
except User.DoesNotExist:
pass # User deleted, skip
except Exception as exc:
raise self.retry(exc=exc, countdown=60 * (2 ** self.request.retries))
# views.py
def register(request):
user = User.objects.create(...)
send_welcome_email.delay(user.id) # Fire and forget
return redirect('dashboard')
User Request:
"Process a large CSV import with progress updates"
Implementation:
@shared_task(bind=True)
def import_csv(self, file_path, total_rows):
from myapp.models import Record
with open(file_path) as f:
reader = csv.DictReader(f)
for i, row in enumerate(reader):
Record.objects.create(**row)
if i % 100 == 0:
self.update_state(
state='PROGRESS',
meta={'current': i, 'total': total_rows}
)
return {'status': 'complete', 'processed': total_rows}
# Check progress
result = import_csv.AsyncResult(task_id)
if result.state == 'PROGRESS':
progress = result.info.get('current', 0) / result.info.get('total', 1)
User Request:
"Process an order: validate inventory, charge payment, then send confirmation"
Implementation:
from celery import chain
@shared_task
def validate_inventory(order_id):
# Returns order_id if valid, raises if not
order = Order.objects.get(id=order_id)
if not order.items_in_stock():
raise ValueError("Items out of stock")
return order_id
@shared_task
def charge_payment(order_id):
order = Order.objects.get(id=order_id)
order.charge()
return order_id
@shared_task
def send_confirmation(order_id):
order = Order.objects.get(id=order_id)
order.send_confirmation_email()
def process_order(order_id):
workflow = chain(
validate_inventory.s(order_id),
charge_payment.s(),
send_confirmation.s()
)
workflow.delay()
Common Pitfalls:
Django Integration:
django-celery-beat for database-backed schedulesdjango-celery-results for storing task results in DjangoCELERY_ settings in Django settings.py@shared_task for reusable appsSecurity:
development
Refactor Django/Python code to improve maintainability, readability, and adherence to best practices. Transforms fat views into Clean Architecture with Use Cases and Services. Applies SOLID principles, Clean Code patterns, Python 3.12+ features like type parameter syntax and @override decorator, Django 5+ patterns like GeneratedField and async views. Fixes N+1 queries, extracts business logic from views, separates Read/Write serializers, and converts exception-based error handling to explicit return values. Use when refactoring Django code, applying Clean Architecture, or modernizing legacy Django projects.
development
Generate a valid Google Merchant Center product feed (RSS 2.0 / XML) from any backend. Use this skill when the user needs to create or fix a Google Merchant feed, product XML feed, Google Shopping feed, or integrate products with Google Merchant Center. Covers all required and recommended fields, validation rules, common pitfalls, and backend-specific implementations for Django/Python, Node.js, and Next.js API routes.
development
Create production-quality Django REST Framework APIs using Clean Architecture and SOLID principles. Covers layered architecture (views, use cases, services, models), query optimization (N+1 prevention), pagination/filtering, JWT authentication, permissions, and production deployment. Use when building new Django APIs, implementing domain-driven design, optimizing queries, or configuring authentication. Applies Python 3.12+ and Django 5+ patterns.
development
Maintainer-only workflow for handling GitHub Secret Scanning alerts on OpenClaw. Use when Codex needs to triage, redact, clean up, and resolve secret leakage found in issue comments, issue bodies, PR comments, or other GitHub content.