python-best-practices
Skill2.7k starsChanged 10 months agoApache-2.0View on GitHub
Pythonic code with modern type hints, dataclasses, async patterns, packaging, and testing
- Installs packages
15 other projects use a version of this.
Trending
Less talk lately.thin dataabout the whole repository
Most recently taken up by
- baekenough/oh-my-customcodetheir own version, first seen Oct 3, 2026
- The-AIOS/aiostheir own version, first seen Sep 24, 2026
- excatt/superclaude-plusplustheir own version, first seen Sep 7, 2026
- amirrezaalasti/codescribetheir own version, first seen Aug 3, 2026
- Madheshvivekanandan/ai-engineering-skillstheir own version, first seen Jul 31, 2026
- tomroberts92/skillstheir own version, first seen Jun 25, 2026
Who's talking about rohitg00/awesome-claude-code-toolkit
- sudosubin/agents.nix“agent-skills.github.rohitg00.awesome-claude-code-toolkit: init at 0.5.0”GitHub · Oct 1, 2026
- uizze/uizze“docs: track Claude Code Toolkit distribution PR”GitHub · Aug 18, 2026
- hslee16/Archy“chore(distribution): submit archy to awesome-mcp-servers and awesome-claude-code-toolkit”GitHub · Jul 25, 2026
- Nexcyfr/nexcy-site“Vague 1D : workflows et templates internes Claude Code core”GitHub · Jun 11, 2026
- taeyeon-Kim/claude-starter-kit“감사 리포트 2026-04-14 (2차): Warning 0건, Info 4건 — Phase 3.8 첫 실행”GitHub · Apr 14, 2026
The biggest 5 of 7 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 7
Talked about on GitHub (7 times).
On GitHub · 7
- Oct 1, 2026agent-skills.github.rohitg00.awesome-claude-code-toolkit: init at 0.5.0 — sudosubin/agents.nix0 reactions
- Aug 18, 2026docs: track Claude Code Toolkit distribution PR — uizze/uizze0 reactions
- Jul 25, 2026chore(distribution): submit archy to awesome-mcp-servers and awesome-claude-code-toolkit — hslee16/Archy0 reactions · 4 comments
- Jun 11, 2026Vague 1D : workflows et templates internes Claude Code core — Nexcyfr/nexcy-site0 reactions · 1 comment
- Apr 14, 2026감사 리포트 2026-04-14 (2차): Warning 0건, Info 4건 — Phase 3.8 첫 실행 — taeyeon-Kim/claude-starter-kit0 reactions
2 more on GitHub
- Apr 13, 2026Audit candidate: rohitg00/awesome-claude-code-toolkit — xiaolai/nlpm0 reactions · 5 comments
- Apr 6, 2026Audit candidate: rohitg00/awesome-claude-code-toolkit — xiaolai/nlpm0 reactions · 2 comments
Used with
Projects with it also use typescript-best-practices, react-best-practices and 2 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
ofershapSkilltypescript-best-practices
Also in 3 projects that use this
OpenAISkillreact-best-practices
React and Next.js performance optimization guidelines from Vercel Engineering. This skill should be used when writing, reviewing, or refactoring React/Next.js code to ensure optimal performance patterns. Triggers on tasks involving React components, Next.js pages, data fetching, bundle optimization, or performance improvements.
Also in 3 projects that use this
VercelSkillfrontend-design
Create distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, artifacts, posters, or applications (examples include websites, landing pages, dashboards, React components, HTML/CSS layouts, or when styling/beautifying any web UI). Generates creative, polished code and UI design that avoids generic AI aesthetics.
Also in 4 projects that use this
MicrosoftSkillskill-creator
Guide for creating effective GitHub Copilot skills (.github/skills/) in this repository. Use when creating a new skill, updating an existing skill, or when asked about skill structure, format, or best practices for the vscode-documentdb project.
Also in 4 projects that use this
Other versions15 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 15
- The-AIOS/aios★ 69same name
- baekenough/oh-my-customcode★ 43same name
- jefflester/claude-skills-supercharged★ 42same name
- excatt/superclaude-plusplus★ 14same name
- cisco-open/ai-harness-toolkit★ 13same name
- arnabdeypolimi/claude_code_setup★ 4same name
- Sanskar015/claude-skills-supercharged★ 3same name
- amirrezaalasti/codescribe★ 2same name
- b12consulting/skills★ 2same name
- medy-gribkov/arcana★ 1same name
5 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository40 other files it gives its agents.
- rules/agents.mdAGENTS.md
- accessibility-wcagSkill
- agentkit-seoSkill
- api-design-patternsSkill
- authentication-patternsSkill
- aws-cloud-patternsSkill
- ci-cd-pipelinesSkill
- claude-memory-kitSkill
- continuous-learningSkill
- database-optimizationSkill
- data-engineeringSkill
- deep-diveSkill
- devops-automationSkill
- django-patternsSkill
- docker-best-practicesSkill
- frontend-excellenceSkill
- git-advancedSkill
- golang-idiomsSkill
- graphql-designSkill
- kubernetes-operationsSkill
- llm-integrationSkill
- manage-skillsSkill
- mcp-developmentSkill
- microservices-designSkill
- mobile-developmentSkill
- monitoring-observabilitySkill
- nextjs-masterySkill
- performance-optimizationSkill
- postgres-optimizationSkill
- prompt-engineeringSkill
- react-patternsSkill
- redis-patternsSkill
- rust-systemsSkill
- security-hardeningSkill
- springboot-patternsSkill
- styleseedSkill
- tdd-masterySkill
- testing-strategiesSkill
- typescript-advancedSkill
- websocket-realtimeSkill
The file
We split this skill into the rules it gives an agent
11 rules. 0 are common, 0 are distinctive, and 11 are very specific to this project.
0
Common
Most of the 13 edited versions we read keep these.
0
Distinctive
This author's own choices. Worth a look.
11
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 36
Always type function signatures.
- Very specific: line 59
Use frozen=True for immutable value objects.
- Very specific: line 107
Use httpx instead of requests for async HTTP
- Very specific: line 108
Use asyncio.gather for concurrent tasks, asyncio.Semaphore for rate limiting
- Very specific: line 109
Never call blocking I/O in async functions (use asyncio.to_thread for legacy code)
- Very specific: line 110
Use async with for resource management (connections, sessions)
- Very specific: line 135
Use src layout to prevent accidental imports from the project root.
- Very specific: line 180
Use pyproject.toml for all tool configuration.
- Very specific: line 195
Always use virtual environments.
- Very specific: line 229
Use conftest.py for shared fixtures.
- Very specific: line 282
Never use bare except:. Catch the most specific exception.
“Common” is measured: kept by at least 6 in 10 of the 13 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Python Best Practices
Type Hints (3.12+ Syntax)
# Use built-in generics (3.9+), no need for typing.List, typing.Dict
def process_items(items: list[str]) -> dict[str, int]:
return {item: len(item) for item in items}
# Union with | syntax (3.10+)
def find_user(user_id: int) -> User | None:
...
# Type parameter syntax (3.12+)
type Vector[T] = list[T]
type Matrix[T] = list[Vector[T]]
def first[T](items: list[T]) -> T:
return items[0]
# TypedDict for structured dicts
from typing import TypedDict
class UserResponse(TypedDict):
id: int
name: str
email: str
active: boolAlways type function signatures. Use mypy --strict or pyright in CI. Use type: ignore comments sparingly with justification.
Dataclasses vs Pydantic
Dataclasses (internal data, no validation needed)
from dataclasses import dataclass, field
@dataclass(frozen=True, slots=True)
class Point:
x: float
y: float
def distance_to(self, other: "Point") -> float:
return ((self.x - other.x) ** 2 + (self.y - other.y) ** 2) ** 0.5
@dataclass
class Config:
host: str = "localhost"
port: int = 8080
tags: list[str] = field(default_factory=list)Use frozen=True for immutable value objects. Use slots=True for memory efficiency.
Pydantic (external input, validation required)
from pydantic import BaseModel, Field, field_validator
class CreateUserRequest(BaseModel):
model_config = {"strict": True}
email: str = Field(max_length=255)
name: str = Field(min_length=1, max_length=100)
age: int = Field(ge=13, le=150)
@field_validator("email")
@classmethod
def validate_email(cls, v: str) -> str:
if "@" not in v:
raise ValueError("Invalid email format")
return v.lower()Rule: Use dataclasses for domain models and internal structs. Use Pydantic for API boundaries, config files, and external data parsing.
Async Patterns
import asyncio
import httpx
async def fetch_user(client: httpx.AsyncClient, user_id: int) -> User:
response = await client.get(f"/users/{user_id}")
response.raise_for_status()
return User(**response.json())
async def fetch_all_users(user_ids: list[int]) -> list[User]:
async with httpx.AsyncClient(base_url="https://api.example.com") as client:
tasks = [fetch_user(client, uid) for uid in user_ids]
return await asyncio.gather(*tasks)
async def process_with_semaphore(items: list[str], max_concurrent: int = 10):
semaphore = asyncio.Semaphore(max_concurrent)
async def bounded_process(item: str):
async with semaphore:
return await process_item(item)
return await asyncio.gather(*[bounded_process(i) for i in items])Rules:
- Use
httpxinstead ofrequestsfor async HTTP - Use
asyncio.gatherfor concurrent tasks,asyncio.Semaphorefor rate limiting - Never call blocking I/O in async functions (use
asyncio.to_threadfor legacy code) - Use
async withfor resource management (connections, sessions)
Project Structure
my-project/
src/
my_project/
__init__.py
main.py
models.py
services/
__init__.py
user_service.py
api/
__init__.py
routes.py
tests/
conftest.py
test_models.py
test_services/
test_user_service.py
pyproject.tomlUse src layout to prevent accidental imports from the project root.
pyproject.toml
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[project]
name = "my-project"
version = "1.0.0"
requires-python = ">=3.12"
dependencies = [
"httpx>=0.27",
"pydantic>=2.0",
]
[project.optional-dependencies]
dev = [
"pytest>=8.0",
"pytest-cov",
"pytest-asyncio",
"mypy",
"ruff",
]
[project.scripts]
my-project = "my_project.main:cli"
[tool.ruff]
line-length = 100
target-version = "py312"
[tool.ruff.lint]
select = ["E", "F", "I", "N", "UP", "B", "SIM", "RUF"]
[tool.mypy]
strict = true
[tool.pytest.ini_options]
asyncio_mode = "auto"
testpaths = ["tests"]Use pyproject.toml for all tool configuration. Use Ruff instead of flake8 + isort + black (single tool, 10-100x faster).
Virtual Environments
# Use uv for fast dependency management
uv venv
uv pip install -e ".[dev]"
# Or standard venv
python -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"Always use virtual environments. Never install packages globally. Pin exact versions in a lockfile (uv.lock or requirements.txt generated from pip freeze).
Testing with pytest
import pytest
from unittest.mock import AsyncMock, patch
@pytest.fixture
def user_service(db_session):
return UserService(session=db_session)
async def test_create_user_returns_user_with_hashed_password(user_service):
user = await user_service.create(email="test@example.com", password="secret")
assert user.email == "test@example.com"
assert user.password_hash != "secret"
async def test_create_user_rejects_duplicate_email(user_service):
await user_service.create(email="test@example.com", password="secret")
with pytest.raises(DuplicateEmailError):
await user_service.create(email="test@example.com", password="other")
@pytest.fixture
def mock_http_client():
client = AsyncMock(spec=httpx.AsyncClient)
client.get.return_value = httpx.Response(200, json={"id": 1, "name": "Alice"})
return client
async def test_fetch_user_parses_response(mock_http_client):
user = await fetch_user(mock_http_client, user_id=1)
assert user.name == "Alice"
mock_http_client.get.assert_called_once_with("/users/1")Use conftest.py for shared fixtures. Use pytest.mark.parametrize for test variations. Use tmp_path fixture for file system tests.
Pythonic Idioms
# Unpacking
first, *rest = items
x, y = point
# Comprehensions over map/filter
squares = [x**2 for x in numbers if x > 0]
lookup = {u.id: u for u in users}
# Context managers for resource cleanup
with open(path) as f:
data = f.read()
# Walrus operator for assign-and-test
if (match := pattern.search(text)) is not None:
process(match.group(1))
# Structural pattern matching (3.10+)
match command:
case {"action": "move", "direction": d}:
move(d)
case {"action": "quit"}:
sys.exit(0)
case _:
raise ValueError(f"Unknown command: {command}")Error Handling
class AppError(Exception):
def __init__(self, message: str, code: str):
super().__init__(message)
self.code = code
class NotFoundError(AppError):
def __init__(self, resource: str, id: str):
super().__init__(f"{resource} {id} not found", "NOT_FOUND")
# Specific exceptions, never bare except
try:
user = await get_user(user_id)
except NotFoundError:
return {"error": "User not found"}, 404
except DatabaseError as e:
logger.exception("Database error fetching user")
return {"error": "Internal error"}, 500Never use bare except:. Catch the most specific exception. Use logger.exception() to include tracebacks. Define custom exception hierarchies for your application.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

