django-patterns

django-patterns is a skill for Claude Code from tranhieutt/software_development_department. It costs 57 tokens per session (1,405 once invoked), scanned A, original, MIT.

A collection of patterns for building Django web applications and APIs, including database access, background jobs, security, and asynchronous code.

In plain words
What is it for?
Use it when building or improving Django 5.x applications with Django REST Framework, Celery, Channels, authentication, permissions, or database performance work.
Why use it?
It helps avoid common problems such as slow repeated database queries, unsafe concurrent updates, recursive signal handlers, and database locks during migrations.

Skill for Claude Code

Written for Claude Code: allowed-tools in frontmatter.

Good fit Use it when building or improving Django 5.x applications with Django REST Framework, Celery, Channels, authentication, permissions, or database performance work.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/tranhieutt/software_development_department/django-patterns
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add tranhieutt/software_development_department --skill django-patterns
Clone the repo
git clone --depth 1 https://github.com/tranhieutt/software_development_department

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for django-patterns

README.md
[![agentmods](https://agentmods.dev/badge/skills/tranhieutt/software_development_department/django-patterns/github.svg)](https://agentmods.dev/skills/tranhieutt/software_development_department/django-patterns)
Your own site
<a href="https://agentmods.dev/skills/tranhieutt/software_development_department/django-patterns"><img src="https://agentmods.dev/badge/skills/tranhieutt/software_development_department/django-patterns/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for django-patterns

Your own site · 80×15
<a href="https://agentmods.dev/skills/tranhieutt/software_development_department/django-patterns"><img src="https://agentmods.dev/badge/skills/tranhieutt/software_development_department/django-patterns.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 57 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,405 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00057 $0.01405
Opus 5.5 $0.00023 $0.00562
Sonnet 5.5 $0.00011 $0.00281
Haiku 4.5 $0.00006 $0.00140

Measured 3mo ago against content hash e1f42c83c241, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

django-patterns scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/skills/django-patterns/SKILL.md · 170 lines

How it starts

The opening of the file, as written. The whole thing — 170 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Django & DRF Professional Patterns

Core Expertise

  • Modern Django: 5.x features, async views/middleware, ASGI deployment.
  • Background & Real-time: Celery integration, Django Channels.
  • ORM Optimization: select_related, prefetch_related, custom managers.
  • Security: JWT auth, OAuth2, RBAC, protection against SQLi/XSS/CSRF.

Critical rules (non-obvious)

  • N+1 queries: always use select_related (FK) / prefetch_related (M2M) — never iterate and query inside loops
  • get_or_create race condition: wrap in transaction.atomic() in concurrent environments
  • Never call save() inside pre_save signal — causes infinite recursion; use update_fields
  • bulk_create skips signals and save() — don't use when signal logic is required
  • Migrations on large tables: use RunSQL with CONCURRENTLY index creation to avoid locks
# FK / OneToOne → select_related (JOIN)
books = Book.objects.select_related("author", "author__publisher").all()

# M2M / reverse FK → prefetch_related (separate query)
authors = Author.objects.prefetch_related("books", "books__tags").all()

# Custom prefetch with queryset
from django.db.models import Prefetch
Author.objects.prefetch_related(
    Prefetch("books", queryset=Book.objects.filter(published=True), to_attr="active_books")
)

ORM: annotations and aggregations

from django.db.models import Count, Avg, Q, F, Value
from django.db.models.functions import Coalesce

Author.objects.annotate(
    book_count=Count("books"),
    avg_rating=Coalesce(Avg("books__rating"), Value(0.0)),
    high_rated=Count("books", filter=Q(books__rating__gte=4)),
).filter(book_count__gt=0).order_by("-book_count")

ORM: F expressions (avoid race conditions)

# BAD — race condition
product = Product.objects.get(pk=pk)
product.stock -= quantity
product.save()

# GOOD — atomic at DB level
Product.objects.filter(pk=pk).update(stock=F("stock") - quantity)

Read the full file on GitHub · 170 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3mo ago First seen · 170 lines · 57 tokens per session scan A e1f42c83c241

Subscribe to this mod's changes

django-patterns is a skill published in the GitHub repository tranhieutt/software_development_department (75 stars, last pushed 6mo ago), licensed MIT. It adds 57 tokens to every session and 1,405 once invoked, about $0.0002 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

django-patterns compared with skills from other repositories

django-patterns next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
django-patternstranhieutt/software_development_departmentSkill756mo agoMITA57Claude Code
architecturedatit309/supergraphSkill236d agoMITA52Claude Code
fastapiDongDuong2001/pudo-code-systemSkill514d agoMITA0Claude Code, Codex
api-design-planDongDuong2001/pudo-code-systemSkill514d agoMITA14Claude Code, Codex
backend-codeDongDuong2001/pudo-code-systemSkill514d agoMITA13Claude Code, Codex
javascript-codeDongDuong2001/pudo-code-systemSkill514d agoMITA16Claude Code, Codex
architecture-planDongDuong2001/pudo-code-systemSkill514d agoMITA10Claude Code, Codex