| name | coding-standards |
| description | Python coding standards and best practices for AI coding agents |
| globs | ["**/*.py","pyproject.toml","setup.py","requirements*.txt"] |
Python Coding Standards
A comprehensive collection of Python coding standards and best practices. Designed for AI agents and LLMs to generate high-quality, performant, and maintainable Python code.
Categories
Performance Optimization [CRITICAL]
Apply Python optimization patterns to improve processing speed and memory efficiency.
Async Processing [HIGH]
Efficient asynchronous programming patterns using asyncio.
Design Principles [HIGH]
Software design principles for maintainability and extensibility.
Object-Oriented Programming [MEDIUM]
Best practices for Pythonic object-oriented programming.
Quick Reference
Performance Patterns
result = [x * 2 for x in items]
total = sum(x * x for x in range(1_000_000))
value = config.get("key", default_value)
valid_ids: set[int] = {1, 2, 3}
if item_id in valid_ids: ...
result = ",".join(values)
Async Patterns
results = await asyncio.gather(task1(), task2(), task3())
async with aiohttp.ClientSession() as session:
async with session.get(url) as response:
data = await response.json()
semaphore = asyncio.Semaphore(10)
async with semaphore:
await do_work()
Design Patterns
class Service:
def __init__(self, repository: Repository) -> None:
self.repository = repository
def process(data: Data | None) -> Result:
if data is None:
return Result.empty()
OOP Patterns
@dataclass
class User:
name: str
email: str
class Repository(Protocol):
def get(self, id: str) -> Entity: ...
@property
def full_name(self) -> str:
return f"{self.first} {self.last}"
See Also
- Recommended Tooling - Tools to enforce these standards automatically (ruff, mypy, pytest, pyscn, uv)