agentleFS
kjnezkjnez/claude-code-django/CLAUDE.md

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
  1. Distinctive:

    Use early returns, avoid nested conditionals

    line 29
  2. Distinctive:

    Prefer composition over inheritance

    line 30
  3. Distinctive:

    NEVER swallow errors silently

    line 41
  4. Distinctive:

    Always show user feedback for errors (Django messages, HTMX response headers)

    line 42
  5. Distinctive:

    Always validate request.method explicitly

    line 47
  6. Very specific:

    Use select_related() / prefetch_related() to avoid N+1 queries

    line 49
  7. Very specific:

    Use template inheritance ({% extends %}, {% block %})

    line 52
  8. Very specific:

    Create partial templates for HTMX responses (_partial.html naming)

    line 53
  9. Very specific:

    Always include hx-indicator for loading states

    line 54
  10. Distinctive:

    Use ModelForm for model-backed forms

    line 58
  11. Distinctive:

    Always handle form errors in templates

    line 60
  12. Distinctive:

    Use proper retry strategies with exponential backoff

    line 65
  13. Very specific:

    Always log task start/completion/failure

    line 66
  14. Distinctive:

    Write failing test first (TDD)

    line 71
  15. Very specific:

    Use Factory Boy: UserFactory.create(is_admin=True)

    line 72
  16. Very specific:

    Use pytest fixtures in conftest.py

    line 73
  17. Distinctive:

    Test behavior, not implementation

    line 74
  18. Distinctive:

    Run tests before committing

    line 75
  19. Distinctive:

    Before implementing ANY task, check if relevant skills apply:

    line 79

≈ “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.

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

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 applications
  • config/ - Django settings and root URLconf
  • templates/ - Django/Jinja2 templates
  • static/ - CSS, JavaScript, images
  • tests/ - Test files
  • tasks/ - 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 Any types - use proper type hints or object
  • 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.html naming)
  • Always include hx-indicator for loading states
  • Handle HX-Request header for partial vs full page responses

Forms

  • Use ModelForm for model-backed forms
  • Validate in clean() and clean_<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-debugging skill
  • Exploring Django project (models, URLs, settings) → django-extensions skill
  • Creating new skills → skill-creator skill
  • Starting a new task → onboard skill
  • Working a ticket → ticket skill
  • Reviewing a PR → pr-review skill
  • Summarizing branch changes → pr-summary skill
  • Running quality checks → code-quality skill
  • Checking docs accuracy → docs-sync skill
  • Committing worktree changes and merging to master/main → worktree-commit-merge skill

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 PR

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.

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.