AgentSkillsCN

python

Python开发标准和工具链偏好。当(1)编写任何Python代码,(2)用pyproject.toml设置Python项目,(3)创建独立的CLI脚本,(4)配置Python工具(ruff、mypy、pytest、nox、uv),(5)审查或重构Python代码,或(6)提供Python最佳实践建议时,可以使用。强制现代Pythonic风格、严格类型提示和uv-based工作流。

SKILL.md
--- frontmatter
name: python
description: Python development standards and toolchain preferences. Use when (1) writing ANY Python code, (2) setting up Python projects with pyproject.toml, (3) creating standalone CLI scripts, (4) configuring Python tooling (ruff, mypy, pytest, nox, uv), (5) reviewing or refactoring Python code, or (6) advising on Python best practices. Enforces modern Pythonic style, strict type hints, and uv-based workflows.

Python Development Standards

Before Writing Any Code

For applications and multi-file projects: Read references/tdd-workflow.md first. Follow TDD with mandatory verification after every change.

For CLI scripts and one-off utilities: Skip TDD workflow. Focus on working code.

Core Requirements

  1. Type hints everywhere - all functions, all parameters, all return types. No Any.
  2. Docstrings on all public interfaces - RST format for Sphinx compatibility
  3. Absolute imports only - never use relative imports
  4. Modern Python idioms - use latest features appropriate for target version
  5. Empty __init__.py - never add anything to __init__.py

Reference Files

Read based on task: