| name | fastapi-verification |
| description | Verification loop for FastAPI projects: type checking, linting, tests with coverage, security scans, and API schema validation before release or PR. |
FastAPI Verification Loop
Run before PRs, after major changes, and pre-deploy to ensure FastAPI application quality and security.
When to Activate
- Before opening a pull request for a FastAPI project
- After adding or modifying endpoints, Pydantic models, or dependencies
- Pre-deployment verification for staging or production
- Running full environment → lint → test → security → schema pipeline
- Validating Pydantic model correctness and test coverage
Phase 1: Environment Check
python --version
which python
pip list --outdated
python -c "
import os
required = ['DATABASE_URL', 'SECRET_KEY']
for var in required:
status = 'SET' if os.environ.get(var) else 'MISSING'
print(f'{status}: {var}')
"
If environment is misconfigured, stop and fix before proceeding.
Phase 2: Type Checking & Linting
mypy app/ --strict 2>&1 | tail -20
ruff check . --fix
ruff format . --check
python -c "from pydantic import BaseModel; print('Pydantic OK')"
Common issues:
- Missing type annotations on route functions
Any types in Pydantic models
- Untyped
Depends() parameters
Phase 3: Tests + Coverage
pytest tests/ -v --cov=app --cov-report=term-missing --cov-report=html
pytest tests/unit/ -v
pytest tests/integration/ -v
pytest --cov=app --cov-fail-under=80
Coverage targets:
| Component | Target |
|---|
| Routes | 85%+ |
| Services | 90%+ |
| Domain Models | 95%+ |
| Overall | 80%+ |
Phase 4: Security Scan
pip-audit
safety check --full-report
bandit -r app/ -ll -f text 2>&1 | head -40
gitleaks detect --source . --verbose 2>/dev/null || echo "gitleaks not installed"
grep -rn "secret\|password\|api_key\|token" app/ --include="*.py" | grep -v "test\|example\|env\|settings" | grep -v "\.pyc"
Phase 5: API Schema Validation
uvicorn app.main:app --host 0.0.0.0 --port 8000 &
sleep 2
curl -s http://localhost:8000/openapi.json | python -m json.tool > /dev/null && echo "Schema: valid JSON"
curl -s http://localhost:8000/openapi.json > openapi-snapshot.json
kill %1
Schema checklist:
- All endpoints have summary and description
- All response models are typed (no
Any)
- Error responses use RFC 7807 Problem Details format
- Authentication is documented (Bearer, OAuth2, etc.)
Phase 6: Performance Spot Check
python -c "
import asyncio
from app.database import get_session
# Run suspicious endpoints and check query count
print('Run dev server with SQL echo=True to detect N+1')
"
uvicorn app.main:app --host 0.0.0.0 --port 8000 &
sleep 2
curl -o /dev/null -s -w "Response time: %{time_total}s\n" http://localhost:8000/health
kill %1
Phase 7: Diff Review
git diff --stat
git diff | grep -E "todo|fixme|hack|xxx" -i
git diff | grep "print("
git diff | grep "raise Exception"
Checklist:
- No
print() debug statements — use logging or structlog
- No bare
except: clauses
- No hardcoded secrets or credentials
- Pydantic response models cover all fields
- Background tasks have error handling
Output Template
FASTAPI VERIFICATION REPORT
============================
Phase 1: Environment
✓ Python 3.13.x
✓ Virtual environment active
✓ DATABASE_URL set
✗ REDIS_URL missing (optional — feature disabled)
Phase 2: Type Checking & Linting
✓ mypy: No type errors
✓ ruff: No issues
✓ ruff format: Formatted correctly
Phase 3: Tests + Coverage
Tests: 183 passed, 0 failed, 2 skipped
Coverage:
Overall: 86%
routes: 88%
services: 91%
domain: 96%
Phase 4: Security
✓ pip-audit: No vulnerabilities
✓ bandit: No high-severity issues
✓ No secrets detected
Phase 5: API Schema
✓ Schema valid JSON
✓ 23 endpoints documented
✓ All responses typed
Phase 6: Performance
Response time /health: 0.008s
Phase 7: Diff Review
Files changed: 7
+210, -45 lines
✓ No debug statements
✓ No hardcoded secrets
RECOMMENDATION: ✓ Ready to merge
Pre-Deployment Checklist
Related Skills
fastapi-patterns — Architecture patterns, Pydantic models, dependency injection
python-testing — pytest fixtures, HTTPX async client, factory patterns
django-verification — Similar loop for Django projects
verification-loop — General-purpose verification for any project