python-expert
Skill28 starsChanged 3 months agoApache-2.0View on GitHub
Guides PEP 8 compliance, modern static type hinting (Python 3.10+ PEP 604, Protocols), generator pipelines, memory optimization (slots, dataclasses), structured concurrency (asyncio TaskGroup), and production error handling in Python applications. Use when writing pure Python modules, utility functions, algorithms, or optimizing memory and execution speed.
3 other projects use a version of this.
Adopted by
Most recently taken up by
- iamdemetris/lude-kittheir own version, first seen Jul 17, 2026
- miptah21/skillstheir own version, first seen May 26, 2026
- FutureJJ/claude-skillstheir own version, first seen Mar 7, 2026
Other versions3 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 3
- FutureJJ/claude-skills★ 3same name
- miptah21/skills★ 2same name
- iamdemetris/lude-kit★ 0same 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 repository34 other files it gives its agents.
- bigquery-query-optimizationSkill
- build-and-ci-gatesSkill
- cdc-scd-patternsSkill
- code-implementerSkill
- code-smells-expertSkill
- commit-expertSkill
- compliance-verifierSkill
- context-captureSkill
- context-restoreSkill
- database-migration-expertSkill
- design-spec-expertSkill
- documentation-expertSkill
- flutter-architecture-decisionsSkill
- flutter-performance-profilingSkill
- flutter-release-engineeringSkill
- flutter-review-checklistSkill
- flutter-senior-orchestrationSkill
- flutter-test-strategySkill
- flutter-upgrade-migrationSkill
- gcp-data-engineeringSkill
- guidelines-karpathySkill
- loop-engineeringSkill
- performance-scalabilitySkill
- product-analystSkill
- pull-request-expertSkill
- qa-testerSkill
- refactoring-code-expertSkill
- repo-researchSkill
- security-auditSkill
- senior-architect-engineeringSkill
- senior-dev-orchestratorSkill
- sql-query-optimizationSkill
- test-driven-developmentSkill
- testing-expertSkill
The file
We split this skill into the rules it gives an agent
11 rules. 0 are common, 0 are distinctive, and 11 are very specific to this project.
0
Common
Most of the 3 edited versions we read keep these.
0
Distinctive
This author's own choices. Worth a look.
11
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 27
Use built-in generic collections (list[T], dict[K, V], set[T]) instead of legacy typing.List / typing.Dict.
- Very specific: line 28
Use PEP 604 union syntax T | None instead of Optional[T].
- Very specific: line 32
Use @dataclass(slots=True, frozen=True) for lightweight, immutable data transfer objects.
- Very specific: line 34
Use collections.deque for $O(1)$ append/pop operations on both ends (never list.pop(0) which is $O(N)$).
- Very specific: line 38
Use asyncio.TaskGroup() (Python 3.11+) or scoped task management for concurrent asynchronous tasks.
- Very specific: line 39
Never execute blocking synchronous I/O or CPU-bound calls directly on the event loop.
- Very specific: line 40
Use explicit exception chaining (raise CustomError(...) from err) to preserve root cause tracebacks.
- Very specific: line 41
Never swallow exceptions with bare except: or silent pass.
- Very specific: line 44
NEVER: use mutable default arguments (def func(items=[])).
- Very specific: line 45
Always manage resources using context managers (with / async with).
- Very specific: line 46
Use logging.getLogger(__name__) with structured context rather than raw print() statements.
“Common” is measured: kept by at least 6 in 10 of the 3 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 Expert Skill
Overview
This skill guides the design and implementation of modern, idiomatic (Pythonic), type-safe, and high-performance Python (3.10+) applications. It acts as a Senior Python Core Architect enforcing modern syntax standards (PEP 604 unions, @dataclass(slots=True)), zero-copy generator pipelines (itertools), structured async concurrency (asyncio.TaskGroup), and disciplined defensive error handling.
When to Use
Trigger Scenarios
- Writing or refactoring core Python modules, libraries, or backend domain logic.
- Adding strict static type annotations (
mypy,pyright, PEP 604 unionsA | B,typing.Protocol). - Optimizing memory footprint (e.g.,
__slots__, streaming generators for large datasets). - Implementing structured asynchronous concurrency or background workers (
asyncio). - Diagnosing and refactoring performance bottlenecks and algorithmic complexities.
When NOT to Use
- Framework-specific REST API routing: Combine with
fastapi-expertfor HTTP route serialization. - Database schema migrations: Route to
database-migration-expert. - Pre-commit and CI configuration: Route to
build-and-ci-gates. - Non-Python language development: Route to the corresponding language skill.
Process
Phase 1: Modern Type Hinting & Interface Design
- Use built-in generic collections (
list[T],dict[K, V],set[T]) instead of legacytyping.List/typing.Dict. - Use PEP 604 union syntax
T | Noneinstead ofOptional[T]. - Define structural interfaces using
typing.Protocolto enforce duck typing with strict static analysis (mypy).
Phase 2: Memory & Algorithmic Optimization
- Use
@dataclass(slots=True, frozen=True)for lightweight, immutable data transfer objects. - Stream large datasets with generators (
yield) anditertoolspipeline functions (islice,chain) rather than buffering full lists in RAM. - Use
collections.dequefor $O(1)$ append/pop operations on both ends (neverlist.pop(0)which is $O(N)$). - Replace linear list searches ($O(N)$) with set or dictionary lookups ($O(1)$).
Phase 3: Structured Concurrency & Resilience
- Use
asyncio.TaskGroup()(Python 3.11+) or scoped task management for concurrent asynchronous tasks. - Never execute blocking synchronous I/O or CPU-bound calls directly on the event loop; offload via
asyncio.to_thread(). - Use explicit exception chaining (
raise CustomError(...) from err) to preserve root cause tracebacks. - Never swallow exceptions with bare
except:or silentpass.
Phase 4: Defensive Coding Invariants
- NEVER use mutable default arguments (
def func(items=[])). Useitems: list[T] | None = None. - Always manage resources using context managers (
with/async with). - Use
logging.getLogger(__name__)with structured context rather than rawprint()statements.
Usage
CLI Verification Commands
# Static typing verification
mypy --strict src/
# Linter and formatting check
ruff check src/
ruff format --check src/Example Prompts
- "Review this data parsing module to optimize memory usage with slots and generators."
- "Refactor our synchronous network clients to use structured asyncio with TaskGroup."
- "Add strict mypy-compliant type hints to this package using modern Python 3.10+ syntax."
Host Execution Instructions
- Claude Code: Execute
mypyandruffin the workspace shell to verify type safety. - Antigravity: Apply Pythonic guidelines during code generation and run validation checks via workspace tools.
Red Flags
- Mutable default parameters (
def add_item(target=[])). - Bare
except:catchingBaseExceptionand masking system exits. - Running synchronous blocking code (
requests.get,time.sleep) inside async def coroutines. - Instantiating millions of objects without
__slots__or@dataclass(slots=True). - Using
list.pop(0)in loops causing $O(N^2)$ algorithmic degradation.
Verification
mypy --strictpasses with zero type errors.- No mutable default arguments present in any function signatures.
- Large dataset iterations use generators or iterators with bounded memory consumption.
- Async workflows employ
asyncio.TaskGroupor safe concurrency boundaries without thread blocking. - All raised exceptions preserve source context via
from err.
References
For detailed code patterns, memory benchmarks, and anti-pattern comparisons:
- Python Core Best Practices & Performance Optimization
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.

