claude-code-django
CLAUDE.md177 starsChanged 10 months agoMITView on GitHub
Claude Code configuration for Django projects with HTMX and modern Python tooling. Before implementing ANY task, check if relevant skills apply:
- Commits and pushes
We split this CLAUDE.md into the rules it gives an agent
19 rules. About 0 are common, 12 are distinctive, and 7 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈12
Distinctive · estimate
This author's own choices. Worth a look.
7
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Distinctive: line 29
Use early returns, avoid nested conditionals
- Distinctive: line 30
Prefer composition over inheritance
- Distinctive: line 41
NEVER swallow errors silently
- Distinctive: line 42
Always show user feedback for errors (Django messages, HTMX response headers)
- Distinctive: line 47
Always validate request.method explicitly
- Very specific: line 49
Use select_related() / prefetch_related() to avoid N+1 queries
- Very specific: line 52
Use template inheritance ({% extends %}, {% block %})
- Very specific: line 53
Create partial templates for HTMX responses (_partial.html naming)
- Very specific: line 54
Always include hx-indicator for loading states
- Distinctive: line 58
Use ModelForm for model-backed forms
- Distinctive: line 60
Always handle form errors in templates
- Distinctive: line 65
Use proper retry strategies with exponential backoff
- Very specific: line 66
Always log task start/completion/failure
- Distinctive: line 71
Write failing test first (TDD)
- Very specific: line 72
Use Factory Boy: UserFactory.create(is_admin=True)
- Very specific: line 73
Use pytest fixtures in conftest.py
- Distinctive: line 74
Test behavior, not implementation
- Distinctive: line 75
Run tests before committing
- Distinctive: line 79
Before implementing ANY task, check if relevant skills apply:
≈ “Common” is an estimate: at least 1 in 5 of the 25,680 CLAUDE.md 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.
Files
Django Project
Claude Code configuration for Django projects with HTMX and modern Python tooling.
Quick Facts
- Stack: Django, PostgreSQL, HTMX
- Package Manager: uv
- Test Command:
uv run pytest - Lint Command:
uv run ruff check . - Format Command:
uv run ruff format . - Type Check:
uv run pyright
Key Directories
apps/- Django applicationsconfig/- Django settings and root URLconftemplates/- Django/Jinja2 templatesstatic/- CSS, JavaScript, imagestests/- Test filestasks/- Celery tasks
Code Style
- Python 3.12+ with type hints required
- Ruff for linting and formatting (replaces black, isort, flake8)
- pyright strict mode enabled
- No
Anytypes - use proper type hints orobject - Use early returns, avoid nested conditionals
- Prefer composition over inheritance
Git Conventions
- Branch naming:
{initials}/{description}(e.g.,jd/fix-login) - Commit format: Conventional Commits (
feat:,fix:,docs:, etc.) - PR titles: Same as commit format
Critical Rules
Error Handling
- NEVER swallow errors silently
- Always show user feedback for errors (Django messages, HTMX response headers)
- Log errors with proper context for debugging
Views
- Prefer Function-Based Views
- Always validate request.method explicitly
- Return proper HTTP status codes
- Use
select_related()/prefetch_related()to avoid N+1 queries
Templates & HTMX
- Use template inheritance (
{% extends %},{% block %}) - Create partial templates for HTMX responses (
_partial.htmlnaming) - Always include
hx-indicatorfor loading states - Handle
HX-Requestheader for partial vs full page responses
Forms
- Use ModelForm for model-backed forms
- Validate in
clean()andclean_<field>()methods - Always handle form errors in templates
- Disable submit buttons during HTMX requests
Celery Tasks
- Tasks must be idempotent
- Use proper retry strategies with exponential backoff
- Always log task start/completion/failure
- Pass serializable arguments only (no model instances)
Testing
- Write failing test first (TDD)
- Use Factory Boy:
UserFactory.create(is_admin=True) - Use pytest fixtures in
conftest.py - Test behavior, not implementation
- Run tests before committing
Skill Activation
Before implementing ANY task, check if relevant skills apply:
- Debugging issues →
systematic-debuggingskill - Exploring Django project (models, URLs, settings) →
django-extensionsskill - Creating new skills →
skill-creatorskill - Starting a new task →
onboardskill - Working a ticket →
ticketskill - Reviewing a PR →
pr-reviewskill - Summarizing branch changes →
pr-summaryskill - Running quality checks →
code-qualityskill - Checking docs accuracy →
docs-syncskill - Committing worktree changes and merging to master/main →
worktree-commit-mergeskill
Common Commands
# Development
uv run python manage.py runserver # Start dev server
uv run pytest # Run tests
uv run pytest -x --lf # Run last failed, stop on first failure
uv run ruff check . # Lint code
uv run ruff format . # Format code
uv run pyright # Type check
# Django
uv run python manage.py makemigrations
uv run python manage.py migrate
uv run python manage.py shell_plus # Enhanced shell (django-extensions)
uv run python manage.py createsuperuser
# Celery
uv run celery -A config worker -l info
uv run celery -A config beat -l info
# Dependencies
uv sync # Install from pyproject.toml
uv add <package> # Add new dependency
uv add --dev <package> # Add dev dependency
# Git
gh pr create # Create PRIn this repository16 other files it gives its agents.
- celery-patternsSkill
- code-qualitySkill
- django-extensionsSkill
- django-formsSkill
- django-modelsSkill
- django-templatesSkill
- docs-syncSkill
- htmx-patternsSkill
- onboardSkill
- pr-reviewSkill
- pr-summarySkill
- pytest-django-patternsSkill
- skill-creatorSkill
- systematic-debuggingSkill
- ticketSkill
- worktree-commit-mergeSkill
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
Reviews can't be read right now.
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.

