Skip to content
Skills Library
Programming · Building & coding

python-expert

/python-expert

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.

Licence
Apache-2.0
Last repository change
19.10.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
2
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 19.10.2026, without references to retired models or APIs.

Licence

Apache-2.0, otwarta: można używać i zmieniać, z zachowaniem licencji i informacji o zmianach.

What it does and when to use it

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.

Original author description

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.

How it works

  1. Overview
  2. When to Use
  3. Process
  4. Usage
  5. Red Flags
  6. Verification
  7. References
Original SKILL.md headings · 82 lines, 612 words
SKILL.md preview
---
name: python-expert
description: 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.
---

# 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 unions `A | 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-expert` for 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
1. Use built-in generic collections (`list[T]`, `dict[K, V]`, `set[T]`) instead of legacy `typing.List` / `typing.Dict`.
2. Use PEP 604 union syntax `T | None` instead of `Optional[T]`.
3. Define structural interfaces using `typing.Protocol` to enforce duck typing with strict static analysis (`mypy`).

### Phase 2: Memory & Algorithmic Optimization
1. Use `@dataclass(slots=True, frozen=True)` for lightweight, immutable data transfer objects.
2. Stream large datasets with generators (`yield`) and `itertools` pipeline functions (`islice`, `chain`) rather than buffering full lists in RAM.
3. Use `collections.deque` for $O(1)$ append/pop operations on both ends (never `list.pop(0)` which is $O(N)$).
4. Replace linear list searches ($O(N)$) with set or dictionary lookups ($O(1)$).

### Phase 3: Structured Concurrency & Resilience
1. Use `asyncio.TaskGroup()` (Python 3.11+) or scoped task management for concurrent asynchronous tasks.
2. Never execute blocking synchronous I/O or CPU-bound calls directly on the event loop; offload via `asyncio.to_thread()`.
3. Use explicit exception chaining (`raise CustomError(...) from err`) to preserve root cause tracebacks.
4. Never swallow exceptions with bare `except:` or silent `pass`.

### Phase 4: Defensive Coding Invariants
1. **NEVER** use mutable default arguments (`def func(items=[])`). Use `items: list[T] | None = None`.
2. Always manage resources using context managers (`with` / `async with`).
3. Use `logging.getLogger(__name__)` with structured context rather than raw `print()` statements.

## Usage
### CLI Verification Commands
```bash
# 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 `mypy` and `ruff` in 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:` catching `BaseException` and 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 --strict` passes 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.TaskGroup` or 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](references/python-patterns.md)

Files in this package (2)
  • SKILL.md 5 KB
  • references/python-patterns.md 7 KB

Versions

RepositoryScoreLicence
This page · jggomez/expert-ai-developer-skills100Apache-2.0
traylinx/switchAILocal100Apache-2.0
personamanagmentlayer/pcl100Apache-2.0
personamanagmentlayer/pcl100Apache-2.0
miaoge-ge/coding-agent-skills100MIT
wesleyegberto/software-engineering-skills90MIT

Identical content appears in 2 other GitHub folders. We show one copy with the highest score.

Database snapshot: 13.11.2026 · package version ad52e49d34f5 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 90python-style
    Python language conventions and code limits - type hints, Any vs object, dataclasses and Protocols, Pydantic at the boundary, exceptions, logging, pathlib, asyncio (TaskGroup, timeouts, blocking calls), PEP 8 naming, complexity and size limits. Use when writing or reviewing .py…
  • 90python-coding
    Pythonコードの新規実装・修正・レビュー時に、PEP 8/257/484、型ヒント、docstring、単一責任、可読性を重視した一貫したコーディング方針を適用する。テストはプロジェクトに明記された方針と既存テストの流儀に従い、どちらも無ければpytest準拠で書く。例外、標準ライブラリの慣用、importの構成、設定値と秘密情報の扱いの指針を含む。Pythonのモジュール、クラス、関数、テストを作成または変更する際に使用する。
  • 90python-conventions
    Use when a ticket adds or changes Python code and it must follow the repo's Python conventions — PEP 8, full type hints (PEP 484) checked by mypy/pyright, dataclasses, pythonic idioms, explicit error handling, asyncio and thread safety, ruff-clean, and pytest with coverage via…
  • 100python
    Use when the task is Python itself, in any framework or none: PEP 695 generics, mypy --strict typing, dataclass/Protocol/TypedDict/Enum choices, asyncio.TaskGroup, stdlib idioms, src/ layout + pyproject.toml with uv, ruff+mypy+pytest gate. NOT a FastAPI/ASGI service (that is…
  • 90python-asyncio
    Decide whether asyncio pays off, keep the event loop unblocked, and structure concurrency with TaskGroup and disciplined cancellation. Use when writing async Python or diagnosing a hung, slow, or silently-failing event loop.
  • 100python-async
    Writes and reviews correct asyncio code - structured concurrency with TaskGroup, gather vs create_task decisions, cancellation and timeout handling, bridging blocking code with to_thread, and bounded parallelism - with good/bad pairs for the pitfalls that silently freeze the…

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.