python · siviter-xyz — Claude Code skill: Python coding rules
Gives the agent one set of Python conventions: typing, dependency injection, module and test layout. Useful when edits land in an existing codebase.
npx skills add siviter-xyz/dot-agent --skill python -a claude-codeWhat python does
The skill loads as a set of guidelines the agent reads before touching Python code. It covers design, style, type annotations, architecture, testing and the order of implementation. On design it asks for DRY, KISS and SOLID, functional methods where they fit, classes for stateful behaviour, and composition through Protocol classes instead of inheritance.
The typing section is concrete: dict and list over typing.Dict and typing.List, str | None over Optional[str], and from __future__ import annotations at the top of annotated files. Dependencies go in through constructors or methods, one service class per module, and environment access lives in environment.py as one method per variable, like api_key() for API_KEY.
For data models it points at Pydantic v2 — schemas, validation, configuration. Tests run on pytest with pytest-mock, shared fixtures in conftest.py, a directory layout mirroring src/, and a TestFoo class for def foo(). If your repo already has a workflow, spec-first or TDD, the skill says to follow that instead of overriding it. Two reference files ship alongside: references/uv-scripts.md and references/uv-monorepo.md, covering uv and Hatch setups.
What it helps with
- make type hints consistent across a codebase
- move dependencies into constructors instead of globals
- collect environment variable access in one file
- rewrite tests around pytest fixtures in conftest.py
- define request and response schemas with Pydantic v2
Example prompts for the agent
- add a new FastAPI endpoint and define the schemas with Pydantic v2
- refactor this module to inject dependencies through the constructor and define the interface as a Protocol
- write pytest tests for this class and move the fixtures into conftest.py
How to install python
1Skills CLI (Vercel)
npx skills add siviter-xyz/dot-agent --skill python -a claude-code2Manually: put the files in place
~/.claude/skills/python/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/python/
1Skills CLI (Vercel)
npx skills add siviter-xyz/dot-agent --skill python -a codex2Manually: put the files in place
.agents/skills/python/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add siviter-xyz/dot-agent --skill python -a cursor2Manually: put the files in place
.cursor/skills/python/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install siviter-xyz/dot-agent python2Manually: put the files in place
.github/skills/python/SKILL.md1Skills CLI (Vercel)
npx skills add siviter-xyz/dot-agent --skill python -a gemini-cli2Platform CLI
gemini skills install https://github.com/siviter-xyz/dot-agent --path skills/pythonManually: put the files in place
.devin/skills/python/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add siviter-xyz/dot-agent --skill python -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about python
How do I install the python skill in Claude?
Run npx skills add siviter-xyz/dot-agent --skill python -a claude-code. The skill file then sits at ~/.claude/skills/python/SKILL.md.
What does the python skill do?
It hands the agent rules for writing and editing Python: design, type annotations, architecture and tests. The agent applies them whenever it works on Python files.
Which tools does the skill rely on?
It uses pytest and pytest-mock for tests, and Pydantic v2 for data models. Separate reference files cover uv and Hatch.
Source text
SKILL.md · MIT
--- name: python description: Python development guidelines and best practices. Use when working with Python code. --- # Python Guidelines Standards and best practices for Python development. Follow these guidelines when writing or modifying Python code. ## Design Principles Apply DRY, KISS, and SOLID consistently. Prefer functional methods where relevant; use classes for stateful behavior. Use composition with Protocol classes for interfaces rather than inheritance. Each module should have a single responsibility. Use dependency injection for class dependencies. ## Code Style - **Naming**: Descriptive yet concise names for variables, methods, and classes - **Documentation**: Docstrings for all classes, functions, enums, enum values - **Type hints**: Use consistently; avoid `Any` unless necessary - **Imports**: Avoid barrel exports in `__init__.py`; prefer blank files ## Type Annotations - Use `dict`, `list` instead of `typing.Dict`, `typing.List` - Use `str | None` instead of `Optional[str]` - Include `from __future__ import annotations` at top of files with type hints - Prefer built-in types over typing module equivalents ## Architecture ### Dependency Injection - Always inject dependencies via constructors or methods when using classes - One service class per module (interface and class models allowed in addition) - Use Protocol classes to define interfaces for dependency injection and testing ### Module Organization - Each module focuses on one concern with clear boundaries - Extract reusable methods to avoid duplication - Design for reusability across contexts ### Environment Variables - Use an `environment.py` file with individual methods per variable (e.g., `api_key()` for `API_KEY`, `database_url()` for `DATABASE_URL`) - Co-locate all environment access in one place per package for easier mocking in tests ### Data Models - Use Pydantic v2 for schemas, validation, and data models - Leverage Pydantic's type validation, serialization, and configuration management - Use Pydantic models for API request/response schemas, configuration objects, and data transfer objects ## Testing ### Structure - Tests mirror `src/` directory structure - Test methods start with `test_` - Use test class suites: for `def foo()` create `class TestFoo` - Keep names concise, omit class suite name from method - Always check for appropriate unit tests when changing code ### Quality - Use AAA (Arrange, Act, Assert) pattern - Tests should be useful, readable, concise, maintainable - Avoid tests that create massive diffs or become burdensome ### Tools - Prefer `pytest` over `unittest` - Use `pytest-mock` for mocking - Use `conftest.py` for shared fixtures - Use `tests/__test_<package_name>__` for shared testing code ## Implementation When implementing Python code: - Ensure code passes type checking and tests before committing - Group related changes with tests in atomic commits - Check for existing workflow patterns (spec-first, TDD, etc.) and follow them ## References - For adhoc Python scripts in uv-managed projects, see `references/uv-scripts.md`. - For monorepo-specific patterns using uv and Hatch, see `references/uv-monorepo.md`.
© siviter-xyz · MIT · siviter-xyz/dot-agent
Similar skills
All skills for Programming languages →python by other authors comes first.