agentleFS
a365ngaya365ngay/CogniRouter/skills/senior-python-backend/SKILL.md

senior-python-backend

Skill2 starsChanged 5 days agoMITView on GitHub

Use when designing, implementing, debugging, reviewing, or refactoring Python web backends with FastAPI, Django, Django REST Framework, or Flask, including routing, Pydantic or serializer validation, ORM queries (SQLAlchemy, Django ORM), migrations, auth, async I/O, background tasks (Celery, RQ), and API tests. For general Python code standards also see python-standard.

The file

We split this skill into the rules it gives an agent

4 rules. About 0 are common, 3 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Avoid N+1 queries (select_related/prefetch_related, SQLAlchemy selectinload/joinedload), paginate lists, and keep transactions short and …

    line 22
  2. Distinctive:

    Write migrations that are safe for existing data and deployments: add nullable columns or defaults first, backfill separately, avoid long …

    line 24
  3. Distinctive:

    Keep secrets in environment or a secret store.

    line 25
  4. Distinctive:

    Run the project's formatter/linter (ruff, black, flake8), type checker (mypy/pyright) if configured, and pytest including API tests for …

    line 30

≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Senior Python Backend

Role

Build Python web services with validated contracts, efficient ORM access, correct async boundaries, safe migrations, and enforced authorization.

Before Editing

  1. Inspect framework and version, project layout, settings and environment handling, ORM and migration tool (Alembic, Django migrations), validation layer (Pydantic, DRF serializers, marshmallow), auth mechanism, task queue, dependency manager, and test setup (pytest, pytest-django, httpx/TestClient).
  2. Trace the endpoint from router/view through dependencies or middleware, validation, permissions, service logic, ORM queries, external calls, and response schema.
  3. Reuse existing patterns; do not add a new framework layer, repository abstraction, or library for one endpoint.

Implementation Rules

  • Validate all input with the project's schema layer and declare response models so internal fields never leak.
  • Enforce authentication and object-level permissions in dependencies, permission classes, or decorators before side effects.
  • Avoid N+1 queries (select_related/prefetch_related, SQLAlchemy selectinload/joinedload), paginate lists, and keep transactions short and explicit (transaction.atomic, session scope).
  • In async frameworks, never call blocking I/O (sync DB drivers, requests, heavy CPU) inside async def handlers; use async clients, a threadpool, or a sync route.
  • Write migrations that are safe for existing data and deployments: add nullable columns or defaults first, backfill separately, avoid long table locks.
  • Keep secrets in environment or a secret store; set timeouts and retries on outbound HTTP; make background tasks idempotent with retry limits.
  • Map errors to the project's error contract; never return raw tracebacks or ORM errors to clients.

Testing and Verification

Run the project's formatter/linter (ruff, black, flake8), type checker (mypy/pyright) if configured, and pytest including API tests for changed endpoints. Run migrations against a disposable database and check generated SQL for changed queries.

Review Checklist

  • Are input and output schemas explicit, and is authorization object-level?
  • Are queries bounded and free of N+1 behavior?
  • Is async code free of blocking calls?
  • Are migrations reversible or safe to roll forward under load?

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.