Files
supervisor/.github/copilot-instructions.md
T
Jan ČermákandClaude Fable 5.1 c9543e8649 Slim down the agent instructions to essential guidance (#7228)
The instructions file carried product documentation on add-ons, the
update system and backups, general Python advice, a directory tree and
code samples. Every agent session loaded all of it. Current guidance
for agent instruction files is a short list of commands and project
specific conventions the agent cannot infer from the code. Restructure
the file into the pull request template rule, development commands,
Python 3.14 syntax notes, testing rules, good practices and the AI
policy. Drop the coverage threshold, which nothing in CI enforces. The
file shrinks from about 2,700 to 1,100 tokens.

Keep the Supervisor specific conventions: relative imports, per-module
const.py, CoreSysAttributes with the sys_* properties, the executor
for blocking calls, api_process with api_validate, exceptions from
exceptions.py and plain test_ functions.

Replace add-on with app throughout and state that add-on is the legacy
term. The code has moved to app naming, so agents must use it in new
code and keep addon only where an existing API field, config key or
class name still carries it.

Adopt the section layout and several rules from the AGENTS.md in Home
Assistant Core that were not in the old file: the pointer to the VS
Code tasks, the note on lazily evaluated annotations, the test rules
on type annotations, usefixtures, branching and parametrization, and
the rules on small try clauses and comments.

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-15 16:01:50 +02:00

4.8 KiB

GitHub Copilot & Claude Code Instructions

This repository contains the Home Assistant Supervisor, a Python 3 based container orchestration and management system for Home Assistant. It manages the Home Assistant Core, app and plugin containers through the Docker daemon and integrates with the host OS through D-Bus.

Pull Requests

  • When opening a pull request, always use the description format from .github/PULL_REQUEST_TEMPLATE.md.

Development Commands

  • Install development dependencies with pip install -r requirements.txt -r requirements_tests.txt.
  • .vscode/tasks.json contains useful commands used for development.
  • Lint and format with ruff check --fix supervisor tests, ruff format supervisor tests and pylint supervisor.
  • Type check with mypy --ignore-missing-imports supervisor/.
  • After finishing a code session, run pre-commit run --all-files to check for linting and formatting issues.

Python Syntax Notes

  • Supervisor officially supports Python 3.14 as its minimum version. Do not flag syntax or features that require Python 3.14 as issues, and do not suggest workarounds for older Python versions.
  • Python 3.14 explicitly allows except TypeA, TypeB: without parentheses. Never flag this as an issue.
  • Python 3.14 evaluates annotations lazily (PEP 649). Forward references in annotations do not need to be quoted — annotations can reference names defined later in the module without quoting them or using from __future__ import annotations. Do not flag unquoted forward references in annotations as issues.

Testing

  • Use pytest -qsx tests/ to run tests, narrowing the path as needed. Tests mirror the supervisor/ module layout.
  • Write plain test_ functions with pytest fixtures. Do not add Test* classes, they are considered legacy style in this project.
  • Mock external dependencies (Docker, D-Bus, network calls). The fixtures in tests/conftest.py provide a mocked CoreSys.
  • Ensure all test function parameters have type annotations.
  • Prefer @pytest.mark.usefixtures over arguments, if the argument is not going to be used.
  • Avoid using conditions/branching in tests. Instead, either split tests or adjust the test parametrization to cover all cases without branching.
  • If multiple tests share most of their code, use pytest.mark.parametrize to merge them into a single parameterized test instead of duplicating the body. Use pytest.param with an id parameter to name the test cases clearly.

Good practices

  • Apps are the containerized applications installed from stores. "Add-on" is the legacy term for the same thing. Use "app" in new code, comments and docs, and keep "addon" only where an existing API field, config key or class name still uses it.
  • Use relative imports within the supervisor/ package (e.g. from ..docker.manager import ExecReturn), never absolute from supervisor... imports.
  • Use constants from supervisor/const.py instead of hardcoding values. Module-specific constants go in a per-module const.py (e.g. supervisor/store/const.py).
  • Classes that need system access inherit from CoreSysAttributes and use the self.sys_* properties (sys_docker, sys_homeassistant, sys_host, sys_dbus, sys_bus, sys_config, ...). Access Docker through self.sys_docker, never through the Docker SDK directly.
  • All I/O must be async. Run blocking calls through self.sys_run_in_executor(). Put sync setup in __init__ and async initialization in post_init() or load().
  • Raise the exceptions defined in supervisor/exceptions.py and chain them with from. Wrap D-Bus and Docker exceptions in Supervisor-specific ones.
  • API handlers use the @api_process decorator and validate input with api_validate() from supervisor/api/utils.py. The decorator converts APIError and HassioError into responses, so do not add manual error handling in handlers.
  • When catching exceptions, try-clauses should be as small as possible, i.e. avoid wrapping large blocks of code in a try-clause, and avoid catching exceptions from functions that are not expected to raise them.
  • Keep comments concise. Prefer one short line stating the non-obvious constraint, or no comment at all.
  • Do not add comments that just restate the code on the following line(s). Comments should only explain why (non-obvious constraints, surprising behavior, or workarounds), never what. Never add comments that justify a change by referencing what the code looked like before.
  • Use American English for all code, comments, and documentation.

AI policy

This project follows the Open Home Foundation AI Policy. Autonomous contributions are not accepted: a human must review, understand, and be able to explain every change before it is submitted. Do not open issues or pull requests autonomously, and do not post comments on behalf of a user without their review.