Claude-skill-registry lang-python
This skill should be used when the user asks to "write Python code", "debug a Python script", "set up a Python project", "explain Python concepts", or mentions Python-specific libraries like FastAPI, Django, or Pandas.
git clone https://github.com/majiayu000/claude-skill-registry
T=$(mktemp -d) && git clone --depth=1 https://github.com/majiayu000/claude-skill-registry "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/data/lang-python" ~/.claude/skills/majiayu000-claude-skill-registry-lang-python && rm -rf "$T"
skills/data/lang-python/SKILL.md<skill_doc> <trigger_keywords>
Trigger Keywords
Activate this skill when the user mentions any of:
File Extensions:
.py, pyproject.toml, requirements.txt, pytest.ini, setup.py
Python Core: Python, python3, pip, poetry, uv, asyncio, async/await, type hints, dataclass, Protocol, TypeVar, ParamSpec, match/case, pattern matching
Web Frameworks: FastAPI, Django, Flask, Starlette, ASGI, WSGI, Depends, APIRouter, @app.get, @app.post
Validation: Pydantic, BaseModel, model_validate, ConfigDict, Field, validator, model_validator
ORM/Database: SQLAlchemy, AsyncSession, create_async_engine, Alembic, migrations, ORM, query builder
Testing: pytest, pytest-asyncio, @pytest.fixture, @pytest.mark.parametrize, mock, conftest.py, coverage
Data Science: numpy, pandas, polars, DataFrame, ndarray, data pipeline, ETL
Package Management: uv (preferred), poetry, pip install, virtual environment, venv </trigger_keywords>
⛔ Forbidden Patterns
- NO Mutable Default Arguments: Never use
. Usedef foo(x=[])
as default and initialize inside the function.None - NO Sync I/O in Async Functions: Blocking operations (like
orrequests.get
) insidetime.sleep
kill performance. Useasync def
orhttpx
.asyncio.sleep - NO Wildcard Imports: Avoid
. Explicit imports prevent namespace pollution and make code readable.from module import * - NO Bare Excepts: Never use
. Always catch specific exceptions (e.g.,except:
).except ValueError: - NO Pip/Poetry (unless forced): ALWAYS prefer
for package management. It is significantly faster and more reliable. Only useuv
orpip
if explicitly requested or ifpoetry
is unavailable.uv
🤖 Agent Tool Strategy
- Discovery: Check for
first. If it exists, usejustfile
. Readjust -l
orpyproject.toml
.requirements.txt - Package Management: ALWAYS use
for all package operations (uv
,uv add
,uv pip install
). Only fallback touv venv
/pip
ifpoetry
fails.uv - Virtual Environment:
creates environments instantly. Use it.uv venv - Code Analysis: Use
to find definitions. Avoidsearch_files
if possible.grep - Testing: Use
for running tests. Preferpytest
overpytest
.unittest - Linting/Formatting: Respect
orruff.toml
[tool.ruff] settings.pyproject.toml
Quick Reference (30 seconds)
Python 3.13+ Development Specialist - FastAPI, Django, async patterns, pytest, and modern Python features.
Auto-Triggers:
.py files, pyproject.toml, requirements.txt, pytest.ini, FastAPI/Django discussions
Core Capabilities:
- Python 3.13 Features: JIT compiler (PEP 744), GIL-free mode (PEP 703), pattern matching
- Web Frameworks: FastAPI 0.115+, Django 5.2 LTS
- Data Validation: Pydantic v2.9 with model_validate patterns
- ORM: SQLAlchemy 2.0 async patterns
- Testing: pytest with fixtures, async testing, parametrize
- Package Management: poetry, uv, pip with pyproject.toml
- Type Hints: Protocol, TypeVar, ParamSpec, modern typing patterns
- Async: asyncio, async generators, task groups
- Data Science: numpy, pandas, polars basics
Quick Patterns
FastAPI Endpoint:
from fastapi import FastAPI, Depends from pydantic import BaseModel app = FastAPI() class UserCreate(BaseModel): name: str email: str @app.post("/users/") async def create_user(user: UserCreate) -> User: return await UserService.create(user)
Pydantic v2.9 Validation:
from pydantic import BaseModel, ConfigDict class User(BaseModel): model_config = ConfigDict(from_attributes=True, str_strip_whitespace=True) id: int name: str email: str user = User.model_validate(orm_obj) # from ORM object user = User.model_validate_json(json_data) # from JSON
pytest Async Test:
import pytest @pytest.mark.asyncio async def test_create_user(async_client): response = await async_client.post("/users/", json={"name": "Test"}) assert response.status_code == 201
Implementation Guide (5 minutes)
See patterns.md for the detailed implementation guide covering:
- Python 3.13 New Features (JIT, GIL-Free)
- FastAPI 0.115+ Patterns (Async DI, Class Dependencies)
- Django 5.2 LTS Features
- Pydantic v2.9 Deep Patterns
- SQLAlchemy 2.0 Async Patterns
- pytest Advanced Patterns
- Type Hints Modern Patterns
- Package Management (Poetry, uv)
Advanced Implementation (10+ minutes)
For comprehensive coverage including:
- Production deployment patterns (Docker, Kubernetes)
- Advanced async patterns (task groups, semaphores)
- Data science integration (numpy, pandas, polars)
- Performance optimization techniques
- Security best practices (OWASP patterns)
- CI/CD integration patterns
See:
- patterns.md - Implementation patterns (FastAPI, Pydantic, SQLAlchemy)
- reference.md - Complete reference documentation
- examples.md - Production-ready code examples
Context7 Library Mappings
/docs/astral.sh/uv /tiangolo/fastapi - FastAPI async web framework /django/django - Django web framework /pydantic/pydantic - Data validation with type annotations /sqlalchemy/sqlalchemy - SQL toolkit and ORM /pytest-dev/pytest - Testing framework /numpy/numpy - Numerical computing /pandas-dev/pandas - Data analysis library /pola-rs/polars - Fast DataFrame library
Troubleshooting
Common Issues:
Python Version Check:
python --version # Should be 3.13+ python -c "import sys; print(sys.version_info)"
Async Session Detached Error:
- Solution: Set
in session configexpire_on_commit=False - Or: Use
after commitawait session.refresh(obj)
pytest asyncio Mode Warning:
# pyproject.toml [tool.pytest.ini_options] asyncio_mode = "auto" asyncio_default_fixture_loop_scope = "function"
Pydantic v2 Migration:
is nowparse_obj()model_validate()
is nowparse_raw()model_validate_json()
requiresfrom_orm()
in ConfigDict </skill_doc>from_attributes=True