FastAPI Pre-Deploy Gatekeeper
by finance_kim
Most AI code reviews bury the one bug that takes production down under fifty style comments.
Free
FastAPI Pre-Deploy Gatekeeper
Example session with this skill installed
Is my FastAPI orders service safe to deploy? Check this branch against main.
- Read your context and instructions
- Compiled the fastapi pre-deploy gatekeeper
Pre-deploy gate: BLOCK
Why: GET /api/v1/orders returns 500 with AsyncSession (lazy order.items), and /charge blocks the event loop.
| # | Sev | Rule | Location | Finding | Proof |
|---|---|---|---|---|---|
| 1 | HIGH | NPLUS001 | app/routers/orders.py:21 | lazy order.items per order with AsyncSession | test fails: MissingGreenlet |
| 2 | HIGH | ASYNC002 | app/routers/payments.py:18 | requests.post inside async def charge | test fails: loop blocked 0.45 s |
| 3 | HIGH | ENV003 | app/config.py:8 | secret_key defaults to "change-me" | test fails: no ValidationError |
| 4 | HIGH | API002 | app/schemas.py | total_cents removed from 3 order responses | snapshot test fails |
| 5 | MEDIUM | ENV004 | docker-compose.yml | STRIPE_API_KEY never set | test fails |
Fix 2 (minimal):
- resp = requests.post(url, json=payload, timeout=10)
- resp = await asyncio.to_thread(requests.post, url, json=payload, timeout=10)
Dismissed: ACCESS_TOKEN_EXPIRE_MINUTES, REDIS_URL (safe defaults).
Connects securely to your tools. The creator never sees your data.
About this skill
Most AI code reviews bury the one bug that takes production down under fifty style comments. This skill does the opposite: it checks only four things that break FastAPI services or their clients, confirms every candidate by reading the code, proves it with a failing pytest test, proposes the smallest fix, and ends with a clear verdict - PASS, PASS WITH WARNINGS or BLOCK.
What it catches
- Blocking calls inside
async def-time.sleep,requests, synchttpx.Client, psycopg2/sqlite3/pymysql, a sync SQLAlchemySessionin an async route (the most common FastAPI bug),open(),subprocess.run, bcrypt/passlib password hashing, boto3, smtplib - directly or through a sync helper function. Syncdefendpoints, awaited calls andasyncio.to_thread/run_in_threadpoolare correctly left alone. - ORM N+1 queries - lazy relationships read in loops or comprehensions, queries executed per iteration, and response models that serialize lazy relationships. SQLAlchemy 1.4/2.0 (sync and AsyncSession, where a lazy load is a 500), SQLModel, Django ORM and Tortoise. Knows
selectinload,joinedload,select_related,prefetch_relatedandlazy="selectin". - Environment variables - read in code (os.environ, getenv, pydantic BaseSettings with env_prefix and aliases, Starlette Config, decouple) but missing from
.env.example, docker-compose, Kubernetes manifests or docs;int(os.getenv("X"))crashes; secrets with hard-coded defaults; required variables the compose file never sets. Real.envfiles are never read. - API backward compatibility - removed or renamed routes, removed response fields, new required request fields or query params, type changes, removed enum values and changed status codes, compared against your base branch straight from git (the app is never imported or run) or between two exported openapi.json files. Additive changes are not reported.
How it works
- Detects your layout: app entry, router prefixes, ORM, settings style, env templates, manifests, test fixtures.
- Runs a static scanner (one Python file, standard library only) that lists candidates with rule id, severity, confidence, file:line, evidence and fix.
- The agent reads each candidate and confirms or dismisses it with a reason - the scanner suggests, the agent decides.
- Writes one pytest test per confirmed finding from ready templates: an event-loop lag probe, a SQL statement counter (2 rows vs 8 rows), env var presence tests, and an OpenAPI snapshot compatibility test.
- Proposes a minimal diff per finding and, if you ask, applies it and re-runs the tests.
- Reports in a fixed format: verdict, findings table with proof, dismissed candidates, pre-existing issues, and what was not verified.
Why trust it
- 68 unit tests, including false-positive guards (sync endpoints, awaited clients, thread offloading, eager loading, documented variables, additive API changes) and git-based API diffs.
- The test templates were run against the bundled sample service: they fail before each fix and pass after it.
- Never crashes on syntax errors, non-UTF-8 files or large repositories; skips virtualenvs, node_modules and migrations.
Requirements
Python 3.9+ and git. Nothing to install, no API keys, no network access. Proof tests use your project's own pytest setup.
Static analysis only. Blocking calls hidden behind dynamic dispatch, class methods or more than one helper level, and third-party SDKs outside the built-in list, can be missed. N+1 through templates, properties or validators outside the route is not traced. Routes registered with add_api_route, mounted sub-apps and generic response models are compared only through the exported openapi.json diff. Custom env wrappers and nested settings models are not followed. Every finding is a candidate the agent confirms before reporting.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before buying a skill.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Free to use
No account required to browse
Trust & safety
Security scan
Security scan passed 9 days ago
- Free with an Agensi account
- Software
Python 3.9+
Git
Permissions
File Scopes
Runs a bundled standard-library Python script and git (read-only: rev-parse, ls-tree, cat-file). No network access.
What's inside
Frequently Asked Questions
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse All Claude Skills.