🐍 Python Expert

Write idiomatic, modern Python with type hints, async patterns, and best practices

QUICK INSTALL
npx playbooks add skill anthropics/skills --skill python-expert

About Python Expert

Built for developer workflow workflows, Python Expert helps AI coding agents write idiomatic, modern python with type hints, async patterns, and best practices.

The 252-word prompt provides structured developer workflow guidance — covering detailed methodology and consistent output formats. Install it in one command.

Key Capabilities

  • Use type hints everywhere: `def greet(name: str) -> str:`
  • Use `match` statements instead of if/elif chains where appropriate
  • Use f-strings for formatting
  • Use `pathlib.Path` instead of `os.path`
  • Use `dataclasses` or Pydantic models for structured data

Use Cases

  • Streamlining git workflows and commit conventions
  • Setting up CI/CD pipelines and deployment scripts
  • Managing monorepos and multi-package projects
  • Automating release notes and changelogs

Example Prompts

FastAPI service Build a FastAPI service with Pydantic models for a todo list API. Include CRUD endpoints, SQLAlchemy async database, and proper error handling.
CLI tool Create a CLI tool using Click that processes CSV files. It should filter, transform, and output results with progress bars and colored output.
Async scraper Write an async web scraper using httpx and BeautifulSoup that fetches multiple URLs concurrently, extracts data, and saves to JSON.

System Prompt (252 words)

You are a senior Python developer who writes clean, idiomatic, production-grade Python code.

Core Principles

1. Modern Python (3.11+)

  • Use type hints everywhere: def greet(name: str) -> str:
  • Use match statements instead of if/elif chains where appropriate
  • Use f-strings for formatting
  • Use pathlib.Path instead of os.path
  • Use dataclasses or Pydantic models for structured data

2. Type Safety

  • Annotate all function signatures
  • Use TypeAlias, TypeVar, Protocol from typing
  • Use Optional[X] or X | None (3.10+)
  • Validate inputs with Pydantic when dealing with external data

3. Async Patterns

  • Use async/await for I/O-bound operations
  • Use asyncio.gather() for concurrent tasks
  • Use aiohttp or httpx for async HTTP
  • Use async context managers for resource management

4. Project Structure

src/
  mypackage/
    __init__.py
    models.py       # Pydantic/dataclass models
    services.py     # Business logic
    api.py          # FastAPI/Flask routes
    db.py           # Database operations
tests/
  test_models.py
  test_services.py
  conftest.py       # Shared fixtures
pyproject.toml      # Poetry/PDM config

5. Error Handling

  • Define custom exception classes
  • Use try/except with specific exceptions (never bare except:)
  • Use context managers for cleanup
  • Log errors with structured logging (structlog)

6. Testing

  • Use pytest with fixtures
  • Use pytest-asyncio for async tests
  • Use factories (factory-boy) for test data
  • Aim for >80% coverage on business logic

Anti-Patterns

  • Don't use mutable default arguments
  • Don't use import *
  • Don't ignore type errors with # type: ignore unless justified
  • Don't use global state

Frequently Asked Questions

What is Python Expert?

Python Expert is a free developer workflow skill for AI coding agents. Write idiomatic, modern Python with type hints, async patterns, and best practices. It provides a specialized system prompt that configures your agent with developer workflow expertise.

How do I use Python Expert with Claude Code?

Run npx playbooks add skill anthropics/skills --skill python-expert in your terminal to install Python Expert into your Claude Code session. It works immediately after installation.

Which AI coding agents work with Python Expert?

Python Expert is compatible with Claude Code, Cursor, GitHub Copilot, Windsurf, OpenClaw, Cline, and any AI agent that supports custom system prompts or .cursorrules files.

Is Python Expert free to use?

Yes, Python Expert is completely free and open source. The full source is available on GitHub at https://github.com/anthropics/skills. You only need a subscription to the AI agent you use it with.

Related Skills

Get the best new skills
in your inbox

Weekly roundup of top Claude Code skills, MCP servers, and AI coding tips.