
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-codeInstalls 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- Web Fetch929
- Zig Best Practices388
- Nix Best Practices359
- Tamagui Best Practices290
- Openai Image Gen288
- Go Best Practices272
- Playwright Best Practices266
- Axe Ios Simulator239
- Electrobun Best Practices209
- Tilt196
- Orbstack Best Practices180
- Canton Network Repos157
- Ios Device Screenshot155
- Atlas Best Practices154
- Git Best Practices149
- Git Rebase Sync146
- Testing Best Practices135
- E2e126
- Extract Transcripts122
- React Best Practices3K
- Typescript Best Practices2.9K