Agents are quick at Django and quick to leave behind the classic problems: model changes without migrations, edited migrations that already ran, N+1 queries in list views, csrf_exempt to make a form work, DEBUG and SECRET_KEY in code. This loadout sets the rules from Django's own docs, adds makemigrations --check and check --deploy as gates, and ships a safe-migration skill with a two-release path for removals and renames and a query-count test that the verifier runs against a real N+1.
What's in it
- makemigrations --check --dry-run and manage.py check as done-gates
- Two-release path for removing or renaming columns
- assertNumQueries test that catches N+1 queries
- Data migrations with apps.get_model and a backwards function
- No csrf_exempt, no |safe on user input, secrets from the environment
You'll need
- Tools:
uv
Verification
| Check | Result | What we found |
|---|---|---|
| Listinglisting.yaml matches the schema and declares every file in the folder. | Pass | Schema valid; 5 files declared, none missing or extra
|
| Files parseJSON parses; SKILL.md and .mdc front matter is valid YAML with the fields each agent needs; code fences are closed. | Pass | All 5 files parse; front matter valid |
| AdaptersCLAUDE.md imports @AGENTS.md, GEMINI.md imports @./AGENTS.md, and both match the generator. | Pass | CLAUDE.md and GEMINI.md import AGENTS.md and are up to date
|
| Install pathsEvery file lands where each agent documents it, with no collisions, and the laid-out project is re-discovered correctly. | Pass | Correct paths for all 6 agents; layouts re-discovered
|
| MCP configmcp.json is structurally valid, converts to each agent's format, declares no literal secrets, and referenced packages exist on npm/PyPI. | Not applicable | No MCP servers in this loadout |
| Safety scanThe intake scanner finds no credentials, risky shell, hidden Unicode or prompt-injection wording, and the listing's network flag is honest. | Pass | Clean: no credentials, risky shell or hidden text
|
| ReferencesLinks and file paths between the loadout's files resolve, including for each agent's installed layout. | Pass | 1 reference between files resolves for every agent |
| Size limitsFile count and sizes are within the submission limits; SKILL.md bodies stay under 500 lines. | Pass | 5 files, 4.9 KB total; largest AGENTS.md 2.0 KB
|
| LicenceA recognised SPDX licence, with the licence text available. | Pass | MIT, by Agent Loadout; text in the repository LICENSE |
| Starter buildA minimal fixture project with the loadout applied installs and builds or type-checks, and the loadout's own code examples compile. | Pass | In a small Django project: manage.py check passes, makemigrations --check finds no missing migration, the skill's query-count test passes with select_related and catches an N+1 version
|
What this means: a script checked the files themselves: they parse, they install where each agent looks, any MCP config is sound, the safety scan is clean, references between files resolve, and, where a free and repeatable fixture exists, a small starter project builds with the loadout applied. No AI agent was run. Per-agent results ("tested with agent") are separate and stay untested until an agent actually runs.
Install
Choose your agent. Run the commands from your project root, or download a zip already laid out in the right folders.
Claude Code reads CLAUDE.md (imports AGENTS.md with @AGENTS.md) and skills from .claude/skills/.
curl -fsSL --create-dirs -o AGENTS.md https://loadout.jnw-it.com/raw/django-app/1.0.0/AGENTS.md curl -fsSL --create-dirs -o CLAUDE.md https://loadout.jnw-it.com/raw/django-app/1.0.0/CLAUDE.md curl -fsSL --create-dirs -o .claude/skills/safe-migration/SKILL.md https://loadout.jnw-it.com/raw/django-app/1.0.0/skills/safe-migration/SKILL.md curl -fsSL --create-dirs -o .claude/skills/safe-migration/references/test_query_count.py https://loadout.jnw-it.com/raw/django-app/1.0.0/skills/safe-migration/references/test_query_count.py
| File | Goes to |
|---|---|
AGENTS.md | AGENTS.md |
CLAUDE.md | CLAUDE.md |
skills/safe-migration/SKILL.md | .claude/skills/safe-migration/SKILL.md |
skills/safe-migration/references/test_query_count.py | .claude/skills/safe-migration/references/test_query_count.py |
Already have an AGENTS.md or CLAUDE.md? The commands above overwrite it — download the file instead and merge the sections you want.
Codex CLI reads AGENTS.md and skills from .agents/skills/.
curl -fsSL --create-dirs -o AGENTS.md https://loadout.jnw-it.com/raw/django-app/1.0.0/AGENTS.md curl -fsSL --create-dirs -o .agents/skills/safe-migration/SKILL.md https://loadout.jnw-it.com/raw/django-app/1.0.0/skills/safe-migration/SKILL.md curl -fsSL --create-dirs -o .agents/skills/safe-migration/references/test_query_count.py https://loadout.jnw-it.com/raw/django-app/1.0.0/skills/safe-migration/references/test_query_count.py
| File | Goes to |
|---|---|
AGENTS.md | AGENTS.md |
skills/safe-migration/SKILL.md | .agents/skills/safe-migration/SKILL.md |
skills/safe-migration/references/test_query_count.py | .agents/skills/safe-migration/references/test_query_count.py |
Already have an AGENTS.md or CLAUDE.md? The commands above overwrite it — download the file instead and merge the sections you want.
Cursor reads AGENTS.md + .cursor/rules/*.mdc and skills from .agents/skills/.
curl -fsSL --create-dirs -o AGENTS.md https://loadout.jnw-it.com/raw/django-app/1.0.0/AGENTS.md curl -fsSL --create-dirs -o .agents/skills/safe-migration/SKILL.md https://loadout.jnw-it.com/raw/django-app/1.0.0/skills/safe-migration/SKILL.md curl -fsSL --create-dirs -o .agents/skills/safe-migration/references/test_query_count.py https://loadout.jnw-it.com/raw/django-app/1.0.0/skills/safe-migration/references/test_query_count.py
| File | Goes to |
|---|---|
AGENTS.md | AGENTS.md |
skills/safe-migration/SKILL.md | .agents/skills/safe-migration/SKILL.md |
skills/safe-migration/references/test_query_count.py | .agents/skills/safe-migration/references/test_query_count.py |
Already have an AGENTS.md or CLAUDE.md? The commands above overwrite it — download the file instead and merge the sections you want.
Gemini CLI reads GEMINI.md (imports AGENTS.md with @./AGENTS.md) and skills from .agents/skills/.
curl -fsSL --create-dirs -o AGENTS.md https://loadout.jnw-it.com/raw/django-app/1.0.0/AGENTS.md curl -fsSL --create-dirs -o GEMINI.md https://loadout.jnw-it.com/raw/django-app/1.0.0/GEMINI.md curl -fsSL --create-dirs -o .agents/skills/safe-migration/SKILL.md https://loadout.jnw-it.com/raw/django-app/1.0.0/skills/safe-migration/SKILL.md curl -fsSL --create-dirs -o .agents/skills/safe-migration/references/test_query_count.py https://loadout.jnw-it.com/raw/django-app/1.0.0/skills/safe-migration/references/test_query_count.py
| File | Goes to |
|---|---|
AGENTS.md | AGENTS.md |
GEMINI.md | GEMINI.md |
skills/safe-migration/SKILL.md | .agents/skills/safe-migration/SKILL.md |
skills/safe-migration/references/test_query_count.py | .agents/skills/safe-migration/references/test_query_count.py |
Already have an AGENTS.md or CLAUDE.md? The commands above overwrite it — download the file instead and merge the sections you want.
Antigravity CLI reads AGENTS.md (read natively; GEMINI.md is also read) and skills from .agents/skills/.
curl -fsSL --create-dirs -o AGENTS.md https://loadout.jnw-it.com/raw/django-app/1.0.0/AGENTS.md curl -fsSL --create-dirs -o .agents/skills/safe-migration/SKILL.md https://loadout.jnw-it.com/raw/django-app/1.0.0/skills/safe-migration/SKILL.md curl -fsSL --create-dirs -o .agents/skills/safe-migration/references/test_query_count.py https://loadout.jnw-it.com/raw/django-app/1.0.0/skills/safe-migration/references/test_query_count.py
| File | Goes to |
|---|---|
AGENTS.md | AGENTS.md |
skills/safe-migration/SKILL.md | .agents/skills/safe-migration/SKILL.md |
skills/safe-migration/references/test_query_count.py | .agents/skills/safe-migration/references/test_query_count.py |
Already have an AGENTS.md or CLAUDE.md? The commands above overwrite it — download the file instead and merge the sections you want.
GitHub Copilot reads AGENTS.md and skills from .agents/skills/.
curl -fsSL --create-dirs -o AGENTS.md https://loadout.jnw-it.com/raw/django-app/1.0.0/AGENTS.md curl -fsSL --create-dirs -o .agents/skills/safe-migration/SKILL.md https://loadout.jnw-it.com/raw/django-app/1.0.0/skills/safe-migration/SKILL.md curl -fsSL --create-dirs -o .agents/skills/safe-migration/references/test_query_count.py https://loadout.jnw-it.com/raw/django-app/1.0.0/skills/safe-migration/references/test_query_count.py
| File | Goes to |
|---|---|
AGENTS.md | AGENTS.md |
skills/safe-migration/SKILL.md | .agents/skills/safe-migration/SKILL.md |
skills/safe-migration/references/test_query_count.py | .agents/skills/safe-migration/references/test_query_count.py |
Already have an AGENTS.md or CLAUDE.md? The commands above overwrite it — download the file instead and merge the sections you want.
Files
Rules AGENTS.md Django rules for models, migrations, queries and security. 33 lines
# AGENTS.md: Django app
Django project managed with uv. Supported Django: 5.2 LTS or 6.x; check `pyproject.toml` before using a newer API.
## Commands
- Run: `uv run python manage.py runserver`. Shell: `uv run python manage.py shell`.
- Tests: `uv run pytest -q` (pytest-django) or `uv run python manage.py test`.
- Checks before saying done: `uv run python manage.py check`, `uv run python manage.py makemigrations --check --dry-run`
(must report no changes), tests, and `uv run ruff check .`.
- Deployment settings: `uv run python manage.py check --deploy` with production settings.
## Models and migrations
- Every model change ships with its migration in the same commit. Use the `safe-migration` skill.
- Never edit or delete a migration that may have run anywhere else. Add a new one.
- In data migrations use `apps.get_model("app", "Model")`, never import the model class.
- Read the SQL of risky migrations with `uv run python manage.py sqlmigrate <app> <number>` and show it to the human.
## Queries
- No N+1: `select_related` for foreign keys, `prefetch_related` for reverse and many-to-many. Prove it with
`assertNumQueries` (or `django_assert_num_queries` in pytest-django) when you touch a list view.
- Writes that must succeed together go in `transaction.atomic()`.
- Never build SQL with string formatting. Use the ORM, or `raw()` and `cursor.execute()` with parameters.
## Security
- `SECRET_KEY`, `DEBUG`, `ALLOWED_HOSTS` and database credentials come from the environment, never hard-coded.
- Never add `@csrf_exempt` to a view that uses session auth. Never mark user input `mark_safe` or `|safe`.
- Validate input with forms or serializers, not by reading `request.POST` directly.
- Views that need a login use `LoginRequiredMixin` or `@login_required`; check object ownership in the queryset.
## Style
- Fat models, thin views: business rules on the model or in a service module, not in templates.
- Settings changes go in the settings module the project already uses; do not add a second settings system. Adapter CLAUDE.md Imports AGENTS.md for Claude Code. 10 lines
# CLAUDE.md
@AGENTS.md
## Claude Code notes
- Skills from this loadout live in `.claude/skills/`: `safe-migration`. Use them when their description matches the task.
- Follow AGENTS.md above; where this file and AGENTS.md disagree, AGENTS.md wins.
<!-- From the Agent Loadout "Django app rules" v1.0.0 — https://loadout.jnw-it.com/loadouts/django-app/ --> Adapter GEMINI.md Imports AGENTS.md for Gemini CLI. 10 lines
# GEMINI.md
@./AGENTS.md
## Gemini CLI notes
- Skills from this loadout live in `.agents/skills/`: `safe-migration`. Use them when their description matches the task.
- Follow AGENTS.md above; where this file and AGENTS.md disagree, AGENTS.md wins.
<!-- From the Agent Loadout "Django app rules" v1.0.0 — https://loadout.jnw-it.com/loadouts/django-app/ --> Skill skills/safe-migration/SKILL.md Model change with reviewed SQL and a zero-downtime path. 20 lines
---
name: safe-migration
description: Make a Django model change with a reviewed migration, a zero-downtime path for destructive changes and a query-count test. Use when adding, renaming or removing fields or models.
---
# Safe migration
1. Change the model. Run `uv run python manage.py makemigrations <app>` and read the generated file.
2. Show the SQL: `uv run python manage.py sqlmigrate <app> <number>`. Flag to the human anything that rewrites or locks a
large table (adding a non-null column with a default on old databases, new indexes on big tables, type changes).
3. Destructive changes take two releases:
- Remove a field: release 1 stops using it in code (and makes it nullable if needed); release 2 drops the column.
- Rename: add the new field, copy data in a data migration, switch code, drop the old field later.
Never rely on `makemigrations` guessing a rename on a production table without checking the SQL.
4. Data migrations: `RunPython(forwards, backwards)` using `apps.get_model`. Batch large updates. Always give a
`backwards` function, or `migrations.RunPython.noop` if reversing is genuinely safe to skip.
5. Run `uv run python manage.py migrate` locally, then `makemigrations --check --dry-run` (no changes left) and tests.
6. If a list view or API touches the changed model, add a query-count test like `references/test_query_count.py`.
7. Report: migration file, SQL summary, whether it is safe to run on a live database, and the follow-up release if any. Skill file skills/safe-migration/references/test_query_count.py assertNumQueries test against N+1 queries. 24 lines
"""Query-count test: a list of books with authors must not issue one query per book (N+1).
Adapt the app, model and function names. Uses Django's TestCase.assertNumQueries.
"""
from django.test import TestCase
from shop.models import Author, Book
from shop.queries import book_titles_with_authors
class BookListQueries(TestCase):
@classmethod
def setUpTestData(cls):
for i in range(5):
author = Author.objects.create(name=f"Author {i}")
Book.objects.create(title=f"Book {i}", author=author)
def test_one_query_for_any_number_of_books(self):
with self.assertNumQueries(1):
rows = book_titles_with_authors()
self.assertEqual(len(rows), 5)
self.assertEqual(rows[0], ("Book 0", "Author 0")) All files: source zip · Licence MIT · By Agent Loadout · First listed
Credits
Public work that inspired this loadout. The wording here is our own; follow the links for the originals.
Installing and testing
How do I install Django app rules in Claude Code?
From your project root, put AGENTS.md, CLAUDE.md, skills/safe-migration/SKILL.md at .claude/skills/safe-migration/SKILL.md, skills/safe-migration/references/test_query_count.py at .claude/skills/safe-migration/references/test_query_count.py. The "Claude Code" tab on this page has the curl commands, or download https://loadout.jnw-it.com/download/django-app/claude-code.zip, which is already laid out. Do not overwrite an existing AGENTS.md or CLAUDE.md; merge it.
How do I install Django app rules in Codex CLI?
From your project root, put AGENTS.md, skills/safe-migration/SKILL.md at .agents/skills/safe-migration/SKILL.md, skills/safe-migration/references/test_query_count.py at .agents/skills/safe-migration/references/test_query_count.py. The "Codex CLI" tab on this page has the curl commands, or download https://loadout.jnw-it.com/download/django-app/codex.zip, which is already laid out. Do not overwrite an existing AGENTS.md or CLAUDE.md; merge it.
How do I install Django app rules in Cursor?
From your project root, put AGENTS.md, skills/safe-migration/SKILL.md at .agents/skills/safe-migration/SKILL.md, skills/safe-migration/references/test_query_count.py at .agents/skills/safe-migration/references/test_query_count.py. The "Cursor" tab on this page has the curl commands, or download https://loadout.jnw-it.com/download/django-app/cursor.zip, which is already laid out. Do not overwrite an existing AGENTS.md or CLAUDE.md; merge it.
How do I install Django app rules in Gemini CLI?
From your project root, put AGENTS.md, GEMINI.md, skills/safe-migration/SKILL.md at .agents/skills/safe-migration/SKILL.md, skills/safe-migration/references/test_query_count.py at .agents/skills/safe-migration/references/test_query_count.py. The "Gemini CLI" tab on this page has the curl commands, or download https://loadout.jnw-it.com/download/django-app/gemini-cli.zip, which is already laid out. Do not overwrite an existing AGENTS.md or CLAUDE.md; merge it.
How do I install Django app rules in Antigravity CLI?
From your project root, put AGENTS.md, skills/safe-migration/SKILL.md at .agents/skills/safe-migration/SKILL.md, skills/safe-migration/references/test_query_count.py at .agents/skills/safe-migration/references/test_query_count.py. The "Antigravity CLI" tab on this page has the curl commands, or download https://loadout.jnw-it.com/download/django-app/antigravity-cli.zip, which is already laid out. Do not overwrite an existing AGENTS.md or CLAUDE.md; merge it.
How do I install Django app rules in GitHub Copilot?
From your project root, put AGENTS.md, skills/safe-migration/SKILL.md at .agents/skills/safe-migration/SKILL.md, skills/safe-migration/references/test_query_count.py at .agents/skills/safe-migration/references/test_query_count.py. The "GitHub Copilot" tab on this page has the curl commands, or download https://loadout.jnw-it.com/download/django-app/copilot.zip, which is already laid out. Do not overwrite an existing AGENTS.md or CLAUDE.md; merge it.
Has Django app rules been tested?
It passed the Level 1 automated install checks on 2026-10-17: the files parse, install to each agent's documented paths, and pass the safety scan. No AI agent has run it yet, so no agent pass or fail is claimed.
More for Claude Code, Codex, Cursor, Gemini CLI, Antigravity CLI and GitHub Copilot.