Skip to main content
skill CX Codex

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.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add siviter-xyz/dot-agent --skill python -a claude-code
Open on GitHub

What 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-code

2Manually: put the files in place

~/.claude/skills/python/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/python/

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.

python Mindrally This skill tells your coding agent how to write Python: PEP 8, type hints, early returns, async for I/O. Useful when the agent edits or generates code in a Python repo. CX Codex +1 983installs python pproenca A skill with 42 Python 3.11+ optimization rules: it steers the agent on async code, data structures and memory use. CX Codex +1 315installs python-pro davila7 A Claude skill that steers Python 3.12+ development: async patterns, typing, profiling, plus uv, ruff, pydantic and FastAPI. 399installs typing-exclusion-worker getsentry Removes Python modules from mypy exclusion lists in pyproject.toml, fixes typing errors, and runs scoped validation. Built for parallel typing debt workers. CX Codex +1 1,600installs fastapi-patterns affaan-m Provides production patterns for FastAPI, including Pydantic v2 schemas, async dependencies, and service layers. Useful when writing or reviewing API architectures. CX Codex +1 4,900installs fastapi-python Mindrally Tells the agent how to write FastAPI code: async I/O, Pydantic v2 models, early returns and router layout. Useful when you build a Python API. CX Codex +1 13,900installs python-testing-patterns Seth Hobson This skill guides Python testing with pytest, fixtures and mocks. Use it when building a test suite or tracking down failing checks. CX Codex 36,943installs temporal-python-testing Seth Hobson Guidance for testing Temporal workflows in Python with pytest, time-skipping, activity mocks, and replay checks. Use it while building workflow tests or investigating failures. CX Codex 10,900installs

From the same set4

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor