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.

referencesimports.md

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

Imports Style Guide

General Rules

  • Source code (src/): use relative imports. from ..agents.llm_agent import LlmAgent
  • Tests (tests/): use absolute imports. from google.adk.agents.llm_agent import LlmAgent
  • Import from the module, not the package. from ..agents.llm_agent import LlmAgent, never from ..agents import LlmAgent. Importing through __init__.py inside the framework creates import cycles and forces the package to eagerly load unrelated modules.
  • CLI package (cli/):
    • Treat it as an external package.
    • Use relative imports for files within cli/.
    • Use absolute imports for files outside cli/.
    • Dependency direction: cli/ may import from the rest of the codebase; nothing outside cli/ may import from it. scripts/compliance_checks.py fails the commit on any from ...cli... import ... outside the package.

One name per line

isort's google profile puts every imported name on its own line, so from typing import Any, Optional becomes two lines. Ordering is case-insensitive and does not group by type, which is why PrivateAttr sorts after model_validator:

from typing import Any
from typing import Optional

from pydantic import BaseModel
from pydantic import Field
from pydantic import model_validator
from pydantic import PrivateAttr

Three groups, blank-line separated: standard library, third party, then relative. In tests, google.adk sorts into the third-party group (known_third_party in pyproject.toml), alongside google.genai and pytest.

Don't wrap a long import

The 80-character limit does not apply to imports: isort is configured with line_length = 200 and pyink leaves import lines intact. A long from ... import ... stays on one line — the codebase has no parenthesized from-imports. Adding parentheses or a line break will be reverted by the next format run.

TYPE_CHECKING Imports

Use TYPE_CHECKING for imports needed only by type hints, to avoid circular imports at runtime:

from __future__ import annotations

from typing import TYPE_CHECKING

if TYPE_CHECKING:
  from ..agents.invocation_context import InvocationContext

This works because from __future__ import annotations makes annotations strings (deferred evaluation), so the import is never needed at runtime.

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