All skills
google avatar

/adk-style

@29933ce
by googlegoogle/adk-python22k stars
4,084

Python style and codebase conventions for ADK (Agent Development Kit): private-by-default file visibility, imports, type hints, Pydantic v2 models, formatting, docstrings, logging, async I/O, file and test layout, and unit test structure. Use when writing or editing ADK source or tests, deciding whether a new file or symbol should be public or private, naming or placing a test file, fixing a formatter, linter, or type-check failure (pyink, isort, ruff, mypy, addlicense, compliance-checks), or asking whether code matches house style. Don't use for reviewing a whole changeset (use adk-review), writing a developer guide or design doc for a code unit (use adk-unit-guide or adk-unit-design), building or configuring agents (use adk-agent-builder), or installing the toolchain (use adk-setup).

Use this Skill: https://skilld.dev/gh/google/adk-python/adk-style

This session only. Nothing lands on disk.

referencesvisibility.md

≈680 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Visibility Style Guide

ADK defines its visibility boundaries with naming conventions and module structure, since Python has no access modifiers to enforce them.

Conventions

1. Module-Private / Internal Files

  • Private by Default: All new .py module files under src/google/adk/ must be private by default (prefixed with _). This is enforced by a pre-commit hook (check-new-py-prefix).
  • Even if a file contains symbols intended for the public API, the file itself must have a leading underscore. The symbols are then exposed via the package's __init__.py.
  • Files intended for internal use within a package or subsystem must also be prefixed with a leading underscore (e.g., _task_models.py).
  • These files should never be imported directly by code outside of the ADK framework.

2. Class and Function Visibility

  • Public: No leading underscore. Intended for use by consumers of the module or package.
  • Internal/Private: Leading underscore (e.g., _private_method()). Intended only for use within the defining class or module.

3. Package-Private (Subsystem Visibility)

Since Python lacks true package-private access, we simulate it by:

  • Not exporting the symbol in the package's __init__.py.
  • Using _-prefixed modules for internal implementation details.
  • Code within the same package can import from these _ modules, but code outside should not.
  • Direct Imports Required: Within the ADK framework, import from the specific module, never from a package's __init__.py — see the imports reference.

4. Public API Export

  • The public API of a package must be explicitly exported in __init__.py.
  • Use __all__: The __init__.py file should define __all__ to explicitly list the symbols that are part of the public API.
  • Only public names (symbols intended for use outside the package) should be imported into __init__.py and listed in __all__.
  • Users should be able to import public symbols directly from the package level, rather than digging into internal modules.

Examples

Exposing a Public Interface

# In src/google/adk/agents/llm/task/_task_agent.py (File is private by default)
class TaskAgent: # Public symbol
    ...

# In src/google/adk/agents/llm/task/__init__.py
from ._task_agent import TaskAgent

__all__ = [
    'TaskAgent',
]

Keeping Implementation Details Private

# In src/google/adk/agents/llm/task/_task_models.py (Internal file)
class TaskRequest(BaseModel): # Public within the module, but module is private
    ...

# In src/google/adk/agents/llm/task/__init__.py
# We DO NOT export TaskRequest here if it is only for internal use within the task package.

Source: SKILL.md on GitHub

No alerts16d3 checks · Risk SAFE
  • Gen Agent Trust Hub16d

    This skill provides comprehensive Python style and codebase conventions for the Agent Development Kit (ADK). It covers visibility, imports, typing, Pydantic models, formatting, and testing, all of which align with standard software development best practices.

  • Socket16d

    No alerts

  • Snyk16d

    Risk: LOW · No issues

Signed by skilld at 29933ce. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub yesterday.

Activeupdated 2 months ago

README badge

README badge for google/adk-python/adk-style