AgentSkillsCN

python-production-libs

通过pybytesize进行字节大小的解析与格式化。在将字节转换为更易读的人类单位、解析大小字符串,或进行块对齐计算时使用此功能——例如,“将1GB格式化为MiB”、“解析‘500MB’”、“让文件大小更贴近人类阅读习惯”。

SKILL.md
--- frontmatter
name: python-production-libs
description: Production-grade Python library selection and recommendations. Use when choosing libraries for HTTP clients, CLI frameworks, data validation, structured logging, JSON serialization, terminal output, or async patterns—e.g., "which library for HTTP", "modern alternatives to requests", "pydantic vs dataclasses", "structured logging setup".

Python Production Libraries

Purpose

Canonical library choices for production Python. Third-party when stdlib is painful; stdlib when it's good enough.

CRITICAL: Use Context7 for Implementation

YOU MUST NOT rely on pre-trained knowledge for these libraries. APIs change frequently, and stale knowledge causes bugs. No exceptions.

IMMEDIATELY upon loading this skill:

  1. Announce: "Using python-production-libs - will query Context7 for all library implementations"
  2. Load the appropriate reference from this skill to get the Context7 library slug
  3. Query Context7 with the suggested queries BEFORE writing any code
  4. Write code based on Context7 results, NOT memory

Library without Context7 query = implementation based on stale knowledge. Every time.

Example workflow:

code
1. Need HTTP client → Load references/http.md
2. Get slug: /encode/httpx
3. Query: mcp_context7_query-docs(libraryId="/encode/httpx", query="async client timeout configuration")
4. Write code from fresh docs

Core Principle

Stdlib is often outdated or painful (urllib, argparse, unittest, logging for structured output). Our recommendations reflect modern Python production standards—third-party libs that have become the de facto standard.

Quick Reference

DomainUse ThisNot This
HTTPhttpxurllib, requests
Loggingstructloglogging (for structured)
CLItyperargparse
Validationpydanticdataclasses (when validation needed)
JSONorjsonjson (when perf matters)
Terminalrichprint()
Env varspydantic-settingsos.environ
Pathspathlib (stdlib)os.path
Dates/TZzoneinfo (stdlib)pytz
Testingpytestunittest
Asyncanyioasyncio (for library code)

References (Load as Needed)

Load the appropriate reference when working in that domain:

Minimum Production Stack

toml
[project]
dependencies = [
    "httpx[http2]>=0.27.0",
    "pydantic>=2.10.0",
    "pydantic-settings>=2.5.0",
    "structlog>=24.0.0",
    "typer[all]>=0.15.0",
    "orjson>=3.9.0",
    "rich>=13.9.0",
    "python-dotenv>=1.0.0",
    "anyio>=4.0.0",
]

[project.optional-dependencies]
dev = [
    "pytest>=8.0.0",
    "pytest-asyncio>=0.24.0",
    "ruff>=0.9.0",
    "mypy>=1.16.0",
]

YOU MUST

  • Query Context7 BEFORE writing any implementation code - Each reference has the library slug and suggested queries
  • Announce which library you're choosing and why when making recommendations
  • Check this skill before adding new dependencies
  • Use type hints with all these libraries
  • Prefer async variants when available
  • Pin major versions in production

NEVER

  • Rely on pre-trained knowledge - Library APIs change; stale knowledge causes bugs
  • Use requests (use httpx - same API, async support, modern standard)
  • Use argparse for new CLIs (use typer - industry standard)
  • Use stdlib logging for JSON output (use structlog - required for structured logging)
  • Use json for high-throughput (use orjson - 10x faster)