# Python

> Use when: write or review idiomatic, typed, well-structured Python that is easy to test and maintain.

- Skill: `kimtth/python` (Agent Skill)
- Install (CLI): `npx skillmds@latest add kimtth/python`
- Raw SKILL.md: https://api.skillmd.com/api/skills/kimtth/python/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: kimtth (https://skillmd.com/u/kimtth)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/kimtth/python

---


Goal: clear, typed Python that fails loudly and tests easily.

Use for:
- new modules, scripts, or services in Python
- reviewing code for idiom, typing, and structure
- tightening loose, untyped, or side-effect-heavy code

Workflow:
1. Add type hints at function and module boundaries.
2. Prefer pure functions; isolate I/O and side effects.
3. Use dataclasses or pydantic for structured data, not dicts.
4. Handle errors with specific exceptions; avoid bare except.
5. Manage resources with context managers (with-blocks).
6. Verify with pytest, ruff/flake8, and a type checker (mypy/pyright).

Idioms:
- comprehensions and generators over manual loops
- pathlib over os.path string juggling
- f-strings for formatting
- enumerate/zip instead of index bookkeeping
- prefer the standard library before adding a dependency

Rules:
- type the boundaries; let inference handle locals
- never catch Exception just to silence it
- pin dependencies and use a virtualenv or uv
- keep functions small and single-purpose; test behavior

