---
name: "django-channels-websocket-consumers"
description: "Add real-time WebSockets, push notifications, and chat rooms to Django using Channels."
metadata:
  author: "Django"
  version: "1.0.0"
  runtime_compatibility:
    - "codex"
    - "claude-code"
    - "cursor"
    - "windsurf"
triggers:
  - "write django channels consumer"
  - "configure channels_redis"
  - "websocket routing asgi django"
permissions:
  fs_read: true
  fs_write: "workspace"
  shell_exec: false
  net_access: false
---

# Django Channels Async WebSocket Consumers & Redis Layer

Configures Django Channels 4: writing AsyncWebsocketConsumer, configuring channel layers with channels_redis, routing in asgi.py, managing groups (group_add, group_discard), and authenticating WebSocket handshakes.

## When to Invoke
Invoke this skill whenever you need to:
- write django channels consumer
- configure channels_redis
- websocket routing asgi django

## Execution SOP & Rules
1. Define consumer: class NotificationConsumer(AsyncWebsocketConsumer): async def connect(self): ...
2. Join channel group: await self.channel_layer.group_add('user_123', self.channel_name).
3. Broadcast message: await self.channel_layer.group_send('user_123', {'type': 'notify', 'message': data}).
4. Configure ASGI application routing ProtocolTypeRouter({'http': ..., 'websocket': AuthMiddlewareStack(...)}) in asgi.py.

## Verification Checklist
- Run local linting, syntax validation, and type-checks before reporting completion.
- Ensure all created or modified files adhere to workspace boundaries and avoid uncommitted secrets.
- Verify tests or build commands exit cleanly with return code 0.
