python-backend

python-backend is a skill for Claude Code, Codex from WrongStack/WrongStack. It costs 93 tokens per session (2,269 once invoked), scanned A, original, MIT.

A guide for building and upgrading Python services, including web APIs and background jobs, with clear environments and resource handling.

In plain words
What is it for?
It is for FastAPI and Django services, Python APIs, validation, async boundaries, database sessions, cleanup, packaging, and job processing.
Why use it?
It helps prevent invalid data, blocking work in asynchronous requests, leaked resources, unclear packaging, and unsafe configuration or authorization.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit It is for FastAPI and Django services, Python APIs, validation, async boundaries, database sessions, cleanup, packaging, and job processing.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/wrongstack/wrongstack/python-backend
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add WrongStack/WrongStack --skill python-backend
Clone the repo
git clone --depth 1 https://github.com/WrongStack/WrongStack

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for python-backend

README.md
[![agentmods](https://agentmods.dev/badge/skills/wrongstack/wrongstack/python-backend/github.svg)](https://agentmods.dev/skills/wrongstack/wrongstack/python-backend)
Your own site
<a href="https://agentmods.dev/skills/wrongstack/wrongstack/python-backend"><img src="https://agentmods.dev/badge/skills/wrongstack/wrongstack/python-backend/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for python-backend

Your own site · 80×15
<a href="https://agentmods.dev/skills/wrongstack/wrongstack/python-backend"><img src="https://agentmods.dev/badge/skills/wrongstack/wrongstack/python-backend.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 93 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,269 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00093 $0.02269
Opus 5.5 $0.00037 $0.00908
Sonnet 5.5 $0.00019 $0.00454
Haiku 4.5 $0.00009 $0.00227

Measured 27d ago against content hash 2cdf872cbbc7, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

python-backend scanned grade A with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 27d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

- Smoke: `uv run uvicorn app.main:app --port 8000`, then `curl -fsS localhost:8000/healthz` and the changed route
packages/core/skills/python-backend/SKILL.md · 117 lines

How it starts

The opening of the file, as written. The whole thing — 117 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Python Backend

Selection card

  • Task: Implement or repair Python APIs, workers and typed validation.
  • Start: Read pyproject.toml, the lockfile, the ASGI/WSGI entrypoint and the route or task being changed.
  • Finish: the real entrypoint starts, the changed path answers correctly, and the checks below pass.

Overview

A Python service fails in production at its boundaries: unvalidated input, blocking calls on the event loop, sessions that outlive their unit of work, and settings nobody checked at startup. Checked 2026-11-02: Python 3.15.2, FastAPI 0.162.0, Django 6.1.2 and uv 0.13.6. Verify framework/native-wheel/Python support before combining them; latest Python can lead package support. Type hints document intent; only Pydantic, serializers and forms enforce it at runtime.

Rules

  1. Never call blocking I/O inside async def. Use an async client (httpx.AsyncClient, AsyncSession), asyncio.to_thread, or declare the FastAPI endpoint as plain def so it runs in the threadpool.
  2. Validate every untrusted payload at the boundary and return explicit response models; never serialize ORM rows or exception text directly.
  3. One database session per unit of work, opened and closed by a context manager or yield dependency, with rollback on error. Never share one AsyncSession across concurrent tasks.
  4. Every outbound call has a timeout. requests has none by default; httpx defaults to 5 seconds — set it deliberately either way.
  5. Load settings once at startup through pydantic-settings or Django settings, fail fast on missing values, and keep secrets in SecretStr or the environment, never in code.
  6. Authorize the object, not just the route: filter queries by owner/tenant at the query boundary.
  7. Keep the project's package manager, framework and layout. A framework migration is its own task.
  8. Re-raise asyncio.CancelledError after cleanup; never swallow it in except Exception or bare except.

First moves by situation

Situation First moves
New endpoint Find a sibling route; copy its dependency, schema and error conventions; add request and response models; write the failing test first
Endpoint slow or hangs under load Look for sync clients, time.sleep, sync ORM calls inside async def; count queries per request; check pool size vs worker count
MissingGreenlet / greenlet_spawn has not been called An async session lazy-loaded a relationship or touched an expired attribute; add selectinload/joinedload and expire_on_commit=False
422 or validation surprise Compare the Pydantic model to the payload; check lax coercion ("1" becomes 1) versus ConfigDict(strict=True)
Django N+1 or slow admin select_related/prefetch_related; prove the count with assertNumQueries
Python or framework upgrade Read release notes and deprecations; run tests with -W error::DeprecationWarning; confirm native wheels exist for the new interpreter
Background job duplicated or lost Check ack mode, broker visibility timeout versus task duration, and idempotency keys (hand off to queues-jobs for semantics)
Settings or secret leak Grep for hard-coded keys, DEBUG=True, wildcard ALLOWED_HOSTS, secrets in logged reprs

Read the full file on GitHub · 117 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 27d ago Changed · +48 lines · +51 tokens per session 2cdf872cbbc7
  2. 1mo ago Changed · +10 lines b74682326dab
  3. 1mo ago Changed ac48532ed0ac
  4. 1mo ago First seen · 59 lines · 42 tokens per session scan A bd13c6f167ae

Subscribe to this mod's changes

python-backend is a skill published in the GitHub repository WrongStack/WrongStack (444 stars, last pushed today), licensed MIT. It adds 93 tokens to every session and 2,269 once invoked, about $0.0004 per session on Opus 5.5. A static security scan graded it A with 1 finding (makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-10-10.

Related

python-backend compared with skills from other repositories

python-backend next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
python-backendWrongStack/WrongStackSkill444todayMITA93Claude Code, Codex
pydantic-models-pyLiHongwei-cn/lihongwei-cnSkill51mo agoMITA23Claude Code, Codex
performant-pythonandreibesleaga/GABBESkill243d agononeA55Claude Code, Codex
fastapi-templatesLiHongwei-cn/lihongwei-cnSkill51mo agoMITA37Claude Code, Codex
fastapi-templatesmattmre/EVOKORE-MCP-PUBLICSkill46mo agoMITA37Claude Code, Codex
fastapi-templateswshobson/agentsSkill43k6d agoMITA37Claude Code
build-fullstack-backendmindsdb/antonSkill753todayMITA130Claude Code, Codex