python-dev
Skill1 starsChanged 9 months agoMITView on GitHub
Python backend development: FastAPI, SQLAlchemy 2.0, Alembic, Pydantic v2, async Python, testing with pytest. Use when implementing or modifying API endpoints, database models/migrations, services, schemas, or backend tests.
7 other projects use a version of this.
Adopted by
Most recently taken up by
- tenequm/skillstheir own version, first seen Jun 5, 2026
- doccker/cc-use-exptheir own version, first seen May 29, 2026
- kumaran-is/claude-code-onboardingtheir own version, first seen May 25, 2026
- pytholic/claude-skillstheir own version, first seen Apr 22, 2026
- databricks-solutions/ai-dev-kittheir own version, first seen Mar 23, 2026
- JohnJBoren/claude-skills-ecosystemtheir own version, first seen Dec 26, 2025
Other versions7 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 7
- databricks-solutions/ai-dev-kit★ 1.9ksame name
- doccker/cc-use-exp★ 1.1ksame name
- tenequm/skills★ 37same name
- kumaran-is/claude-code-onboarding★ 36same name
- 0xSero/claude-skill-dir★ 3same name
- pytholic/claude-skills★ 3same name
- JohnJBoren/claude-skills-ecosystem★ 2same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository16 other files it gives its agents.
- .claude/CLAUDE.mdCLAUDE.md
- .cursor/rules/ask-first.mdcCursor rule
- .cursor/rules/git-mv-rename.mdcCursor rule
- .cursor/rules/include-specs.mdcCursor rule
- .cursor/rules/update-specs.mdcCursor rule
- code-review-codexSkill
- commitSkill
- python-devSkill
- react-devSkill
- spec-review-codexSkill
- summarizerSkill
- ui-designSkill
- yt-transcriptSkill
- codex-reviewSkill
- react-devSkill
- ui-designSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
28 rules. 0 are common, 12 are distinctive, and 16 are very specific to this project.
0
Common
Most of the 5 edited versions we read keep these.
12
Distinctive
This author's own choices. Worth a look.
16
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 16
Use this whenever you are asked to:
- Distinctive: line 20
Write async services, integrations, or data pipelines
- Distinctive: line 21
Write or update backend tests (pytest, pytest-asyncio)
- Distinctive: line 27
Async discipline: no blocking calls in async paths
- Distinctive: line 61
All I/O operations must be awaited — database queries, HTTP calls, file I/O.
- Very specific: line 62
Never call blocking functions (e.g., time.sleep, synchronous DB drivers) inside async endpoints or services.
- Very specific: line 63
Use asyncio.gather for independent concurrent operations.
- Very specific: line 64
If you must call blocking code, use asyncio.to_thread() or a thread pool executor.
- Very specific: line 68
Use Depends() for cross-cutting concerns: DB sessions, auth, config, services.
- Distinctive: line 69
Use lifespan events for startup/shutdown (connection pools, caches).
- Very specific: line 70
Prefer path operation decorators that declare response models: response_model=FooResponse.
- Very specific: line 71
Use status_code parameter on decorators for non-200 success responses (201, 204).
- Very specific: line 77
Use model_config = ConfigDict(from_attributes=True) for ORM-backed response models.
- Very specific: line 79
Use Field() for constraints, defaults, descriptions, and examples.
- Very specific: line 80
Prefer Annotated[str, Field(...)] style for reusable type annotations.
- Very specific: line 84
Use declarative models with Mapped[] and mapped_column().
- Very specific: line 85
Use select() statement style — never legacy session.query().
- Very specific: line 86
Prefer session.scalars(select(...)) over session.execute(select(...)).scalars().
- Very specific: line 87
Use relationships with lazy="selectin" or explicit eager loading to avoid N+1 queries.
- Distinctive: line 88
Always scope sessions properly — one session per request via dependency injection.
- Very specific: line 92
Run alembic revision --autogenerate -m "description" after model changes.
- Distinctive: line 93
Always review autogenerated migrations — they can miss renames, data migrations, or constraints.
- Very specific: line 95
Test migrations forward and backward (upgrade + downgrade).
- Very specific: line 99
Use HTTPException for expected errors (validation, not-found, auth failures).
- Distinctive: line 100
Use exception handlers for domain-specific error classes.
- Distinctive: line 103
Never expose internal details (tracebacks, DB errors) in API responses.
- Distinctive: line 107
Keep business logic in service modules, not in endpoint functions.
- Distinctive: line 109
Avoid circular imports — use dependency injection and interfaces.
“Common” is measured: kept by at least 6 in 10 of the 5 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Python Development
When to use this skill
Use this whenever you are asked to:
- Build or modify FastAPI endpoints, middleware, or dependencies
- Work with SQLAlchemy models, queries, or Alembic migrations
- Define or update Pydantic schemas (request/response, config, validation)
- Write async services, integrations, or data pipelines
- Write or update backend tests (pytest, pytest-asyncio)
Outcome targets
- Correctness: endpoints return proper status codes; data integrity maintained
- Type safety: type hints everywhere; Pydantic at all boundaries
- Async discipline: no blocking calls in async paths
- Testability: behavior-focused tests; mocked external dependencies
- Clarity: small functions, meaningful errors, structured logging
Stack and tooling
- FastAPI — async endpoints, dependency injection, lifespan events, middleware
- Pydantic v2 — schemas, settings, validation, serialization
- SQLAlchemy 2.0 — async sessions, declarative models,
Mapped[],select()style - Alembic — async migrations, autogenerate, manual revision editing
- Async Python — asyncio, asyncpg, httpx, proper concurrency patterns
- Testing — pytest, pytest-asyncio, httpx AsyncClient, fixtures, coverage
Coding standards
- Async-first — all I/O (DB, HTTP, LLM) must be async. No blocking calls in async paths.
- Type hints everywhere — use modern Python syntax (PEP 604 unions, generics, etc.).
- Pydantic at all boundaries — request/response models, config, inter-module data. No raw dicts across boundaries.
- SQLAlchemy 2.0 only — no legacy 1.x Query API. Use
select(),Mapped[],mapped_column(). - Dependency injection — use FastAPI
Depends()for sessions, config, auth, services. - Structured logging — use the project's logging setup, not bare
print(). - Meaningful errors —
HTTPExceptionwith correct status codes and clear detail messages. - Small, focused functions — single responsibility. Easy to read, easy to test.
Best-practice rules
A) Async discipline
- All I/O operations must be awaited — database queries, HTTP calls, file I/O.
- Never call blocking functions (e.g.,
time.sleep, synchronous DB drivers) inside async endpoints or services. - Use
asyncio.gatherfor independent concurrent operations; avoid creating tasks you don't track. - If you must call blocking code, use
asyncio.to_thread()or a thread pool executor.
B) FastAPI patterns
- Use
Depends()for cross-cutting concerns: DB sessions, auth, config, services. - Use lifespan events for startup/shutdown (connection pools, caches).
- Prefer path operation decorators that declare response models:
response_model=FooResponse. - Use
status_codeparameter on decorators for non-200 success responses (201, 204). - Group related endpoints in routers; keep
main.pythin.
C) Pydantic schemas
- Separate request and response models — don't reuse the same schema for both.
- Use
model_config = ConfigDict(from_attributes=True)for ORM-backed response models. - Validate early: let Pydantic reject bad input at the API boundary, not deep in business logic.
- Use
Field()for constraints, defaults, descriptions, and examples. - Prefer
Annotated[str, Field(...)]style for reusable type annotations.
D) SQLAlchemy 2.0
- Use declarative models with
Mapped[]andmapped_column(). - Use
select()statement style — never legacysession.query(). - Prefer
session.scalars(select(...))oversession.execute(select(...)).scalars(). - Use relationships with
lazy="selectin"or explicit eager loading to avoid N+1 queries. - Always scope sessions properly — one session per request via dependency injection.
E) Alembic migrations
- Run
alembic revision --autogenerate -m "description"after model changes. - Always review autogenerated migrations — they can miss renames, data migrations, or constraints.
- For data migrations, write explicit
op.execute()SQL in the migration. - Test migrations forward and backward (
upgrade+downgrade).
F) Error handling
- Use
HTTPExceptionfor expected errors (validation, not-found, auth failures). - Use exception handlers for domain-specific error classes.
- Return consistent error response shapes across the API.
- Log unexpected errors with full context; return generic 500 to clients.
- Never expose internal details (tracebacks, DB errors) in API responses.
G) Project structure
- Keep business logic in service modules, not in endpoint functions.
- Endpoints should: validate input, call services, return responses.
- Avoid circular imports — use dependency injection and interfaces.
- Group by feature/domain, not by layer, when the project grows.
Testing
- Write tests alongside implementation — new endpoints, services, and schema changes should include corresponding tests.
- Test behavior, not internals — test inputs -> outputs, status codes, side effects.
- Use fixtures for shared setup — DB sessions, test clients, sample data. Keep
conftest.pyorganized by scope. - Async tests — use
pytest-asyncioandhttpx.AsyncClientfor endpoint tests. - Mock external dependencies — LLM calls, external HTTP, scheduled jobs. Never hit real external services in tests.
- Cover the important paths — happy path, validation errors (422), auth failures (401/403), not-found (404), and domain-specific edge cases.
- Run tests after changes — if tests exist in the area you touched, run them and fix failures before finishing.
- Coverage awareness — prioritize coverage for business logic and API boundaries over boilerplate.
Common failure modes (fast triage)
| Symptom | Likely cause | Fix |
RuntimeWarning: coroutine was never awaited | Missing await on async call | Add await |
| Endpoint hangs / slow response | Blocking call in async path | Replace with async equivalent or to_thread() |
DetachedInstanceError | Accessing lazy-loaded attribute outside session | Use eager loading or access within session scope |
| N+1 queries | Lazy loading in a loop | Use selectin loading or explicit joins |
| Migration autogenerate misses change | Rename or complex alteration | Write manual migration operations |
| 422 with unclear message | Pydantic validation error | Check schema constraints and field types |
| Circular import | Modules importing each other at top level | Use TYPE_CHECKING guard or restructure |
Sources
FastAPI
- FastAPI docs — https://fastapi.tiangolo.com/
- Dependencies — https://fastapi.tiangolo.com/tutorial/dependencies/
- Lifespan events — https://fastapi.tiangolo.com/advanced/events/
- Testing — https://fastapi.tiangolo.com/tutorial/testing/
Pydantic
- Pydantic v2 docs — https://docs.pydantic.dev/latest/
- Model config — https://docs.pydantic.dev/latest/concepts/config/
- Field types — https://docs.pydantic.dev/latest/concepts/fields/
SQLAlchemy
- SQLAlchemy 2.0 — https://docs.sqlalchemy.org/en/20/
- Mapped columns — https://docs.sqlalchemy.org/en/20/orm/mapped_attributes.html
- Async session — https://docs.sqlalchemy.org/en/20/orm/extensions/asyncio.html
Alembic
- Alembic tutorial — https://alembic.sqlalchemy.org/en/latest/tutorial.html
- Autogenerate — https://alembic.sqlalchemy.org/en/latest/autogenerate.html
Testing
- pytest — https://docs.pytest.org/
- pytest-asyncio — https://pytest-asyncio.readthedocs.io/
- httpx — https://www.python-httpx.org/
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
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.

