- Home
- Skills
- Agents & Orchestration
- Python Web Rules
Python Web Rules
Production-grade rules for Django and FastAPI to fix N+1 queries, async blocking, and security leaks.
$5
Works with the AI Agents you already use
Python Web Rules
Example session with this skill installed
My FastAPI endpoint is slow. It takes a user ID, fetches their profile, then loops through their 50 most recent orders to fetch shipping status from another table, and returns the whole dict.
- Read your context and instructions
- Compiled the python web rules
Surface
FastAPI endpoint fetching User, Order, and Shipping status.
Findings
- main.py — ORM rule 1. Accessing shipping status in a loop creates an N+1 query pattern.
- main.py — Pydantic rule 4. Returning a raw dict instead of a response model risks leaking internal DB fields.
Patch
@app.get("/orders", response_model=List[OrderResponse])
async def get_orders(user_id: int, db: Session = Depends(get_db)):
return (
db.query(Order)
.filter(Order.user_id == user_id)
.options(joinedload(Order.shipping))
.limit(50)
.all()
)
Checks to run
- Enable SQL logging and confirm exactly 1 query is emitted.
- Verify OrderResponse excludes internal metadata.
Connects securely to your tools. The creator never sees your data.
About this skill
The problem
Python web code often looks correct in development but fails under load due to N plus one queries, blocked event loops, or leaky serialization. LLMs usually write code that works in isolation but ignores production-critical details like transaction boundaries and connection pooling.
What it does
- Identifies N plus one query patterns and converts them to
select_relatedorprefetch_relatedjoins. - Detects synchronous calls like
requestsor ORM operations insideasynchandlers that block the event loop. - Enforces Pydantic v2 strictness by separating input/output models and forbidding extra fields to prevent data leaks.
- Audit settings for security vulnerabilities including missing CSRF protection, exposed secrets, and improper HSTS headers.
- Refactors database writes to use atomic boundaries and prevents external API calls from holding row locks.
Frameworks & tools
Django, FastAPI, Pydantic v2, SQLAlchemy, and standard Python async libraries.
Why this beats prompting it yourself
Generic prompts often miss the nuances of database connection lifetimes and background task safety. This skill uses a specific trigger matrix to catch silent failures, like summing columns in Python memory instead of the database, that typical AI suggestions overlook.
Use cases
- Refactoring slow Django endpoints that perform hundreds of database queries per request.
- Converting synchronous FastAPI endpoints to safe asynchronous implementations without blocking.
- Hardening API security by implementing strict Pydantic validation and secure header configurations.
- Ensuring database integrity by correctly placing transaction boundaries around multi-row writes.
Known limitations
Does not execute migrations, start servers, or access live databases. All verification steps are provided as commands for the user to run manually.
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for Agents & Orchestration.
Does not run migrations, connect to live databases, or execute tests. Relies on the user to run provided verification commands.
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
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed 3 months ago
- Software
Python