FP

    FastAPI Pre-Deploy Gatekeeper

    by finance_kim

    1

    Most AI code reviews bury the one bug that takes production down under fifty style comments.

    Free

    Security scanned

    Works with the AI Agents you already use

    FP

    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.

    #SevRuleLocationFindingProof
    1HIGHNPLUS001app/routers/orders.py:21lazy order.items per order with AsyncSessiontest fails: MissingGreenlet
    2HIGHASYNC002app/routers/payments.py:18requests.post inside async def chargetest fails: loop blocked 0.45 s
    3HIGHENV003app/config.py:8secret_key defaults to "change-me"test fails: no ValidationError
    4HIGHAPI002app/schemas.pytotal_cents removed from 3 order responsessnapshot test fails
    5MEDIUMENV004docker-compose.ymlSTRIPE_API_KEY never settest 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).

    docker-compose.yml

    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, sync httpx.Client, psycopg2/sqlite3/pymysql, a sync SQLAlchemy Session in an async route (the most common FastAPI bug), open(), subprocess.run, bcrypt/passlib password hashing, boto3, smtplib - directly or through a sync helper function. Sync def endpoints, awaited calls and asyncio.to_thread / run_in_threadpool are 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_related and lazy="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 .env files 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

    1. Detects your layout: app entry, router prefixes, ORM, settings style, env templates, manifests, test fixtures.
    2. Runs a static scanner (one Python file, standard library only) that lists candidates with rule id, severity, confidence, file:line, evidence and fix.
    3. The agent reads each candidate and confirms or dismisses it with a reason - the scanner suggests, the agent decides.
    4. 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.
    5. Proposes a minimal diff per finding and, if you ask, applies it and re-runs the tests.
    6. 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. 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. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 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

    Terminal / Shell
    Read Files
    Write Files

    File Scopes

    Reads
    the
    project's
    source
    env
    templates
    manifests
    and
    docs
    (never
    real
    .env
    files)
    Writes
    new
    pytest
    files
    under
    tests
    folder;
    edits
    application
    code
    only
    when
    you
    ask
    for
    fixes

    Runs a bundled standard-library Python script and git (read-only: rev-parse, ls-tree, cat-file). No network access.

    Listed9 days ago

    What's inside

    Creator

    finance_kim

    finance_kim

    11 skills on Agensi

    Frequently Asked Questions

    No. The scanner parses source code with Python's ast module and reads the base branch with git; it never imports, installs or executes your project and makes no network calls. Only the proof tests run, inside your own test setup, when you allow it.

    It ignores style, naming and refactoring suggestions and reports only four high-impact problem classes. Every finding is confirmed by reading the code and backed by a failing test, so the report stays short and actionable.

    No. FastAPI runs sync def endpoints and dependencies in a threadpool, so the skill only looks inside async def code. Awaited calls and work passed to asyncio.to_thread, run_in_threadpool or run_in_executor are also not flagged.

    SQLAlchemy 1.4 and 2.0 (sync and async), SQLModel, Django ORM and Tortoise ORM. Eager loading via selectinload, joinedload, select_related, prefetch_related or lazy=selectin on the relationship suppresses the finding.

    It extracts routes, router prefixes, pydantic models, enums and status codes from the source at your base ref (read with git) and from the working tree, then compares them. If your routes are built dynamically, export openapi.json for both versions and use the OpenAPI diff instead.

    Yes. Run the scanner with --fail-on high to get a non-zero exit code when a high-severity candidate is found, and --format json for machine-readable output. Reviewed false positives can be silenced with a gatekeeper ignore comment on the line.

    No. Real .env files are never opened; only templates such as .env.example, manifests and docs are searched for variable names, and reports refer to variables by name only.

    Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse All Claude Skills.

    Free