coding-standards

Python coding standards and best practices for AI coding agents

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "coding-standards" with this command: npx skills add ludo-technologies/python-best-practices/ludo-technologies-python-best-practices-coding-standards

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.

RuleDescription
perf-list-comprehensionPrefer list comprehensions over loops (1.5-2x faster)
perf-generator-expressionUse generators for large datasets (O(1) memory)
perf-dict-getUse dict.get() for efficient default values
perf-set-lookupUse set for fast lookups (O(1) vs O(n))
perf-str-joinUse join for string concatenation (O(n) vs O(n²))

Async Processing [HIGH]

Efficient asynchronous programming patterns using asyncio.

RuleDescription
async-gatherUse asyncio.gather for independent tasks
async-create-taskProper background task creation
async-context-managerResource management with async with
async-semaphoreLimit concurrency with semaphores

Design Principles [HIGH]

Software design principles for maintainability and extensibility.

RuleDescription
design-philosophyDRY, YAGNI, KISS principles
design-single-responsibilitySingle Responsibility Principle
design-dependency-injectionLoose coupling with dependency injection
design-pure-functionsPrefer pure functions without side effects
design-early-returnReduce nesting with early returns

Object-Oriented Programming [MEDIUM]

Best practices for Pythonic object-oriented programming.

RuleDescription
oop-composition-over-inheritancePrefer composition over inheritance
oop-dataclassUse dataclass for data containers
oop-protocolPrefer Protocol over abstract base classes
oop-propertyUse property instead of getters

Quick Reference

Performance Patterns

# List comprehension (not loops)
result = [x * 2 for x in items]

# Generator for large data
total = sum(x * x for x in range(1_000_000))

# dict.get() with default
value = config.get("key", default_value)

# Set for fast lookup
valid_ids: set[int] = {1, 2, 3}
if item_id in valid_ids: ...

# join for strings
result = ",".join(values)

Async Patterns

# Concurrent execution
results = await asyncio.gather(task1(), task2(), task3())

# Resource management
async with aiohttp.ClientSession() as session:
    async with session.get(url) as response:
        data = await response.json()

# Concurrency limit
semaphore = asyncio.Semaphore(10)
async with semaphore:
    await do_work()

Design Patterns

# Dependency injection
class Service:
    def __init__(self, repository: Repository) -> None:
        self.repository = repository

# Early return
def process(data: Data | None) -> Result:
    if data is None:
        return Result.empty()
    # main logic here

OOP Patterns

# Dataclass
@dataclass
class User:
    name: str
    email: str

# Protocol for interfaces
class Repository(Protocol):
    def get(self, id: str) -> Entity: ...

# Property
@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)

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Coding

coding-standards

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

python-best-practices

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

coding-standards

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

python-best-practices

No summary provided by upstream source.

Repository SourceNeeds Review