A secure-by-default, AI-agent-ready Django template. Clone it, run the
/install skill with your coding agent, then tell the agent what to build. The
production scaffolding — quality gates, CI/CD, security controls, deploy, and a
repo-backed memory system that keeps agents coherent across sessions — is already
done.
Risk-bearing features — logins, accounts, APIs — are opt-in, not bundled. The default install is minimal, and everything it ships is hardened out of the box.
Most Django starters give you framework boilerplate. This one gives you the operating system for building with AI agents: an enforced agent contract, runbooks, durable project memory, and a security/quality gate suite that runs in pre-commit and CI — so an agent (Claude, Codex, etc.) can do real work on your project without drifting, leaking secrets, or shipping the obvious OWASP bugs.
Two gradients keep it coherent:
- Opt-out for things on by default because they're simply better: TypeScript, strict mode, the gates, the memory system.
- Opt-in for features that add attack surface: user accounts, 2FA, a REST API. Add them via the secure recipes below.
- Use this template (green button on GitHub) or clone it, then
cdin. - Open the repo with your agent and run the installer skill:
- Claude Code:
/install - Codex:
$install
- Claude Code:
- Answer the few questions it asks (GitHub repo, and — when you're ready — your deploy target). It sets up the local env, wires GitHub + CI/CD, and validates everything.
- Tell your agent what you want the site to become.
- Python 3.12+, Node 22+, and the GitHub CLI (
gh) authenticated. - For deployment: a VPS or public-facing server you can SSH into (the template deploys via SSH from GitHub Actions). You don't need this to start building locally — only to go live.
python3 -m venv .venv && . .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install -r requirements.txt -r requirements-dev.txt
npm install
cp .env.example .env # then set DEBUG=True and a SECRET_KEY
git config core.hooksPath hooks # enable the pre-commit gate
python manage.py migrate
npm run build:js
python manage.py runserver- Quality + security gates (pre-commit and CI): Gitleaks (secrets), Ruff,
import-linter(architecture boundaries), a project SAST checker (tools/check_security_patterns.py), Semgrep,pip-audit,npm audit, Django tests, TypeScript typecheck, and a "compiled assets are current" check. - Pinned supply chain inputs: direct Python dependencies are pinned,
transitive Python dependencies install through
constraints.txt, npm usespackage-lock.json, and GitHub Actions are pinned to full commit SHAs. - Secure-by-default settings:
DEBUGoff by default; production security headers auto-enable; Argon2 password hashing; secrets only from the environment. - Agent memory system:
AGENTS.mdcontract,docs/runbooks/, topic memory indocs/memory/, an active-state handoff, andtools/check_memory_system.pyto keep it from rotting. - Deploy pipeline: a manual, confirmation-gated GitHub Actions
Deployworkflow that runsdeploy.shover SSH after CI passes. - TypeScript by default with a tiny
tscbuild, no bundler.
Multiple agents are supported because people have different tools and
preferences. The contract is written once in AGENTS.md and mirrored:
| Agent | Tier | File |
|---|---|---|
| Claude Code | full read/write | CLAUDE.md (byte mirror of AGENTS.md) |
| Codex | full read/write | AGENTS.md |
| Gemini / Antigravity | read-only overlay | GEMINI.md |
Edit AGENTS.md, then run python3 tools/sync_agents.py to regenerate the
CLAUDE.md mirror (CI verifies they match).
Gemini defaults to read-only because of weaker agentic-coding reliability — it
can review and propose patches, but not modify files. If Gemini is your only
agent, you can promote it (replace GEMINI.md with a mirror of AGENTS.md), but
treat full install/deploy driven by Gemini as untested; the pre-commit and CI
gates are your safety net regardless of which agent writes the code.
No agent deploys to production unattended: the Deploy workflow is
manual-dispatch, requires a typed deploy confirmation, and only runs after CI
passes for that commit. The agent prepares the change; you trigger the deploy.
Skills live per agent: /install ships for both Claude (.claude/skills/) and
Codex (.agents/skills/); other skills are intentionally per-agent so you can
use each agent for its strengths.
- Provision a server and a deploy SSH key.
- Run
/install(or set them by hand): GitHub Actions VariablesAPP_NAME,REMOTE_HOST,REMOTE_USER,REMOTE_DIR, and SecretsPROD_SSH_PRIVATE_KEY,PROD_SSH_KNOWN_HOSTS. - Push to the default branch; let CI pass.
- Run the Deploy workflow (type
deployto confirm). It verifies CI passed for the commit, then runsdeploy.shover SSH.
The template secures the code path (gates, secret scanning, hardened settings, hardened systemd units). Securing the infrastructure — your VPS, SSH posture, firewall, TLS — is still your responsibility.
If you want plain JS or no build step:
- Delete
tsconfig.json,tsconfig.build.json, and thestatic/web/ts/sources. - Remove the
typecheck/build:jsscripts and thetypescriptdev dep frompackage.json. - Remove the TypeScript, Build JavaScript assets, and Generated
assets are current steps from
.github/workflows/ci.yml. - Point templates at hand-written JS under
static/web/js/.
Add these only when you need them. Each keeps the template's security posture —
ask your agent to follow the recipe and the security-implementation runbook.
- Add
django.contrib.authviews/URLs (login, logout, password reset) or a small accounts app. Keep registration/login logic in a service, not the view. - Argon2 is already the default hasher. Keep the password validators.
- Add
accountstoINSTALLED_APPS,SCAN_ROOTSintools/check_security_patterns.py, and thedeploy.shallowlist. - Add
docs/memory/accounts.md(topic-memory shape) and ownership/IDOR negative tests next to the owning views. - Add a login-endpoint
limit_req_zoneinwebapp_nginx(the base already rate-limits/admin/login/; do the same for your own login route).
- Add
pyotp,qrcode, andcryptographytorequirements.txt, then refreshconstraints.txt. - Store the TOTP secret encrypted at rest (never plaintext), gate login on the second factor, and provide recovery codes.
- Add negative tests: wrong/replayed codes rejected, recovery-code single use.
- Add
djangorestframeworktorequirements.txt, then refreshconstraints.txt. - Authenticate machine endpoints with bearer tokens (not cookies); only then is
csrf_exemptappropriate. Scope every queryset by token/owner. - Add token-scope and IDOR negative tests.
- Add
limit_req_zones inwebapp_nginxfor the public/export endpoints (abuse control), keyed on client IP and returning 429.
config/ Django project (settings, urls, wsgi)
web/ Example app: model, services, thin views, templates, tests
static/web/ts/ TypeScript sources -> compiled to static/web/js/
constraints.txt Resolved Python dependency constraints
tools/ Gate scripts + sync_agents.py
docs/runbooks/ Required workflows
docs/memory/ Durable topic memory
.claude/ .agents/ Per-agent skills, hooks, settings
deploy.sh Production deploy (run by the Deploy workflow)
AGENTS.md Canonical agent contract (mirrored to CLAUDE.md)
MIT — see LICENSE.