python-expert
Use for Python development requiring async programming, type system expertise, testing patterns, or performance optimization.
What this skill does
# Python Expert
Elite Python 3.13+ expertise for backend development, testing, async programming, and type systems.
## When to Use
- Async/await, asyncio, concurrency patterns
- Type errors or complex annotations
- Writing/debugging tests (pytest, async, mocking)
- Performance optimization
- Security review
- Backend architecture (FastAPI, Django, SQLAlchemy)
## Core Expertise
**Python Mastery**: Decorators, context managers, metaclasses, descriptors, generators, coroutines, data model, GIL internals
**Backend**: FastAPI/Django/Flask, PostgreSQL/Redis/MongoDB, SQLAlchemy/Django ORM, REST/GraphQL/WebSockets/gRPC, OAuth2/JWT, microservices
## Code Standards
- Full type hints, Google/NumPy docstrings, 88-char lines
- PEP 8 naming, SOLID principles, secure by default
- Use f-strings for formatting, focused small functions
## Testing
**pytest**: Use `setup_method`, `pytest.raises`, `@patch` for mocking
**Async**: Use anyio for test fixtures, `AsyncMock` for mocking async functions
**Integration**: In-memory SQLite fixtures with proper cleanup
**All network calls must be mocked**
## Async/Await
- `asyncio.run()` for entry, `TaskGroup` for structured concurrency (preferred over `gather()`)
- `asyncio.timeout()` for timeouts, `Semaphore` for rate limiting
- Handle cancellation with try/finally, use `ExceptionGroup` for multiple errors
- Type: `async def foo() -> T` or `Awaitable[T]`
## Type System
**Modern syntax** (Python 3.10+): `list[str]`, `dict[str, int]`, `str | None`
**Variance**: dict invariant, Mapping covariant—use `Mapping[K, V]` when needed
**Advanced**: `Self` for fluent methods, `ParamSpec` for decorator typing, `TypedDict`
**Minimize `Any`**:
- Use `Protocol` for structural typing instead of `Any`
- Use `TypedDict` for dicts with known structure instead of `dict[str, Any]`
- Document why `Any` is necessary when it must be used
**Common fixes**: Mixed type ops, SQLAlchemy column assignments, API response access
**Atomic processing**: Fix ALL type errors in file with single edit
## Patterns
```python
# Dataclass with slots (memory efficient)
@dataclass(slots=True)
class User:
name: str
email: str
tags: list[str] = field(default_factory=list)
def __post_init__(self):
if not self.name: raise ValueError("Name required")
# Pattern matching (3.10+)
match response.status:
case 200: return response.json()
case 404: raise NotFoundError()
case _: raise APIError(response.status)
```
**Prefer**: Dependency injection over singletons, `@cache` for memoized instances
## Security
- Validate/sanitize all inputs, parameterized SQL queries only
- Rate limiting, CORS/CSRF protection, secure sessions
- Avoid dynamic code evaluation and unsafe serialization with untrusted data
**Cryptography**:
- Forbidden: MD5, SHA-1, DES/3DES, RC4, custom crypto
- Required: SHA-256+ for hashing, AES-256-GCM for encryption, Argon2/scrypt for passwords
- Use `secrets` module for tokens, `cryptography` package for crypto operations
## Performance
- Profile first (cProfile, timeit), optimize real bottlenecks
- Sets for O(1) lookup, deque for queues, Counter for counting
- Generators for large data, `__slots__` for memory
- `@cache` (unbounded) or `@lru_cache` (bounded) for memoization
- Eager loading (N+1), connection pooling, async I/O
## Pitfalls
```python
# Mutable defaults: use None, then check identity
def f(items=None):
if items is None:
items = [] # Don't use `or []` - empty list is falsy!
return items
# Late binding: capture with default arg
funcs = [lambda x=i: x for i in range(3)]
```
**Avoid**: God classes, spaghetti code, magic numbers, copy-paste, bare `except:`
## Error Handling
Custom exception hierarchies, structured JSON logging, circuit breakers, retry with backoff, graceful degradation
## Tooling
```bash
ruff check . # lint
ruff format . # format
pyright . # typecheck
```
**Stack**: uv, httpx/aiohttp/anyio, pydantic
## Cleanup
Remove before completion: `debug-*.py`, `test-*.py`, `__pycache__/`, `*.pyc`, `*_REPORT.md`
Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.