Style guide

From Kevin-Liu-01/Agent-Machines · View interactive version

Style guide is an AI agent skill from the GitHub repository Kevin-Liu-01/Agent-Machines. Dedalus style guide quick reference. Key rules for writing code that lasts. Use when writing or reviewing Python code.

How to use this skill

Skill file

Dedalus Style Guide: Quick Reference

Hard Limits

I/O Convention

# I/O function: io: Io as first parameter
async def fetch_user(io: Io, user_id: str) -> User | None: ...

# Pure function: no io parameter
def compute_discount(user: User, cart: Cart) -> Decimal: ...

Types

JSONArray from core.types.json. These are proper recursive RFC 8259 types.

There is no excuse for dict[str, object] or dict[str, Any].

Functions

Split into foo = Foo(x) then result = foo.bar().

Error Handling

No Fallbacks

# Bad: silent, undebuggable
model = request.model or config.default_model or "gpt-4"

# Good: explicit precedence with early returns
def get_model(request, config):
    if request.model:
        return request.model
    if config.default_model:
        return config.default_model
    raise ValueError("model is required")

Naming

Applies in comprehensions too: {field.name: field for field in fields}.

Docstrings (Google style)

async def fetch_user(io: Io, user_id: str) -> User | None:
    """Fetch user from database by ID.

    The returned User is a snapshot; mutations won't persist.

    Args:
        io: I/O capability handle.
        user_id: The unique identifier for the user.

    Returns:
        The User object if found, None otherwise.

    """

Comments

(see column-aligned-fields skill for detailed rules)

Module Organization

naming convention (public vs _-prefixed). We never use import *.

caches. Don't import cross-package deps for simple stdlib needs.

Constants

Testing (Inline)

# --- Tests ---

from inline_tests import test  # noqa: E402


@test
async def rejects_empty_id():
    import pytest  # noqa: PLC0415

    with pytest.raises(ValueError):
        await fetch_user("")

Before Committing

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.