Communitygithub.com

django-verification

Django 프로젝트의 마이그레이션, 린팅, 커버리지 테스트, 보안 스캔, 배포 준비 확인을 위한 검증 파이프라인입니다. PR 전이나 배포 전에 실행하세요.

django-verification란 무엇인가요?

이 스킬은 Django 프로젝트의 품질과 보안을 보장하기 위한 포괄적인 검증 루프를 제공합니다. PR 요청 전, 주요 변경 후, 배포 전에 실행하도록 설계되었으며, 환경 확인부터 코드 품질, 마이그레이션, 테스트, 보안 스캔, 성능 점검, 정적 자산, 설정 검토, 로깅, API 문서, diff 리뷰까지 12단계로 구성되어 있습니다. 각 단계는 구체적인 CLI 명령어와 함께 상세한 설명을 제공하며, 실행 후 종합 보고서를 생성합니다. GitHub Actions를 포함한 CI/CD 파이프라인과 쉽게 통합할 수 있고, 배포 전 체크리스트와 빠른 참조 표를 제공하여 실무에서 바로 활용할 수 있습니다. Claude Code, Cursor, Codex와 같은 AI 에이전트와 함께 사용하면 Django 프로젝트의 일관된 품질 관리를 자동화할 수 있습니다.

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

즐겨 사용하는 AI에게 물어보기

이 에이전트 스킬이 미리 로드된 새 채팅을 엽니다.

문서

Django 검증 루프

PR 전, 주요 변경 후, 배포 전에 실행하여 Django 애플리케이션의 품질과 보안을 보장하세요.

실행 시점

  • Django 프로젝트의 풀 리퀘스트를 열기 전
  • 주요 모델 변경, 마이그레이션 업데이트, 의존성 업그레이드 후
  • 스테이징 또는 프로덕션 배포 전 검증
  • 전체 환경 → 린트 → 테스트 → 보안 → 배포 준비 파이프라인 실행
  • 마이그레이션 안전성 및 테스트 커버리지 검증

1단계: 환경 확인

# Python 버전 확인
python --version  # 프로젝트 요구 사항과 일치해야 함

# 가상 환경 확인
which python
pip list --outdated

# 환경 변수 확인
python -c "import os; import environ; print('DJANGO_SECRET_KEY 설정됨' if os.environ.get('DJANGO_SECRET_KEY') else '누락: DJANGO_SECRET_KEY')"

환경이 잘못 구성된 경우 중단하고 수정하세요.

2단계: 코드 품질 및 포맷팅

# 타입 검사
mypy . --config-file pyproject.toml

# ruff로 린팅
ruff check . --fix

# black으로 포맷팅
black . --check
black .  # 자동 수정

# 임포트 정렬
isort . --check-only
isort .  # 자동 수정

# Django 전용 검사
python manage.py check --deploy

일반적인 문제:

  • 공개 함수에 타입 힌트 누락
  • PEP 8 포맷팅 위반
  • 정렬되지 않은 임포트
  • 프로덕션 설정에 남아 있는 디버그 설정

3단계: 마이그레이션

# 적용되지 않은 마이그레이션 확인
python manage.py showmigrations

# 누락된 마이그레이션 생성
python manage.py makemigrations --check

# 마이그레이션 적용 시뮬레이션
python manage.py migrate --plan

# 마이그레이션 적용 (테스트 환경)
python manage.py migrate

# 마이그레이션 충돌 확인
python manage.py makemigrations --merge  # 충돌이 있는 경우에만

보고:

  • 대기 중인 마이그레이션 수
  • 마이그레이션 충돌 여부
  • 마이그레이션이 없는 모델 변경

4단계: 테스트 + 커버리지

# pytest로 전체 테스트 실행
pytest --cov=apps --cov-report=html --cov-report=term-missing --reuse-db

# 특정 앱 테스트 실행
pytest apps/users/tests/

# 마커로 실행
pytest -m "not slow"  # 느린 테스트 건너뛰기
pytest -m integration  # 통합 테스트만 실행

# 커버리지 리포트
open htmlcov/index.html

보고:

  • 전체 테스트: X개 통과, Y개 실패, Z개 건너뜀
  • 전체 커버리지: XX%
  • 앱별 커버리지 분포

커버리지 목표:

구성 요소목표
모델90%+
시리얼라이저85%+
뷰80%+
서비스90%+
전체80%+

5단계: 보안 스캔

# 의존성 취약점
pip-audit
safety check --full-report

# Django 보안 검사
python manage.py check --deploy

# Bandit 보안 린터
bandit -r . -f json -o bandit-report.json

# 시크릿 스캔 (gitleaks가 설치된 경우)
gitleaks detect --source . --verbose

# 환경 변수 확인
python -c "from django.core.exceptions import ImproperlyConfigured; from django.conf import settings; settings.DEBUG"

보고:

  • 취약한 의존성 발견
  • 보안 설정 문제
  • 하드코딩된 시크릿 감지
  • DEBUG 모드 상태 (프로덕션에서는 False여야 함)

6단계: Django 관리 명령어

# 모델 문제 확인
python manage.py check

# 정적 파일 수집
python manage.py collectstatic --noinput --clear

# 슈퍼유저 생성 (테스트에 필요한 경우)
echo "from apps.users.models import User; User.objects.create_superuser('[email protected]', 'admin')" | python manage.py shell

# 데이터베이스 무결성
python manage.py check --database default

# 캐시 확인 (Redis 사용 시)
python -c "from django.core.cache import cache; cache.set('test', 'value', 10); print(cache.get('test'))"

7단계: 성능 점검

# Django Debug Toolbar 출력 (N+1 쿼리 확인)
# DEBUG=True로 개발 모드에서 페이지 접근
# SQL 패널에서 중복 쿼리 확인

# 쿼리 수 분석
django-admin debugsqlshell  # django-debug-sqlshell이 설치된 경우

# 누락된 인덱스 확인
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

보고:

  • 페이지당 쿼리 수 (일반 페이지는 50 미만이어야 함)
  • 누락된 데이터베이스 인덱스
  • 감지된 중복 쿼리

8단계: 정적 자산

# npm 의존성 확인 (npm 사용 시)
npm audit
npm audit fix

# 정적 파일 빌드 (webpack/vite 사용 시)
npm run build

# 정적 파일 확인
ls -la staticfiles/
python manage.py findstatic css/style.css

9단계: 설정 검토

# Python 셸에서 설정 확인
python manage.py shell << EOF
from django.conf import settings
import os

# 중요 점검
checks = {
    'DEBUG가 False인가': not settings.DEBUG,
    'SECRET_KEY가 설정되었는가': bool(settings.SECRET_KEY and len(settings.SECRET_KEY) > 30),
    'ALLOWED_HOSTS가 설정되었는가': len(settings.ALLOWED_HOSTS) > 0,
    'HTTPS가 활성화되었는가': getattr(settings, 'SECURE_SSL_REDIRECT', False),
    'HSTS가 활성화되었는가': getattr(settings, 'SECURE_HSTS_SECONDS', 0) > 0,
    '데이터베이스가 구성되었는가': settings.DATABASES['default']['ENGINE'] != 'django.db.backends.sqlite3',
}

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

10단계: 로깅 설정

# 로깅 출력 테스트
python manage.py shell << EOF
import logging
logger = logging.getLogger('django')
logger.warning('테스트 경고 메시지')
logger.error('테스트 오류 메시지')
EOF

# 로그 파일 확인 (설정된 경우)
tail -f /var/log/django/django.log

11단계: API 문서화 (DRF 사용 시)

# 스키마 생성
python manage.py generateschema --format openapi-json > schema.json

# 스키마 검증
# schema.json이 유효한 JSON인지 확인
python -c "import json; json.load(open('schema.json'))"

# Swagger UI 접근 (drf-yasg 사용 시)
# 브라우저에서 http://localhost:8000/swagger/ 방문

12단계: Diff 리뷰

# Diff 통계 보기
git diff --stat

# 실제 변경 사항 보기
git diff

# 변경된 파일 보기
git diff --name-only

# 일반적인 문제 확인
git diff | grep -i "todo\|fixme\|hack\|xxx"
git diff | grep "print("  # 디버그 문장
git diff | grep "DEBUG = True"  # 디버그 모드
git diff | grep "import pdb"  # 디버거

체크리스트:

  • 디버깅 문장 없음 (print, pdb, breakpoint())
  • 중요한 코드에 TODO/FIXME 주석 없음
  • 하드코딩된 시크릿 또는 자격 증명 없음
  • 모델 변경에 대한 데이터베이스 마이그레이션 포함
  • 설정 변경 사항 문서화
  • 외부 호출에 대한 오류 처리 존재
  • 필요한 경우 트랜잭션 관리

출력 템플릿

DJANGO 검증 보고서
==================

1단계: 환경 확인
  ✓ Python 3.11.5
  ✓ 가상 환경 활성화
  ✓ 모든 환경 변수 설정됨

2단계: 코드 품질
  ✓ mypy: 타입 오류 없음
  ✗ ruff: 3개 문제 발견 (자동 수정됨)
  ✓ black: 포맷팅 문제 없음
  ✓ isort: 임포트 정상 정렬
  ✓ manage.py check: 문제 없음

3단계: 마이그레이션
  ✓ 적용되지 않은 마이그레이션 없음
  ✓ 마이그레이션 충돌 없음
  ✓ 모든 모델에 마이그레이션 있음

4단계: 테스트 + 커버리지
  테스트: 247개 통과, 0개 실패, 5개 건너뜀
  커버리지:
    전체: 87%
    users: 92%
    products: 89%
    orders: 85%
    payments: 91%

5단계: 보안 스캔
  ✗ pip-audit: 2개 취약점 발견 (수정 필요)
  ✓ safety check: 문제 없음
  ✓ bandit: 보안 문제 없음
  ✓ 시크릿 감지되지 않음
  ✓ DEBUG = False

6단계: Django 명령어
  ✓ collectstatic 완료
  ✓ 데이터베이스 무결성 확인
  ✓ 캐시 백엔드 연결 가능

7단계: 성능
  ✓ N+1 쿼리 감지되지 않음
  ✓ 데이터베이스 인덱스 구성됨
  ✓ 쿼리 수 허용 가능

8단계: 정적 자산
  ✓ npm audit: 취약점 없음
  ✓ 자산 빌드 성공
  ✓ 정적 파일 수집됨

9단계: 설정
  ✓ DEBUG = False
  ✓ SECRET_KEY 설정됨
  ✓ ALLOWED_HOSTS 설정됨
  ✓ HTTPS 활성화됨
  ✓ HSTS 활성화됨
  ✓ 데이터베이스 구성됨

10단계: 로깅
  ✓ 로깅 구성됨
  ✓ 로그 파일 쓰기 가능

11단계: API 문서
  ✓ 스키마 생성됨
  ✓ Swagger UI 접근 가능

12단계: Diff 리뷰
  변경된 파일: 12개
  +450, -120 라인
  ✓ 디버그 문장 없음
  ✓ 하드코딩된 시크릿 없음
  ✓ 마이그레이션 포함됨

권장 사항: 경고: 배포 전에 pip-audit 취약점을 수정하세요

다음 단계:
1. 취약한 의존성 업데이트
2. 보안 스캔 재실행
3. 최종 테스트를 위해 스테이징에 배포

배포 전 체크리스트

  • 모든 테스트 통과
  • 커버리지 ≥ 80%
  • 보안 취약점 없음
  • 적용되지 않은 마이그레이션 없음
  • 프로덕션 설정에서 DEBUG = False
  • SECRET_KEY 올바르게 설정됨
  • ALLOWED_HOSTS 올바르게 설정됨
  • 데이터베이스 백업 활성화
  • 정적 파일 수집 및 제공됨
  • 로깅 설정 및 작동 중
  • 오류 모니터링 (Sentry 등) 구성됨
  • CDN 구성됨 (해당하는 경우)
  • Redis/캐시 백엔드 구성됨
  • Celery 워커 실행 중 (해당하는 경우)
  • HTTPS/SSL 구성됨
  • 환경 변수 문서화됨

지속적 통합

GitHub Actions 예제

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

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 설정
        uses: actions/setup-python@v4
        with:
          python-version: '3.11'

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

      - name: 의존성 설치
        run: |
          pip install -r requirements.txt
          pip install ruff black mypy pytest pytest-django pytest-cov bandit safety pip-audit

      - name: 코드 품질 검사
        run: |
          ruff check .
          black . --check
          isort . --check-only
          mypy .

      - name: 보안 스캔
        run: |
          bandit -r . -f json -o bandit-report.json
          safety check --full-report
          pip-audit

      - name: 테스트 실행
        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: 커버리지 업로드
        uses: codecov/codecov-action@v3

빠른 참조

점검 항목명령어
환경python --version
타입 검사mypy .
린팅ruff check .
포맷팅black . --check
마이그레이션python manage.py makemigrations --check
테스트pytest --cov=apps
보안pip-audit && bandit -r .
Django 검사python manage.py check --deploy
정적 파일 수집python manage.py collectstatic --noinput
Diff 통계git diff --stat

명심하세요: 자동화된 검증은 일반적인 문제를 잡아내지만, 수동 코드 리뷰와 스테이징 환경에서의 테스트를 대체하지는 않습니다.

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.

관련 스킬