0xbigboss avatar

Python Best Practices

The python-best-practices skill guides developers in writing type-safe, maintainable Python code by applying immutable data structures, discriminated unions, and domain-specific types to prevent invalid states at type-check time. It's for Python developers who want to follow functional programming patterns and enforce correctness through the type system rather than runtime checks. The skill solves the problem of catching logic errors early and avoiding mutation-related bugs by making illegal application states unrepresentable in the code.

skills.sh installs
1.8K
GitHub stars
51
last updated
Jul 14, 2026

Install

$ npx -y skills add 0xbigboss/claude-code --skill python-best-practices --agent claude-code

Installs into .claude/skills of the current project.

Files

Python Best Practices

Follows type-first, functional, and error handling patterns from CLAUDE.md. This skill covers language-specific idioms only.

Make Illegal States Unrepresentable

Use Python's type system to prevent invalid states at type-check time.

Frozen dataclasses for immutable domain models:

from dataclasses import dataclass
from datetime import datetime

@dataclass(frozen=True)
class User:
    id: str
    email: str
    name: str
    created_at: datetime

# Frozen dataclasses are immutable — no accidental mutation

Discriminated unions with Literal:

from dataclasses import dataclass
from typing import Literal

@dataclass
class Success:
    status: Literal["success"] = "success"
    data: str

@dataclass
class Failure:
    status: Literal["error"] = "error"
    error: Exception

RequestState = Success | Failure

def handle_state(state: RequestState) -> None:
    match state:
        case Success(data=data):
            render(data)
        case Failure(error=err):
            show_error(err)

NewType for domain primitives:

from typing import NewType

Sponsors

Details

Repository
github.com/0xbigboss/claude-code
Category
Python

More from 0xbigboss/claude-code

All 22

Recommended

More Python
1nvidia avatarcuopt-numerical-optimization-api-pythonnvidia/skillsSolve LP, MILP, QP (beta) with cuOpt Python API — linear/quadratic objectives, integer variables, scheduling, portfolio, least squares.1.7Kskills.sh installs
2nvidia avatartilegym-cutile-pythonnvidia/skillsExpert cuTile programming assistant. Write high-performance GPU kernels using cuTile's tile-based programming model with proper validation and optimization. Sup1.7Kskills.sh installs
3github avataraws-cdk-python-setupgithub/awesome-copilotSetup and initialization guide for developing AWS CDK (Cloud Development Kit) applications in Python. This skill enables users to configure environment prerequi1.7Kskills.sh installs
4existential-birds avatarpython-code-reviewexistential-birds/beagleReviews Python code for type safety, async patterns, error handling, and common mistakes. Use when reviewing .py files, checking type hints, async/await usage, 928skills.sh installs
5mindrally avatardjango-rest-api-developmentmindrally/skillsComprehensive guidelines for building scalable Django REST APIs with proper architecture, authentication, and performance optimization.900skills.sh installs
6mindrally avatardata-jupyter-pythonmindrally/skillsGuidelines for data analysis and Jupyter Notebook development with pandas, matplotlib, seaborn, and numpy.892skills.sh installs