Awesome-claude-code s1-api-conventions

Python API coding conventions for this BookStore project. Use when writing or reviewing Python code.

install
source · Clone the upstream repo
git clone https://github.com/pgagarinov/awesome-claude-code
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/pgagarinov/awesome-claude-code "$T" && mkdir -p ~/.claude/skills && cp -r "$T/examples/05-skills-n-agents/.claude/skills/s1-api-conventions" ~/.claude/skills/pgagarinov-awesome-claude-code-s1-api-conventions && rm -rf "$T"
manifest: examples/05-skills-n-agents/.claude/skills/s1-api-conventions/SKILL.md
source content

S1 — BookStore API Conventions

Follow these conventions when writing or reviewing Python code in this project.

Data Models

  • Use
    @dataclass(slots=True)
    for all models
  • Store monetary values as
    int
    in cents (e.g.,
    price_cents: int
    )
  • Use
    field(default_factory=list)
    for mutable defaults
  • Type-annotate every field using modern syntax (
    str | None
    , not
    Optional[str]
    )

API Functions

  • All public API functions return
    dict
    (not dataclass instances)
  • Include a
    "status"
    key in mutation responses (
    "created"
    ,
    "updated"
    ,
    "deleted"
    )
  • Use
    snake_case
    with a verb prefix:
    create_book
    ,
    get_author
    ,
    list_books
  • Private helpers start with underscore:
    _to_dict
    ,
    _validate_input

Docstrings

Every public function must have a docstring with:

"""One-line summary.

Args:
    param_name: Description.

Returns:
    Description of return value.

Raises:
    ValueError: When and why.
"""

Error Handling

  • Raise
    ValueError
    for invalid inputs (bad data from the caller)
  • Raise
    KeyError
    for missing resources (not found)
  • Never silently swallow exceptions

Imports

  • Standard library first, then third-party, then local
  • Use absolute imports:
    from models.book import Book
  • No wildcard imports