Django Project Skill 🧩
This skill scaffolds new Django projects or upgrades existing ones with a production-ready layout and operational practices suitable for large systems.
Scope and alignment 🧭
Mandatory reads (must be loaded before using this skill):
Inputs to confirm ✅
- Project name and Python version
- Database (SQLite/PostgreSQL) and cache (Redis/none)
- API surface (Django REST Framework, HTML templates, or both)
- Background jobs (Celery/none) and async worker needs
- Deployment target (container, PaaS, serverless)
- Environment split (local/staging/prod) and secrets strategy
Quick reference 🧠
| Capability |
Purpose |
Key Outputs |
| Project scaffold |
Create a working Django foundation aligned with Python instructions |
pyproject.toml, src/ layout, settings split, core apps |
| Large-system structure |
Keep growth manageable with clear boundaries |
Domain apps, service/selectors, thin views |
| Observability baseline |
Operational visibility from day one |
Structured logs, request IDs, health endpoints |
| Security baseline |
Protect data and reduce risk |
Secure defaults, secrets handling, dependency scanning |
| Resilience and availability |
Survive failures and scale safely |
Timeouts, retries, graceful degradation |
| Quality gates |
Enforce fast feedback |
make targets or uv commands for lint/typecheck/test |
Capabilities 🧰
1. Project scaffold (foundation)
Use this for new projects or to align an existing project with the standard layout.
Core requirements:
- Use
pyproject.toml as the single source of truth. If available, start from the template and set:
- project metadata (name, version, requires-python)
- dependency groups for dev tooling
- ruff, mypy, pytest configuration
- Use
uv for deterministic installs and lockfile management.
- Pin Python in
.python-version and requires-python.
- Scaffold with a
src/ layout so imports are explicit and testable.
- Split settings into
base.py, local.py, production.py, and test.py.
- Provide a minimal
apps/ structure for domain growth.
- Ensure
manage.py defaults to local settings and can switch via DJANGO_SETTINGS_MODULE.
Recommended layout:
.
├── .python-version
├── manage.py
├── pyproject.toml
├── src/
│ ├── config/
│ │ ├── __init__.py
│ │ ├── asgi.py
│ │ ├── urls.py
│ │ ├── wsgi.py
│ │ └── settings/
│ │ ├── __init__.py
│ │ ├── base.py
│ │ ├── local.py
│ │ ├── production.py
│ │ └── test.py
│ └── apps/
│ ├── core/
│ ├── health/
│ └── users/
└── tests/
Dependency defaults (adjust to requirements):
Django
django-environ (or a small local env parser if you want to avoid extra deps)
pytest, pytest-django
ruff, mypy, django-stubs
2. Large-system structure and boundaries
Use these patterns when the system is expected to grow:
- Group code by domain in
src/apps/<domain>; avoid a single monolithic app.
- Keep views thin; put business logic in services and selectors.
- Use serializers/forms as boundary validators; keep DB access inside selectors or repositories.
- Separate external integrations behind adapters to allow testing and swapping implementations.
- Avoid global mutable state; wire dependencies explicitly.
3. Observability baseline
Observability is non-negotiable for production workloads:
- Configure structured logging and include required fields from the structured logging baseline.
- Add request ID/correlation ID middleware and propagate IDs into logs.
- Provide health endpoints (
/healthz, /readyz) with clear dependency checks.
- Add optional hooks for metrics and tracing (Prometheus or OpenTelemetry) but keep them toggled by configuration.
- Never log secrets or raw personal data.
4. Security baseline
Protect data and enforce secure defaults:
- Load secrets from environment or a secret manager; never commit or log secrets.
- Enable Django security middleware and set production hardening settings (
DEBUG=false, explicit ALLOWED_HOSTS, SECURE_SSL_REDIRECT, SECURE_HSTS_SECONDS, secure cookies).
- Keep CSRF and CORS explicit; avoid permissive wildcards in production.
- Use dependency pinning and vulnerability scanning; keep lock files updated.
- Ensure audit/access logs follow the structured logging baseline without sensitive data.
5. Resilience and availability baseline
Build for failure and recovery:
- Set explicit timeouts on all outbound HTTP/DB calls; never rely on defaults.
- Use retries with bounded backoff and jitter for transient failures; avoid retrying non-idempotent operations without safeguards.
- Use transaction boundaries for multi-step writes; prefer idempotent background jobs.
- Provide graceful shutdown and ensure long-running tasks are interruptible.
- Use caching for hot paths and provide safe fallbacks when caches fail.
6. Quality gates and verification
Align with Python quality gates:
- Prefer
make format, make lint, make typecheck, make test when Makefile targets exist.
- Otherwise use
uv run ruff format ., uv run ruff check ., uv run mypy ., uv run pytest.
- Add
python manage.py check to validate Django configuration before shipping.
Output expectations 📦
When executing this skill, produce:
- A scaffolded Django project or a concrete refactor plan for an existing codebase
- A list of decisions made for observability, security, resilience, and availability
- A short validation checklist using the canonical quality gates
When information is missing, record Unknown from code – {suggested action} instead of guessing.
Version: 1.0.0
Last Amended: 2026-01-18
Converted and distributed by TomeVault — claim your Tome and manage your conversions.
1---2name: django-project3description: Scaffold and evolve Django projects with uv-based tooling, structured settings, and production-ready observability, resilience, availability, and security patterns aligned with python.instructions.md. Use when this capability is needed.4---56# Django Project Skill 🧩78This skill scaffolds new Django projects or upgrades existing ones with a production-ready layout and operational practices suitable for large systems.910## Scope and alignment 🧭1112Mandatory reads (must be loaded before using this skill):1314- [Python instructions](../../instructions/python.instructions.md) — use its identifiers when describing compliance.15- [Local-first dev baseline](../../instructions/includes/local-first-dev-baseline.include.md)16- [Quality gates baseline](../../instructions/includes/quality-gates-baseline.include.md)17- [Observability logging baseline](../../instructions/includes/observability-baseline.include.md)18- [AI-assisted change baseline](../../instructions/includes/ai-assisted-change-baseline.include.md)1920## Inputs to confirm ✅2122- Project name and Python version23- Database (SQLite/PostgreSQL) and cache (Redis/none)24- API surface (Django REST Framework, HTML templates, or both)25- Background jobs (Celery/none) and async worker needs26- Deployment target (container, PaaS, serverless)27- Environment split (local/staging/prod) and secrets strategy2829## Quick reference 🧠3031| Capability | Purpose | Key Outputs |32| --------------------------- | ------------------------------------------------------------------- | ---------------------------------------------------------- |33| Project scaffold | Create a working Django foundation aligned with Python instructions | `pyproject.toml`, `src/` layout, settings split, core apps |34| Large-system structure | Keep growth manageable with clear boundaries | Domain apps, service/selectors, thin views |35| Observability baseline | Operational visibility from day one | Structured logs, request IDs, health endpoints |36| Security baseline | Protect data and reduce risk | Secure defaults, secrets handling, dependency scanning |37| Resilience and availability | Survive failures and scale safely | Timeouts, retries, graceful degradation |38| Quality gates | Enforce fast feedback | `make` targets or uv commands for lint/typecheck/test |3940---4142## Capabilities 🧰4344### 1. Project scaffold (foundation)4546Use this for new projects or to align an existing project with the standard layout.4748Core requirements:4950- Use `pyproject.toml` as the single source of truth. If available, start from [the template](../../instructions/templates/pyproject.toml) and set:51 - project metadata (name, version, requires-python)52 - dependency groups for dev tooling53 - ruff, mypy, pytest configuration54- Use `uv` for deterministic installs and lockfile management.55- Pin Python in `.python-version` and `requires-python`.56- Scaffold with a `src/` layout so imports are explicit and testable.57- Split settings into `base.py`, `local.py`, `production.py`, and `test.py`.58- Provide a minimal `apps/` structure for domain growth.59- Ensure `manage.py` defaults to local settings and can switch via `DJANGO_SETTINGS_MODULE`.6061Recommended layout:6263```text64.65├── .python-version66├── manage.py67├── pyproject.toml68├── src/69│ ├── config/70│ │ ├── __init__.py71│ │ ├── asgi.py72│ │ ├── urls.py73│ │ ├── wsgi.py74│ │ └── settings/75│ │ ├── __init__.py76│ │ ├── base.py77│ │ ├── local.py78│ │ ├── production.py79│ │ └── test.py80│ └── apps/81│ ├── core/82│ ├── health/83│ └── users/84└── tests/85```8687Dependency defaults (adjust to requirements):8889- `Django`90- `django-environ` (or a small local env parser if you want to avoid extra deps)91- `pytest`, `pytest-django`92- `ruff`, `mypy`, `django-stubs`9394### 2. Large-system structure and boundaries9596Use these patterns when the system is expected to grow:9798- Group code by domain in `src/apps/<domain>`; avoid a single monolithic `app`.99- Keep views thin; put business logic in services and selectors.100- Use serializers/forms as boundary validators; keep DB access inside selectors or repositories.101- Separate external integrations behind adapters to allow testing and swapping implementations.102- Avoid global mutable state; wire dependencies explicitly.103104### 3. Observability baseline105106Observability is non-negotiable for production workloads:107108- Configure structured logging and include required fields from the structured logging baseline.109- Add request ID/correlation ID middleware and propagate IDs into logs.110- Provide health endpoints (`/healthz`, `/readyz`) with clear dependency checks.111- Add optional hooks for metrics and tracing (Prometheus or OpenTelemetry) but keep them toggled by configuration.112- Never log secrets or raw personal data.113114### 4. Security baseline115116Protect data and enforce secure defaults:117118- Load secrets from environment or a secret manager; never commit or log secrets.119- Enable Django security middleware and set production hardening settings (`DEBUG=false`, explicit `ALLOWED_HOSTS`, `SECURE_SSL_REDIRECT`, `SECURE_HSTS_SECONDS`, secure cookies).120- Keep CSRF and CORS explicit; avoid permissive wildcards in production.121- Use dependency pinning and vulnerability scanning; keep lock files updated.122- Ensure audit/access logs follow the structured logging baseline without sensitive data.123124### 5. Resilience and availability baseline125126Build for failure and recovery:127128- Set explicit timeouts on all outbound HTTP/DB calls; never rely on defaults.129- Use retries with bounded backoff and jitter for transient failures; avoid retrying non-idempotent operations without safeguards.130- Use transaction boundaries for multi-step writes; prefer idempotent background jobs.131- Provide graceful shutdown and ensure long-running tasks are interruptible.132- Use caching for hot paths and provide safe fallbacks when caches fail.133134### 6. Quality gates and verification135136Align with Python quality gates:137138- Prefer `make format`, `make lint`, `make typecheck`, `make test` when Makefile targets exist.139- Otherwise use `uv run ruff format .`, `uv run ruff check .`, `uv run mypy .`, `uv run pytest`.140- Add `python manage.py check` to validate Django configuration before shipping.141142---143144## Output expectations 📦145146When executing this skill, produce:147148- A scaffolded Django project or a concrete refactor plan for an existing codebase149- A list of decisions made for observability, security, resilience, and availability150- A short validation checklist using the canonical quality gates151152When information is missing, record **Unknown from code – {suggested action}** instead of guessing.153154---155156> **Version**: 1.0.0157> **Last Amended**: 2026-01-18158159---160> Converted and distributed by [TomeVault](https://tomevault.io/claim/stefaniuk) — claim your Tome and manage your conversions.161<!-- tomevault:4.0:skill_md:2026-04-11 -->