django-patterns
Skill4 starsChanged 3 months agoMITView on GitHub
Django/DRF project conventions: service-layer structure, serializers, thin views, URL namespacing, the canonical /api/v1 API contract, Celery tasks, and testing. Apply when writing or reviewing Django/Python backend code.
29 other projects use a version of this.
Adopted by
Most recently taken up by
- Rojios/everything-claude-codetheir own version, first seen Nov 8, 2026
- GstMirabal/Token-Optimized-Agent-Pipelinetheir own version, first seen Nov 8, 2026
- ControllableModel/SWE-Skills-Benchtheir own version, first seen Nov 8, 2026
- pankaj-mahaur/Agent-Daemontheir own version, first seen Nov 6, 2026
- ku5ic/claude-kittheir own version, first seen Nov 4, 2026
- TsinHzl/claude-code-configtheir own version, first seen Nov 1, 2026
Used with
Projects with it also use django-tdd, springboot-tdd and 8 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
FaisalAlqarniSkilldjango-tdd
Django testing strategies with pytest-django, TDD methodology, factory_boy, mocking, coverage, and testing Django REST Framework APIs.
Also in 6 projects that use this
AshfaqbsSkillspringboot-tdd
Test-driven development for Spring Boot using JUnit 5, Mockito, MockMvc, Testcontainers, and JaCoCo. Use when adding features, fixing bugs, or refactoring.
Also in 4 projects that use this
LangChainSkilldocker-patterns
Best practices for Docker containerization and multi-stage builds
Also in 5 projects that use this
seikaikyoSkillfastapi-patterns
FastAPI + SQLModel + Neon PostgreSQL 後端開發最佳實踐。適用於 Render 部署的 API 服務。涵蓋路由設計、資料庫操作、錯誤處理、認證授權。
Also in 3 projects that use this
royaluniondesign-sysSkilldeployment-patterns
Deployment workflows, CI/CD pipeline patterns, Docker containerization, health checks, rollback strategies, and production readiness checklists for web applications.
Also in 3 projects that use this
lodetomasiSkilltdd-workflow
Test-Driven Development workflow with red-green-refactor pattern and best practices
Also in 5 projects that use this
Other versions29 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 29
- loulanyue/awesome-claude-notes★ 272same name
- tranhieutt/software_development_department★ 71same name
- Fmarzochi/EGC★ 61same name
- skateddu/claude-code-python-setup★ 28same name
- FaisalAlqarni/sp-ecc★ 9same name
- ControllableModel/SWE-Skills-Bench★ 8same name
- edjchapman/claude-code-config★ 8same name
- gongyijie85/dsh-ecc★ 8same name
- Lukasbrujula/claude-code-framework★ 4same name
- peopleforrester/claude-dotfiles★ 3same name
19 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository53 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- llms.txtllms.txt
- actionableSkill
- astro-bootstrapSkill
- astro-patternsSkill
- autopilotSkill
- axon-code-intelSkill
- brainstormingSkill
- commit-conventionsSkill
- cross-repo-contextSkill
- django-bootstrapSkill
- executeSkill
- find-sessionSkill
- flutter-bootstrapSkill
- flutter-patternsSkill
- full-featureSkill
- intelSkill
- nextjs-bootstrapSkill
- nextjs-fullstack-bootstrapSkill
- nextjs-fullstack-patternsSkill
- nextjs-mui-bootstrapSkill
- nextjs-patternsSkill
- nextjs-shadcn-bootstrapSkill
- orchestratorSkill
- phase-breakdownSkill
- plan-and-scopeSkill
- prdSkill
- reactSkill
- recallSkill
- reflectSkill
- relaySkill
- rememberSkill
- scaffoldSkill
- scratchSkill
- tailwindSkill
- ux-specSkill
- ux-to-promptsSkill
- verify-astroSkill
- verify-djangoSkill
- verify-flutterSkill
- verify-nextjs-fullstackSkill
- verify-nextjs-muiSkill
- verify-nextjs-shadcnSkill
- verify-nextjsSkill
- verifySkill
- visual-feedbackSkill
- work-disciplineSkill
- worktreesSkill
- wrapSkill
- write-as-friendSkill
- write-as-humanSkill
- writing-clearlySkill
- writing-skillsSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
24 rules. 0 are common, 7 are distinctive, and 17 are very specific to this project.
0
Common
Most of the 4 edited versions we read keep these.
7
Distinctive
This author's own choices. Worth a look.
17
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 19
All models inherit from AbstractModel (provides uuid, metadata, created_at, updated_at, silent_save())
- Very specific: line 20
Use the inherited uuid field for public-facing IDs, keep integer PKs internal
- Very specific: line 21
Add __str__ methods to every model
- Very specific: line 22
Use Meta.ordering to define default ordering
- Very specific: line 23
Keep models thin — business logic goes in services.py
- Very specific: line 33
Use SerializerMethodField sparingly — prefer annotations at the queryset level
- Very specific: line 35
Always define fields explicitly (never use __all__)
- Distinctive: line 38
Prefer ViewSets for CRUD, APIView for custom actions
- Very specific: line 39
Use select_related / prefetch_related on querysets to avoid N+1
- Very specific: line 41
Use permission_classes explicitly on every view
- Distinctive: line 46
Use DRF routers for ViewSets
- Very specific: line 52
Prefix: every endpoint lives under /api/v1 with a trailing slash on every path.
- Very specific: line 70
Resource endpoints: follow REST collection/detail conventions under the prefix, keyed by uuid:
- Very specific: line 98
Keep tasks in each app's tasks.py
- Very specific: line 102
Add RunPython data migrations when needed alongside schema changes
- Distinctive: line 103
Never edit a migration that's been pushed to main
- Very specific: line 106
Use pytest-django with @pytest.mark.django_db
- Distinctive: line 107
Use factory_boy for test data (not fixtures)
- Very specific: line 108
Test API endpoints via APIClient — test the contract, not internals
- Distinctive: line 109
Test services independently with unit tests (no HTTP layer)
- Very specific: line 113
All commands run via make (Docker Compose under the hood) — never run python manage.py directly
- Very specific: line 114
Use /django-bootstrap when setting up a new project from scratch
- Distinctive: line 117
After completing a backend feature, generate an integration summary:
- Distinctive: line 121
Document error response shapes
“Common” is measured: kept by at least 6 in 10 of the 4 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Skill: Django Patterns
Purpose
Guide Claude Code when implementing Django/DRF features. Follow these conventions unless the project's CLAUDE.md overrides them.
Project Structure
- Project settings module is always named
project/(not the service name) - Apps live in their own top-level directories
- Each app has:
admin.py,apps.py,models.py,serializers.py,services.py,tasks.py,urls.py,views.py,tests/ - Tests use a
tests/directory with files per concern:test_models.py,test_views.py,test_services.py
Models
- All models inherit from
AbstractModel(providesuuid,metadata,created_at,updated_at,silent_save()) - Use the inherited
uuidfield for public-facing IDs, keep integer PKs internal - Add
__str__methods to every model - Use
Meta.orderingto define default ordering - Keep models thin — business logic goes in
services.py
Service Layer
- Each app has a
services.py— all business logic lives here, not in views or models - Services are classes with external dependencies injected via
__init__ - Views call services; services call models and external APIs
- This keeps views thin and business logic testable without HTTP
Serializers (DRF)
- Separate read vs write serializers when shapes differ
- Use
SerializerMethodFieldsparingly — prefer annotations at the queryset level - Validate at the serializer level, not the view level
- Always define
fieldsexplicitly (never use__all__)
Views
- Prefer ViewSets for CRUD, APIView for custom actions
- Use
select_related/prefetch_relatedon querysets to avoid N+1 - Views should only: parse request, call service, return serialized response
- Use
permission_classesexplicitly on every view
URLs
- Each app exports
urlpatternsfromurls.py project/urls.pyaggregates with namespacing:path("api/v1/{app}/", include(({app}_urlpatterns, "{app}")))- Use DRF routers for ViewSets
Canonical API Contract
This is the source of truth for the cross-stack API. The Django backend ships exactly this; every decoupled client (Next.js, Flutter) consumes exactly this. Keep paths, identifiers, and payload shapes byte-for-byte consistent with this section — do not restate them differently elsewhere.
Prefix: every endpoint lives under /api/v1 with a trailing slash on every path.
Identifiers: clients only ever see uuid. Models keep an internal integer primary key for FK/index efficiency, but URLs and payloads expose the public uuid field only — never the integer id. Detail routes are keyed on it: path("<uuid:uuid>/", ...).
Auth endpoints:
| Method | Path | Request | Response |
| POST | /api/v1/auth/login/ | {email, password} | {access, refresh} |
| POST | /api/v1/auth/refresh/ | {refresh} | {access} |
| GET | /api/v1/auth/me/ | — (Bearer access token) | user object |
| POST | /api/v1/auth/register/ | {username, email, password, first_name, last_name} | {user, tokens: {access, refresh}} |
- Login returns the token pair directly:
{access, refresh}. - Refresh returns
{access}(a new access token from a valid refresh token). - Register wraps the created user and its tokens:
{user, tokens: {access, refresh}}. - The user object (from
/api/v1/auth/me/and inside register'suser) is{uuid, username, email, first_name, last_name}— no integerid.
Resource endpoints follow REST collection/detail conventions under the prefix, keyed by uuid:
| Method | Path | Purpose |
| GET | /api/v1/{resource}/ | list (paginated) |
| POST | /api/v1/{resource}/ | create |
| GET | /api/v1/{resource}/<uuid>/ | retrieve |
| PATCH | /api/v1/{resource}/<uuid>/ | update |
| DELETE | /api/v1/{resource}/<uuid>/ | delete |
(The self-contained full-stack Next.js app applies the same prefix, uuid, and pagination shape to its own route handlers — e.g. /api/v1/posts — though Next.js route paths omit the trailing slash.)
Pagination: list endpoints are page-number paginated. Query params: page and page_size. Response shape:
{
"page": 1,
"count": 42,
"num_pages": 5,
"results": [ ... ]
}count is the total item count across all pages, num_pages the total page count, page echoes the current page, and results holds the current page's items. (This is a custom paginator — not DRF's default {count, next, previous, results}.)
Celery Tasks
- Use
@shared_task(bind=True, max_retries=3, default_retry_delay=60) - Tasks call services — no business logic in the task itself
- Keep tasks in each app's
tasks.py
Migrations
- Review auto-generated migrations before committing
- Add
RunPythondata migrations when needed alongside schema changes - Never edit a migration that's been pushed to main
Testing
- Use
pytest-djangowith@pytest.mark.django_db - Use factory_boy for test data (not fixtures)
- Test API endpoints via
APIClient— test the contract, not internals - Test services independently with unit tests (no HTTP layer)
- Aim for: service logic tests, serializer validation tests, endpoint integration tests
Development Environment
- All commands run via
make(Docker Compose under the hood) — never runpython manage.pydirectly - Use
/django-bootstrapwhen setting up a new project from scratch
Integration Summaries
After completing a backend feature, generate an integration summary:
- List all new/modified endpoints with method, path, auth requirements
- Include request/response shapes as JSON examples
- Note any pagination, filtering, or ordering parameters
- Document error response shapes
- Save to
docs/integration/[feature-name].md
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

