agentleFS
carlosedm10carlosedm10/skills/skills/backend-drf/SKILL.md

backend-drf

Skill1 starsChanged 4 months agoMITView on GitHub

Scaffolds Django REST Framework backends with uv, ruff, pyproject.toml, per-app tests/, and Makefile Django targets (migrate, makemigrations, startapp, createsuperuser, coverage, migration reset). Django project initialization is human-only — the agent creates folder stubs and provides exact official commands. Use when creating DRF backends, adding manage.py Make targets, or when project-scaffold selects DRF over FastAPI.

  • Reads credentials

The file

We split this skill into the rules it gives an agent

5 rules. About 0 are common, 1 is distinctive, and 4 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use backend-fastapi for lightweight APIs without admin or heavy Django infrastructure.

    line 14
  2. Very specific:

    After Compose exists, further apps use make startapp APP=name (not a host manage.py).

    line 88
  3. Very specific:

    After make up / make build, echo:

    line 146
  4. Very specific:

    Use Django native unit tests: APITestCase + APIClient

    line 174
  5. Very specific:

    Run via make test-backend or make test-backend TEST=api.users

    line 176

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Backend DRF

When to use

  • Projects needing Django admin
  • Complex permissions, serializers, and ORM-heavy workflows
  • Teams already invested in the Django ecosystem

Use backend-fastapi for lightweight APIs without admin or heavy Django infrastructure.

Environment

Settings read from env vars (DATABASE_URL, SECRET_KEY, etc.) via python-dotenv in config/settings.py. Locally, env-secrets loads them via .envrc/direnv from gitignored .env. In Docker, Compose passes the same .env via env_file.

Stack

ToolPurpose
uvPackage manager and virtual env
ruffLinting and formatting
pyproject.tomlProject config and dependencies
Django + DRFWeb framework and REST API
PostgreSQLDatabase (via psycopg)
Django TestCase / APITestCaseTesting (see django-test-generation)

Directory layout (after human init)

backend/
├── pyproject.toml
├── uv.lock
├── manage.py
├── config/              # Django project package (settings, urls, wsgi)
│   ├── __init__.py
│   ├── settings.py
│   ├── urls.py
│   └── wsgi.py
└── api/
    └── <app>/
        ├── __init__.py
        ├── models.py
        ├── serializers.py
        ├── views.py
        ├── urls.py
        └── tests/
            ├── __init__.py
            └── test_<area>.py

Each Django app has its own tests/ directory.

Scaffold workflow

Phase 1 — Agent creates stubs only

  1. Create empty backend/ directory.
  2. Create backend/pyproject.toml with Django/DRF deps (see reference.md).
  3. Create .gitkeep or placeholder files as needed.
  4. Print the human-init commands below — do NOT execute them.

Phase 2 — Human runs official Django commands

Provide these exact commands for the user to run inside backend/:

cd backend

# Initialize uv project (if not already done)
uv init --no-readme

# Add dependencies
uv add django djangorestframework psycopg[binary] python-dotenv
uv add --dev ruff pytest-django factory-boy coverage

# Create Django project
uv run django-admin startproject config .

# Create apps (repeat per feature)
uv run python manage.py startapp users api/users

Adjust app names and paths to match the project. startproject must be run by the human. After Compose exists, further apps use make startapp APP=name (not a host manage.py).

Phase 3 — Agent continues after human init

Once the user confirms Django init is done:

  1. Configure config/settings.py: add rest_framework, database from DATABASE_URL, installed apps.
  2. Configure config/urls.py: include app URL patterns under /api/.
  3. Set up ruff in pyproject.toml.
  4. Create tests/ directories inside each app.
  5. Point to django-test-generation for writing tests.

pyproject.toml essentials

[project]
name = "PROJECT_SLUG"
version = "0.1.0"
requires-python = ">=3.12"
dependencies = [
    "django>=5.1",
    "djangorestframework>=3.15",
    "psycopg[binary]>=3.2",
    "python-dotenv>=1.0",
]

[dependency-groups]
dev = [
    "ruff>=0.8",
    "pytest-django>=4.9",
    "factory-boy>=3.3",
    "coverage>=7.6",
]

[tool.ruff]
target-version = "py312"
line-length = 100

Makefile — Django section

makefile-operations owns lifecycle (up/down/build, never start/stop), uv-* / bun-*, shells, logs-* (never show-*-logs), lint / format / lint-fix, and nuclear clean. This skill owns every manage.py target. Copy the full section from reference.md.

TargetNotes
startappAPP=name; always created at api/$(APP). run --rm. After Docker exists, this is how new apps are added — not a raw manage.py on the host.
createsuperuserexec without -T so the interactive prompts work.
migrateBare verb. exec -T when the stack is up; run --rm if it is not.
migrate-seedmigrate then loaddata seeds.
makemigrationsSame transport as migrate.
db-load-schema-testTest-settings migrate; CI calls this before the suite.
test-backendmanage.py test --verbosity=1 --force-color --noinput --failfast. Filter with TEST= (Django label/path), not a second tests target and not pytest -k.
coverage / coverage-htmlcoverage run manage.py test then report or html. HTML lands in backend/htmlcov/.
delete-migrationsDanger zone. Deletes backend/api/*/migrations/*.py except __init__.py.
db-reset-fullDanger zone. delete-migrations, drop/recreate public schema, makemigrations, migrate. Do not chain format into it.

After make up / make build, echo:

Django Admin: http://localhost:8000/admin/
Swagger:      http://localhost:8000/api/docs/
ReDoc:        http://localhost:8000/api/redoc/
Frontend:     http://localhost:3000/

(api/docs / api/redoc assume spectacular or equivalent is wired; still print them so the local surface is discoverable.)

Agent may write

  • pyproject.toml stub before human init
  • Settings, URLs, serializers, views after human init
  • tests/ directories and test files (via django-test-generation)
  • The Django Makefile section (via makefile-operations conventions)

Agent must NOT execute

  • django-admin startproject
  • python manage.py startapp on the host — use make startapp APP=… once Compose exists
  • python manage.py migrate / db-reset-full / delete-migrations unless the user explicitly requests them and containers are running

Testing conventions

  • Use Django native unit tests: APITestCase + APIClient
  • Tests live in tests/ inside each app, not a top-level tests/ folder
  • Run via make test-backend or make test-backend TEST=api.users
  • See django-test-generation skill for detailed patterns

Integration with sibling skills

SkillWhen
dockerization-templateDocker setup with runserver dev command
makefile-operationsGeneric up/down/uv-*/bun-*/lint/logs-*/clean; splice this skill's Django section in
django-test-generationWriting DRF endpoint tests
github-actionsCI calls make lint / make test

Additional resources

  • Settings, URLs, and the Django Makefile section: reference.md

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.