django-verification
Verification loop for Django projects: migrations, linting, tests with coverage, security scans, and deployment readiness checks before release or PR.
About this skill
This skill provides a robust, multi-phase verification loop for Django projects, designed to be executed by an AI agent before a release or pull request. It systematically checks the project's health and readiness, starting with environment setup (Python version, virtual environment, crucial environment variables). It then proceeds to enforce code quality and formatting standards using tools like MyPy for type checking, Ruff for linting, Black for code formatting, and Isort for import sorting. The loop also includes Django-specific checks (e.g., missing migrations, static files), comprehensive unit/integration testing with coverage reporting, security scanning, and final deployment readiness assessments. This ensures high code quality, security, and operational reliability for Django applications, helping to catch issues early in the development lifecycle.
Best use case
To automatically ensure the quality, security, and deployability of a Django project before merging code, creating a release, or initiating a deployment. It's ideal for maintaining high standards in continuous integration/delivery pipelines managed by an AI, or for an agent performing a final check on a developer's work.
Verification loop for Django projects: migrations, linting, tests with coverage, security scans, and deployment readiness checks before release or PR.
A thoroughly verified Django project that meets predefined quality, security, and deployment readiness standards. The AI agent will report on the status of each verification phase, highlighting any issues found (e.g., linting errors, failed tests, security vulnerabilities, missing migrations) and potentially suggesting fixes or automatically applying them where possible. The ultimate outcome is a more reliable and secure Django application.
Practical example
Example input
An AI agent would typically be invoked with a command like `/run_django_verification` or `perform django-verification on the current project` within its environment, assuming the current working directory is the root of a Django project.
Example output
``` --- Django Verification Loop Initiated --- Phase 1: Environment Check Python version: Python 3.9.7 (OK) Virtual environment: Active (OK) DJANGO_SECRET_KEY set (OK) Phase 2: Code Quality and Formatting MyPy: No type errors found (OK) Ruff: 2 minor linting issues fixed automatically. Black: Code formatted to standard (OK) Isort: Imports sorted (OK) Phase 3: Django Specific Checks Missing migrations: No pending migrations (OK) CollectStatic: Dry run successful (OK) Phase 4: Testing and Coverage Pytest: All 125 tests passed (OK) Coverage: 92% code coverage (OK) Phase 5: Security Scans Bandit: No high-confidence security issues found (OK) Phase 6: Deployment Readiness Dependency check: All dependencies resolved (OK) Settings review: Production settings valid (OK) --- Verification Summary --- All critical checks passed. Minor linting issues were automatically resolved. Project is ready for further review/deployment. ```
When to use this skill
- Before submitting a Pull Request for a Django project to ensure code quality and stability.
- After making significant code changes to a Django application to validate functionality and security.
- As part of a pre-deployment checklist for Django projects to confirm readiness for production.
- To automate code quality, testing, and security checks in a CI/CD workflow managed by an AI agent.
When not to use this skill
- For projects not built with Django (as the checks are Django-specific).
- When only minor, non-code-impacting changes are made (e.g., documentation updates, minor refactoring that doesn't affect logic and doesn't warrant a full verification cycle).
- When quick local development iterations are preferred over a full verification cycle, though it can still be used selectively.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/django-verification/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How django-verification Compares
| Feature / Agent | django-verification | Standard Approach |
|---|---|---|
| Platform Support | Claude | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | medium | N/A |
Frequently Asked Questions
What does this skill do?
Verification loop for Django projects: migrations, linting, tests with coverage, security scans, and deployment readiness checks before release or PR.
Which AI agents support this skill?
This skill is designed for Claude.
How difficult is it to install?
The installation complexity is rated as medium. You can find the installation instructions above.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
Related Guides
AI Agents for Coding
Browse AI agent skills for coding, debugging, testing, refactoring, code review, and developer workflows across Claude, Cursor, and Codex.
Best AI Skills for Claude
Explore the best AI skills for Claude and Claude Code across coding, research, workflow automation, documentation, and agent operations.
ChatGPT vs Claude for Agent Skills
Compare ChatGPT and Claude for AI agent skills across coding, writing, research, and reusable workflow execution.
SKILL.md Source
# Django 検証ループ
PR前、大きな変更後、デプロイ前に実行して、Djangoアプリケーションの品質とセキュリティを確保します。
## フェーズ1: 環境チェック
```bash
# Pythonバージョンを確認
python --version # プロジェクト要件と一致すること
# 仮想環境をチェック
which python
pip list --outdated
# 環境変数を確認
python -c "import os; import environ; print('DJANGO_SECRET_KEY set' if os.environ.get('DJANGO_SECRET_KEY') else 'MISSING: DJANGO_SECRET_KEY')"
```
環境が誤って構成されている場合は、停止して修正します。
## フェーズ2: コード品質とフォーマット
```bash
# 型チェック
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: マイグレーション
```bash
# 未適用のマイグレーションをチェック
python manage.py showmigrations
# 欠落しているマイグレーションを作成
python manage.py makemigrations --check
# マイグレーション適用のドライラン
python manage.py migrate --plan
# マイグレーションを適用(テスト環境)
python manage.py migrate
# マイグレーションの競合をチェック
python manage.py makemigrations --merge # 競合がある場合のみ
```
レポート:
- 保留中のマイグレーション数
- マイグレーションの競合
- マイグレーションのないモデルの変更
## フェーズ4: テスト + カバレッジ
```bash
# 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: セキュリティスキャン
```bash
# 依存関係の脆弱性
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管理コマンド
```bash
# モデルの問題をチェック
python manage.py check
# 静的ファイルを収集
python manage.py collectstatic --noinput --clear
# スーパーユーザーを作成(テストに必要な場合)
echo "from apps.users.models import User; User.objects.create_superuser('admin@example.com', '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: パフォーマンスチェック
```bash
# 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: 静的アセット
```bash
# 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シェルで実行して設定を検証
python manage.py shell << EOF
from django.conf import settings
import os
# 重要なチェック
checks = {
'DEBUG is False': not settings.DEBUG,
'SECRET_KEY set': bool(settings.SECRET_KEY and len(settings.SECRET_KEY) > 30),
'ALLOWED_HOSTS set': len(settings.ALLOWED_HOSTS) > 0,
'HTTPS enabled': getattr(settings, 'SECURE_SSL_REDIRECT', False),
'HSTS enabled': getattr(settings, 'SECURE_HSTS_SECONDS', 0) > 0,
'Database configured': settings.DATABASES['default']['ENGINE'] != 'django.db.backends.sqlite3',
}
for check, result in checks.items():
status = '✓' if result else '✗'
print(f"{status} {check}")
EOF
```
## フェーズ10: ログ設定
```bash
# ログ出力をテスト
python manage.py shell << EOF
import logging
logger = logging.getLogger('django')
logger.warning('Test warning message')
logger.error('Test error message')
EOF
# ログファイルをチェック(設定されている場合)
tail -f /var/log/django/django.log
```
## フェーズ11: APIドキュメント(DRFの場合)
```bash
# スキーマを生成
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: 差分レビュー
```bash
# 差分統計を表示
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 完了
✓ データベース整合性OK
✓ キャッシュバックエンド到達可能
フェーズ7: パフォーマンス
✓ N+1クエリが検出されず
✓ データベースインデックスが構成済み
✓ クエリ数が許容範囲
フェーズ8: 静的アセット
✓ npm audit: 脆弱性なし
✓ アセットが正常にビルド
✓ 静的ファイルが収集済み
フェーズ9: 構成
✓ DEBUG = False
✓ SECRET_KEY 構成済み
✓ ALLOWED_HOSTS 設定済み
✓ HTTPS 有効
✓ HSTS 有効
✓ データベース構成済み
フェーズ10: ログ
✓ ログが構成済み
✓ ログファイルが書き込み可能
フェーズ11: APIドキュメント
✓ スキーマ生成済み
✓ Swagger UIアクセス可能
フェーズ12: 差分レビュー
変更されたファイル: 12
+450、-120行
✓ デバッグステートメントなし
✓ ハードコードされたシークレットなし
✓ マイグレーションが含まれる
推奨: WARNING: デプロイ前にpip-auditの脆弱性を修正してください
次のステップ:
1. 脆弱な依存関係を更新
2. セキュリティスキャンを再実行
3. 最終テストのためにステージングにデプロイ
```
## デプロイ前チェックリスト
- [ ] すべてのテストが成功
- [ ] カバレッジ ≥ 80%
- [ ] セキュリティ脆弱性なし
- [ ] 未適用のマイグレーションなし
- [ ] 本番設定でDEBUG = False
- [ ] SECRET_KEYが適切に構成
- [ ] ALLOWED_HOSTSが正しく設定
- [ ] データベースバックアップが有効
- [ ] 静的ファイルが収集され提供
- [ ] ログが構成され動作中
- [ ] エラー監視(Sentryなど)が構成済み
- [ ] CDNが構成済み(該当する場合)
- [ ] Redis/キャッシュバックエンドが構成済み
- [ ] Celeryワーカーが実行中(該当する場合)
- [ ] HTTPS/SSLが構成済み
- [ ] 環境変数が文書化済み
## 継続的インテグレーション
### GitHub Actionsの例
```yaml
# .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: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Cache pip
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
- name: Install dependencies
run: |
pip install -r requirements.txt
pip install ruff black mypy pytest pytest-django pytest-cov bandit safety pip-audit
- name: Code quality checks
run: |
ruff check .
black . --check
isort . --check-only
mypy .
- name: Security scan
run: |
bandit -r . -f json -o bandit-report.json
safety check --full-report
pip-audit
- name: Run tests
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: Upload coverage
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` |
| 差分統計 | `git diff --stat` |
**覚えておいてください**: 自動化された検証は一般的な問題を捕捉しますが、手動でのコードレビューとステージング環境でのテストに代わるものではありません。Related Skills
laravel-verification
Verification loop for Laravel projects: env checks, linting, static analysis, tests with coverage, security scans, and deployment readiness.
springboot-verification
Verification loop for Spring Boot projects: build, static analysis, tests with coverage, security scans, and diff review before release or PR.
django-tdd
Django testing strategies with pytest-django, TDD methodology, factory_boy, mocking, coverage, and testing Django REST Framework APIs.
django-security
Django security best practices, authentication, authorization, CSRF protection, SQL injection prevention, XSS prevention, and secure deployment configurations.
django-patterns
Django architecture patterns, REST API design with DRF, ORM best practices, caching, signals, middleware, and production-grade Django apps.
workspace-surface-audit
Audit the active repo, MCP servers, plugins, connectors, env surfaces, and harness setup, then recommend the highest-value ECC-native skills, hooks, agents, and operator workflows. Use when the user wants help setting up Claude Code or understanding what capabilities are actually available in their environment.
safety-guard
Use this skill to prevent destructive operations when working on production systems or running agents autonomously.
repo-scan
Cross-stack source code asset audit — classifies every file, detects embedded third-party libraries, and delivers actionable four-level verdicts per module with interactive HTML reports.
project-flow-ops
Operate execution flow across GitHub and Linear by triaging issues and pull requests, linking active work, and keeping GitHub public-facing while Linear remains the internal execution layer. Use when the user wants backlog control, PR triage, or GitHub-to-Linear coordination.
manim-video
Build reusable Manim explainers for technical concepts, graphs, system diagrams, and product walkthroughs, then hand off to the wider ECC video stack if needed. Use when the user wants a clean animated explainer rather than a generic talking-head script.
laravel-plugin-discovery
Discover and evaluate Laravel packages via LaraPlugins.io MCP. Use when the user wants to find plugins, check package health, or assess Laravel/PHP compatibility.
design-system
Use this skill to generate or audit design systems, check visual consistency, and review PRs that touch styling.