Communitygithub.com

django-verification

Verifikationsschleife für Django-Projekte: Migrationen, Linting, Tests mit Coverage, Sicherheitsscans und Deployment-Readiness-Checks vor Releases oder PRs.

Was ist django-verification?

Die Django-Verification-Schleife ist eine automatisierte Pipeline, die vor Pull-Requests, nach großen Änderungen und vor dem Deployment ausgeführt wird, um die Qualität und Sicherheit von Django-Anwendungen sicherzustellen. Sie ist für Entwickler:innen und CI/CD-Systeme konzipiert und unterstützt lokale Terminals, GitHub Actions sowie andere CI-Plattformen. Der Prozess durchläuft 12 Phasen: Umgebungscheck, Codequalität (mypy, ruff, black, isort), Migrationen, Tests mit Coverage (pytest), Sicherheitsscans (pip-audit, safety, bandit, gitleaks), Django-Verwaltungsbefehle, Performance-Prüfungen (N+1-Queries, Indizes), statische Assets, Konfigurationsreview, Logging, API-Dokumentation und Diff-Review. Jede Phase meldet klare Ergebnisse, und eine Zusammenfassung gibt eine Deployment-Empfehlung (OK/WARN/BLOCK). Das Tool automatisiert bewährte Praktiken und erkennt häufige Fehler wie Debug-Modus in Produktion, fehlende Migrationen, Hardcoded Secrets oder Sicherheitslücken in Abhängigkeiten – und ersetzt so manuelle Checklisten durch eine wiederholbare, robuste Prüfungsroutine.

Funktioniert mit~Claude Code~Codex CLI✓Cursor
npx skills add https://github.com/affaan-m/everything-claude-code/tree/main/skills/django-verification

In Ihrer bevorzugten KI fragen

Öffnet einen neuen Chat, in dem dieser Agent-Skill bereits geladen ist.

Dokumentation

Django Verificationsschleife

Führen Sie diese Prüfungen vor Pull-Requests, nach größeren Änderungen und vor dem Deployment durch, um Qualität und Sicherheit Ihrer Django-Anwendung sicherzustellen.

Wann aktivieren

  • Vor dem Öffnen eines Pull-Requests für ein Django-Projekt
  • Nach größeren Modelländerungen, Migrationsupdates oder Abhängigkeits-Upgrades
  • Pre-Deployment-Verifikation für Staging oder Produktion
  • Durchlaufen der vollständigen Pipeline: Umgebung → Lint → Test → Sicherheit → Deployment-Readiness
  • Validierung der Migrationssicherheit und Testabdeckung

Phase 1: Umgebungscheck

# Python-Version prüfen
python --version  # Sollte den Projektanforderungen entsprechen

# Virtuelle Umgebung prüfen
which python
pip list --outdated

# Umgebungsvariablen prüfen
python -c "import os; import environ; print('DJANGO_SECRET_KEY gesetzt' if os.environ.get('DJANGO_SECRET_KEY') else 'FEHLT: DJANGO_SECRET_KEY')"

Wenn die Umgebung fehlerhaft konfiguriert ist, anhalten und korrigieren.

Phase 2: Codequalität & Formatierung

# Typprüfung
mypy . --config-file pyproject.toml

# Linting mit ruff
ruff check . --fix

# Formatierung mit black
black . --check
black .  # Automatische Korrektur

# Imports sortieren
isort . --check-only
isort .  # Automatische Korrektur

# Django-spezifische Prüfungen
python manage.py check --deploy

Häufige Probleme:

  • Fehlende Typannotationen bei öffentlichen Funktionen
  • PEP 8-Formatierungsverstöße
  • Unsorted imports
  • Debug-Einstellungen in der Produktionskonfiguration

Phase 3: Migrationen

# Nicht angewendete Migrationen prüfen
python manage.py showmigrations

# Fehlende Migrationen erkennen
python manage.py makemigrations --check

# Migrationen trocken anwenden
python manage.py migrate --plan

# Migrationen anwenden (Testumgebung)
python manage.py migrate

# Migrationskonflikte prüfen
python manage.py makemigrations --merge  # Nur bei Konflikten

Bericht:

  • Anzahl ausstehender Migrationen
  • Eventuelle Migrationskonflikte
  • Modelländerungen ohne Migrationen

Phase 4: Tests + Coverage

# Alle Tests mit pytest ausführen
pytest --cov=apps --cov-report=html --cov-report=term-missing --reuse-db

# Tests einer bestimmten App ausführen
pytest apps/users/tests/

# Mit Markern ausführen
pytest -m "not slow"  # Langsame Tests überspringen
pytest -m integration  # Nur Integrationstests

# Coverage-Bericht öffnen
open htmlcov/index.html

Bericht:

  • Gesamttests: X bestanden, Y fehlgeschlagen, Z übersprungen
  • Gesamtabdeckung: XX%
  • Abdeckung pro App

Coverage-Ziele:

KomponenteZiel
Modelle90 %+
Serializer85 %+
Views80 %+
Services90 %+
Gesamt80 %+

Phase 5: Sicherheitsscan

# Schwachstellen in Abhängigkeiten
pip-audit
safety check --full-report

# Django-Sicherheitsprüfungen
python manage.py check --deploy

# Bandit-Sicherheitslinter
bandit -r . -f json -o bandit-report.json

# Geheimnissuche (falls gitleaks installiert)
gitleaks detect --source . --verbose

# Umgebungsvariablen prüfen
python -c "from django.core.exceptions import ImproperlyConfigured; from django.conf import settings; settings.DEBUG"

Bericht:

  • Gefundene anfällige Abhängigkeiten
  • Sicherheitskonfigurationsprobleme
  • Hardcodierte Geheimnisse erkannt
  • DEBUG-Modus-Status (sollte in Produktion False sein)

Phase 6: Django-Verwaltungsbefehle

# Modellprobleme prüfen
python manage.py check

# Statische Dateien sammeln
python manage.py collectstatic --noinput --clear

# Superuser erstellen (falls für Tests benötigt)
echo "from apps.users.models import User; User.objects.create_superuser('[email protected]', 'admin')" | python manage.py shell

# Datenbankintegrität
python manage.py check --database default

# Cache-Verifikation (falls Redis verwendet wird)
python -c "from django.core.cache import cache; cache.set('test', 'value', 10); print(cache.get('test'))"

Phase 7: Performance-Prüfungen

# Django Debug Toolbar-Ausgabe (auf N+1-Abfragen prüfen)
# Im Entwicklungsmodus mit DEBUG=True ausführen und eine Seite aufrufen
# Nach doppelten Abfragen im SQL-Panel suchen

# Abfrageanzahl-Analyse
django-admin debugsqlshell  # Falls django-debug-sqlshell installiert ist

# Fehlende Indizes prüfen
python manage.py shell << EOF
from django.db import connection
with connection.cursor() as cursor:
    cursor.execute("SELECT table_name, index_name FROM information_schema.statistics WHERE table_schema = 'public'")
    print(cursor.fetchall())
EOF

Bericht:

  • Anzahl Abfragen pro Seite (sollte < 50 für typische Seiten sein)
  • Fehlende Datenbankindizes
  • Erkannte doppelte Abfragen

Phase 8: Statische Assets

# npm-Abhängigkeiten prüfen (falls verwendet)
npm audit
npm audit fix

# Statische Dateien bauen (falls webpack/vite verwendet)
npm run build

# Statische Dateien verifizieren
ls -la staticfiles/
python manage.py findstatic css/style.css

Phase 9: Konfigurationsreview

# In der Python-Shell ausführen, um Einstellungen zu prüfen
python manage.py shell << EOF
from django.conf import settings
import os

# Kritische Prüfungen
checks = {
    'DEBUG is False': not settings.DEBUG,
    'SECRET_KEY gesetzt': bool(settings.SECRET_KEY and len(settings.SECRET_KEY) > 30),
    'ALLOWED_HOSTS gesetzt': len(settings.ALLOWED_HOSTS) > 0,
    'HTTPS aktiviert': getattr(settings, 'SECURE_SSL_REDIRECT', False),
    'HSTS aktiviert': getattr(settings, 'SECURE_HSTS_SECONDS', 0) > 0,
    'Datenbank konfiguriert': settings.DATABASES['default']['ENGINE'] != 'django.db.backends.sqlite3',
}

for check, result in checks.items():
    status = '✓' if result else '✗'
    print(f"{status} {check}")
EOF

Phase 10: Logging-Konfiguration

# Logging-Ausgabe testen
python manage.py shell << EOF
import logging
logger = logging.getLogger('django')
logger.warning('Test-Warnmeldung')
logger.error('Test-Fehlermeldung')
EOF

# Logdateien prüfen (falls konfiguriert)
tail -f /var/log/django/django.log

Phase 11: API-Dokumentation (falls DRF)

# Schema generieren
python manage.py generateschema --format openapi-json > schema.json

# Schema validieren
# Prüfen, ob schema.json gültiges JSON ist
python -c "import json; json.load(open('schema.json'))"

# Swagger UI aufrufen (falls drf-yasg verwendet)
# Im Browser http://localhost:8000/swagger/ aufrufen

Phase 12: Diff-Review

# Diff-Statistiken anzeigen
git diff --stat

# Tatsächliche Änderungen anzeigen
git diff

# Geänderte Dateien anzeigen
git diff --name-only

# Auf häufige Probleme prüfen
git diff | grep -i "todo\|fixme\|hack\|xxx"
git diff | grep "print("  # Debug-Anweisungen
git diff | grep "DEBUG = True"  # Debug-Modus
git diff | grep "import pdb"  # Debugger

Checkliste:

  • Keine Debug-Anweisungen (print, pdb, breakpoint())
  • Keine TODO/FIXME-Kommentare in kritischem Code
  • Keine hartcodierten Geheimnisse oder Anmeldeinformationen
  • Datenbankmigrationen für Modelländerungen enthalten
  • Konfigurationsänderungen dokumentiert
  • Fehlerbehandlung für externe Aufrufe vorhanden
  • Transaktionsverwaltung wo nötig

Ausgabevorlage

DJANGO VERIFIKATIONSBERICHT
==========================

Phase 1: Umgebungscheck
  ✓ Python 3.11.5
  ✓ Virtuelle Umgebung aktiv
  ✓ Alle Umgebungsvariablen gesetzt

Phase 2: Codequalität
  ✓ mypy: Keine Typfehler
  ✗ ruff: 3 Probleme gefunden (automatisch korrigiert)
  ✓ black: Keine Formatierungsprobleme
  ✓ isort: Imports richtig sortiert
  ✓ manage.py check: Keine Probleme

Phase 3: Migrationen
  ✓ Keine ausstehenden Migrationen
  ✓ Keine Migrationskonflikte
  ✓ Alle Modelle haben Migrationen

Phase 4: Tests + Coverage
  Tests: 247 bestanden, 0 fehlgeschlagen, 5 übersprungen
  Coverage:
    Gesamt: 87 %
    users: 92 %
    products: 89 %
    orders: 85 %
    payments: 91 %

Phase 5: Sicherheitsscan
  ✗ pip-audit: 2 Schwachstellen gefunden (Korrektur erforderlich)
  ✓ safety check: Keine Probleme
  ✓ bandit: Keine Sicherheitsprobleme
  ✓ Keine Geheimnisse erkannt
  ✓ DEBUG = False

Phase 6: Django-Befehle
  ✓ collectstatic abgeschlossen
  ✓ Datenbankintegrität OK
  ✓ Cache-Backend erreichbar

Phase 7: Performance
  ✓ Keine N+1-Abfragen erkannt
  ✓ Datenbankindizes konfiguriert
  ✓ Abfrageanzahl akzeptabel

Phase 8: Statische Assets
  ✓ npm audit: Keine Schwachstellen
  ✓ Assets erfolgreich gebaut
  ✓ Statische Dateien gesammelt

Phase 9: Konfiguration
  ✓ DEBUG = False
  ✓ SECRET_KEY konfiguriert
  ✓ ALLOWED_HOSTS gesetzt
  ✓ HTTPS aktiviert
  ✓ HSTS aktiviert
  ✓ Datenbank konfiguriert

Phase 10: Logging
  ✓ Logging konfiguriert
  ✓ Logdateien beschreibbar

Phase 11: API-Dokumentation
  ✓ Schema generiert
  ✓ Swagger UI erreichbar

Phase 12: Diff-Review
  Geänderte Dateien: 12
  +450, -120 Zeilen
  ✓ Keine Debug-Anweisungen
  ✓ Keine hartcodierten Geheimnisse
  ✓ Migrationen enthalten

EMPFEHLUNG: WARNUNG: Beheben Sie die pip-audit-Schwachstellen vor dem Deployment

NÄCHSTE SCHRITTE:
1. Anfällige Abhängigkeiten aktualisieren
2. Sicherheitsscan wiederholen
3. Für abschließende Tests in Staging bereitstellen

Pre-Deployment-Checkliste

  • Alle Tests bestanden
  • Coverage ≥ 80 %
  • Keine Sicherheitslücken
  • Keine ausstehenden Migrationen
  • DEBUG = False in Produktionseinstellungen
  • SECRET_KEY richtig konfiguriert
  • ALLOWED_HOSTS korrekt gesetzt
  • Datenbank-Backups aktiviert
  • Statische Dateien gesammelt und ausgeliefert
  • Logging konfiguriert und funktionsfähig
  • Fehlerüberwachung (Sentry usw.) konfiguriert
  • CDN konfiguriert (falls zutreffend)
  • Redis-/Cache-Backend konfiguriert
  • Celery-Worker laufen (falls zutreffend)
  • HTTPS/SSL konfiguriert
  • Umgebungsvariablen dokumentiert

Continuous Integration

GitHub Actions-Beispiel

# .github/workflows/django-verification.yml
name: Django Verification

on: [push, pull_request]

jobs:
  verify:
    runs-on: ubuntu-latest
    services:
      postgres:
        image: postgres:14
        env:
          POSTGRES_PASSWORD: postgres
        options: >-
          --health-cmd pg_isready
          --health-interval 10s
          --health-timeout 5s
          --health-retries 5

    steps:
      - uses: actions/checkout@v3

      - name: Python einrichten
        uses: actions/setup-python@v4
        with:
          python-version: '3.11'

      - name: pip cachen
        uses: actions/cache@v3
        with:
          path: ~/.cache/pip
          key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}

      - name: Abhängigkeiten installieren
        run: |
          pip install -r requirements.txt
          pip install ruff black mypy pytest pytest-django pytest-cov bandit safety pip-audit

      - name: Codequalitätsprüfungen
        run: |
          ruff check .
          black . --check
          isort . --check-only
          mypy .

      - name: Sicherheitsscan
        run: |
          bandit -r . -f json -o bandit-report.json
          safety check --full-report
          pip-audit

      - name: Tests ausführen
        env:
          DATABASE_URL: postgres://postgres:postgres@localhost:5432/test
          DJANGO_SECRET_KEY: test-secret-key
        run: |
          pytest --cov=apps --cov-report=xml --cov-report=term-missing

      - name: Coverage hochladen
        uses: codecov/codecov-action@v3

Kurzreferenz

PrüfungBefehl
Umgebungpython --version
Typprüfungmypy .
Lintingruff check .
Formatierungblack . --check
Migrationenpython manage.py makemigrations --check
Testspytest --cov=apps
Sicherheitpip-audit && bandit -r .
Django-Checkpython manage.py check --deploy
Collectstaticpython manage.py collectstatic --noinput
Diff-Statistikengit diff --stat

Denken Sie daran: Automatisierte Verifikation erkennt häufige Probleme, ersetzt aber nicht die manuelle Code-Review und Tests in der Staging-Umgebung.

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

accessibility

Design, implement, and audit inclusive digital products using WCAG 2.2 Level AA. Use when building or auditing UI that must meet WCAG 2.2 Level AA, or when reviewing a change for keyboard, contrast, or screen-reader support.

affaan-m/claude-api

Anthropic Claude API patterns for Python and TypeScript. Covers Messages API, streaming, tool use, vision, extended thinking, batches, prompt caching, and Claude Agent SDK. Use when building applications with the Claude API or Anthropic SDKs.

affaan-m/everything-claude-code

End-to-end marketing campaign planning and execution. Covers audience research, positioning, campaign angle definition, landing page copy, email sequences, social posts, ad copy, short-form video scripts, and content calendars. Use as the orchestration layer for multi-channel product launches. Use when planning or executing a multi-channel product launch, or producing landing page, email, social, or ad copy.

affaan-m/everything-claude-code

Development conventions and patterns for everything-claude-code. JavaScript project with conventional commits.

affaan-m/everything-claude-code-conventions

Development conventions and patterns for everything-claude-code. JavaScript project with conventional commits.

affaan-m/frontend-design

Create distinctive, production-grade frontend interfaces with high design quality. Use when the user asks to build web components, pages, or applications and the visual direction matters as much as the code quality.

affaan-m/gget

gget CLI and Python workflow for quick genomic database queries, sequence lookup, BLAST-style searches, enrichment checks, and reproducible bioinformatics evidence logs.

affaan-m/literature-review

Systematic literature-review workflow for academic, biomedical, technical, and scientific topics, including search planning, source screening, synthesis, citation checks, and evidence logging.

affaan-m/motion-ui

Production-ready UI motion system for React/Next.js. Use when implementing animations, transitions, or motion patterns.

affaan-m/project-guidelines-example

Example project-specific skill template based on a real production application.

affaan-m/pubmed-database

Direct PubMed and NCBI E-utilities search workflows for biomedical literature, MeSH queries, PMID lookup, citation retrieval, and API-backed literature monitoring.

affaan-m/scholar-evaluation

Structured scholarly-work evaluation for papers, proposals, literature reviews, methods sections, evidence quality, citation support, and research-writing feedback.

affaan-m/uspto-database

USPTO patent and trademark data workflow for official record lookup, PatentSearch queries, TSDR checks, assignment data, and reproducible IP research logs.

agent-architecture-audit

Full-stack diagnostic for agent and LLM applications. Audits the 12-layer agent stack for wrapper regression, memory pollution, tool discipline failures, hidden repair loops, and rendering corruption. Produces severity-ranked findings with code-first fixes. Essential for developers building agent applications, autonomous loops, or any LLM-powered feature. Use when an agent or LLM feature misbehaves and the failing layer is unknown, or before shipping an agent stack.

agent-eval

Head-to-head comparison of coding agents (Claude Code, Aider, Codex, etc.) on custom tasks with pass rate, cost, time, and consistency metrics. Use when choosing between coding agents, or when a change to an agent setup needs measured pass rate, cost, and time rather than an impression.

agent-harness-construction

Design and optimize AI agent action spaces, tool definitions, and observation formatting for higher completion rates. Use when defining or revising an agent

agentic-engineering

Operate as an agentic engineer using eval-first execution, decomposition, and cost-aware model routing. Use when planning or executing engineering work that agents will carry out end to end.

agentic-os

Build persistent multi-agent operating systems on Claude Code. Covers kernel architecture, specialist agents, slash commands, file-based memory, scheduled automation, and state management without external databases. Use when building a persistent multi-agent system on Claude Code with its own memory, commands, and scheduling.

agent-introspection-debugging

Structured self-debugging workflow for AI agent failures using capture, diagnosis, contained recovery, and introspection reports. Use when an agent run fails and you need a reproducible diagnosis instead of a retry.

agent-payment-x402

Add x402 payment execution to AI agents with per-task budgets, spending controls, and non-custodial wallets. Supports Base through agentwallet-sdk and X Layer through OKX Payments / OKX Agent Payments Protocol. Use when an agent must pay for something itself and needs per-task budgets, spending controls, and a non-custodial wallet.

Verwandte Skills