为 Django 项目执行发布前校验流程,涵盖迁移、测试、安全与部署检查。
复制安装指令,让 AI 自动完成配置 · 推荐新手
请帮我安装 askskill 上的 "django-verification" 技能: 1. 下载 https://raw.githubusercontent.com/affaan-m/ECC/main/skills/django-verification/SKILL.md 2. 保存为 ~/.claude/skills/django-verification/SKILL.md 3. 装好后重载技能,告诉我可以用了
请为我的 Django 项目执行发布前校验流程:检查迁移是否完整,运行 lint,执行测试并生成覆盖率报告,扫描常见安全问题,并给出部署就绪性结论和修复建议。
返回一份发布前检查报告,包含各项结果、覆盖率、安全风险、是否可部署及修复建议。
针对这次 Django 代码变更做一轮 PR 前验证:确认模型变更对应迁移文件,检查代码风格,运行相关测试,标出潜在安全隐患,并总结是否适合提交 PR。
输出一份面向 PR 的校验摘要,指出阻塞问题、通过项以及建议补充的修改。
请为 Django 项目设计一套自动化校验流程,要求包含迁移检查、lint、测试覆盖率、安全扫描和部署前检查,并说明每一步失败时应如何处理。
得到一套可落地的 Django CI 校验方案,包含步骤顺序、检查项与失败处理建议。
Run before PRs, after major changes, and pre-deploy to ensure Django application quality and security.
# Verify Python version
python --version # Should match project requirements
# Check virtual environment
which python
pip list --outdated
# Verify environment variables
python -c "import os; import environ; print('DJANGO_SECRET_KEY set' if os.environ.get('DJANGO_SECRET_KEY') else 'MISSING: DJANGO_SECRET_KEY')"
If environment is misconfigured, stop and fix.
# Type checking
mypy . --config-file pyproject.toml
# Linting with ruff
ruff check . --fix
# Formatting with black
black . --check
black . # Auto-fix
# Import sorting
isort . --check-only
isort . # Auto-fix
# Django-specific checks
python manage.py check --deploy
Common issues:
# Check for unapplied migrations
python manage.py showmigrations
# Create missing migrations
python manage.py makemigrations --check
# Dry-run migration application
python manage.py migrate --plan
# Apply migrations (test environment)
python manage.py migrate
# Check for migration conflicts
python manage.py makemigrations --merge # Only if conflicts exist
Report:
# Run all tests with pytest
pytest --cov=apps --cov-report=html --cov-report=term-missing --reuse-db
# Run specific app tests
pytest apps/users/tests/
# Run with markers
pytest -m "not slow" # Skip slow tests
pytest -m integration # Only integration tests
# Coverage report
open htmlcov/index.html
Report:
Coverage targets:
| Component | Target |
|---|---|
| Models | 90%+ |
| Serializers | 85%+ |
| Views | 80%+ |
| Services | 90%+ |
| Overall | 80%+ |
# Dependency vulnerabilities
pip-audit
safety check --full-report
# Django security checks
python manage.py check --deploy
# Bandit security linter
bandit -r . -f json -o bandit-report.json
# Secret scanning (if gitleaks is installed)
gitleaks detect --source . --verbose
# Environment variable check
python -c "from django.core.exceptions import ImproperlyConfigured; from django.conf import settings; settings.DEBUG"
Report:
# Check for model issues
python manage.py check
# Collect static files
python manage.py collectstatic --noinput --clear
# Create superuser (if needed for tests)
echo "from apps.users.models import User; User.objects.create_superuser('[email protected]', 'admin')" | python manage.py shell
# Database integrity
python manage.py check --database default
# Cache verification (if using Redis)
python -c "from django.core.cache import cache; cache.set('test', 'value', 10); print(cache.get('test'))"
# Django Debug Toolbar output (check for N+1 queries)
# Run in dev mode with DEBUG=True and access a page
# Look for duplicate queries in SQL panel
# Query count analysis
django-admin debugsqlshell # If django-debug-sqlshell installed
# Check for missing indexes
python manage.py shell << EOF
…
通过双评审智能体对结果进行对抗式校验,提升输出发布前的可靠性
为 Spring Boot 项目执行构建、测试、扫描与变更复核的发布前验证流程