AgentSkillsCN

python

使用现代编程模式、uv 命令、函数式优先的设计理念,以及生产优先的最佳实践,开发 Python 应用程序。当您处理 .py 文件、pyproject.toml、uv 命令,或用户提及 Python、itertools、functools、pytest、mypy、ruff、async,或是函数式编程模式时,此技能将助您事半功倍。

SKILL.md
--- frontmatter
name: python
description: "Develop Python applications using modern patterns, uv, functional-first design, and production-first practices. Activate when working with .py files, pyproject.toml, uv commands, or user mentions Python, itertools, functools, pytest, mypy, ruff, async, or functional programming patterns."

Python Development

Functional-first, production-first Python 3.14+ with uv, type safety, immutability.

Activation Triggers

  • .py files, pyproject.toml, uv commands
  • Python, typing, asyncio, pytest, mypy, ruff, dataclasses, itertools, functools

Workflow

code
1. MODEL    -> types, invariants, boundaries
2. COMPOSE  -> pure functions, pipelines, small modules
3. VALIDATE -> parse at edges, return errors early
4. TEST     -> pytest, fixtures, async tests
5. HARDEN   -> ruff + format + mypy + regression tests

Core Principles

  • Functional core, imperative shell
  • Immutability by default; copy-on-write
  • Explicit types and error paths
  • Small composable units
  • Production defaults: logging, config, timeouts, retries

When to Use

  • New or refactored Python modules
  • Async I/O, data pipelines, CLI tooling
  • Type-heavy APIs, validation, parsing
  • Test strategy or flaky tests

When Not to Use

  • Non-Python runtimes
  • Browser E2E tests (use Playwright)

Quick Start

bash
uv init my-project && cd my-project
uv add requests pydantic httpx
uv add --dev pytest pytest-asyncio mypy ruff

uv run python script.py
uv run pytest

Quality Gates

bash
uv run ruff check src/
uv run ruff format --check src/
uv run mypy src/
uv run pytest

Must / Must Not

  • MUST: type hints on public APIs; validate inputs at boundaries; prefer pathlib
  • MUST NOT: mutable default args; bare except; mix sync/async in one call chain

Notes

Core patterns, async examples, and anti-patterns live in reference.md and the cookbooks.

Research Tools

code
# gh search code for real-world examples
gh search code "asyncio.TaskGroup(" --language=python
gh search code "class.*Protocol):" --language=python
gh search code "async with httpx.AsyncClient(" --language=python

References