general

A set of core rules for the ha_gitops custom Home Assistant integration. Home Assistant is software for managing smart-home devices, and an integration connects it to a particular system or service.

In plain words
What is it for?
Use it when developing or reviewing the ha_gitops integration, especially its Python, Git, Home Assistant, asynchronous I/O, documentation, tests, and user-facing responses.
Why use it?
It records the project’s required architecture, technology choices, language conventions, and restrictions. This helps prevent changes that would break existing configurations or conflict with the project documentation.

Cursor rule for Cursor

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/ckrl/ha-gitops/general
Clone the repo
git clone --depth 1 https://github.com/ckrl/ha-gitops

Made for: Cursor.

Per session 1,013 This file is loaded in full into every session.
When invoked 1,013 The same file — it is already loaded in full.
Security scan A 1 finding. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.01013 $0.01013
Opus 5 $0.00507 $0.00507
Sonnet 5 $0.00203 $0.00203
Haiku 4.5 $0.00101 $0.00101

Measured yesterday against content hash fc2baeeb8653, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

general scanned grade A with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Runs shell commandslowCapability

Expected in a hook, worth knowing in a rule or an instructions file.

- Использовать `async def` + `await` для всех git/IO операций; никаких `subprocess.run`/`os.system` в продакшен-коде.
.cursor/rules/general.mdc · 46 lines

How it starts

The opening of the file, as written. The whole thing — 46 lines — stays where its author put it; the contents beside it link to each section on GitHub.

General Rules

Important

  • Проект — кастомная Home Assistant integration ha_gitops, распространяется через HACS.
  • Источник истины по архитектуре и требованиям — docs/architecture.md (в репо, нумерация разделов стабильна). Все правила, docstrings, тесты ссылаются на параграфы оттуда. При расхождении кода и architecture.md — документ выигрывает; правки в документ — отдельным шагом, не вместе с кодом.
  • Никаких ссылок на ресурсы вне репо (KB-пути, личные заметки, Notion и т. п.) ни в коде, ни в правилах, ни в комментариях. Репо самодостаточен.
  • DOMAIN компонента: ha_gitops. Менять нельзя — ломает существующие конфиги.
  • Все ответы и обсуждения — на русском; код, идентификаторы, commit messages, UI-строки и логи — на английском.

Core Stack (do NOT switch unless explicitly asked)

  • Python 3.11+ (соответствует HA 2024.1+).
  • Home Assistant Core API (homeassistant.*) — entity-модель, config flow, services.
  • asyncio — все I/O-операции неблокирующие; git-операции через GitPython в asyncio.to_thread; ssh-keygenasyncio.create_subprocess_exec.
  • GitPython + git на PATH — бэкенд с v0.1.8 (manifest.json: GitPython), публичный API GitManager без изменений.
  • pytest + pytest-homeassistant-custom-component — тесты.
  • uv (Astral) — управление venv и зависимостями. Версия Python пинится через .python-version, lockfile — uv.lock. Команды: uv sync --extra dev, uv run pytest, uv add --dev <pkg>. НЕ использовать pip install напрямую и не вводить параллельный Pipfile/poetry.lock.
  • HACS — дистрибуция (manifest.json + hacs.json).

Запрещено вводить без обсуждения: dulwich, pygit2, paramiko, FastAPI/Flask, ORM, БД, Node.js-инструменты.

DO

  • Использовать async def + await для всех git/IO операций; никаких subprocess.run/os.system в продакшен-коде.
  • Логировать через logging.getLogger(__name__); имя логгера — custom_components.ha_gitops.<module>.
  • Идемпотентность: повторный push без изменений = no-op (без пустого коммита). Повторный initialize не падает.
  • Любая git-ошибка → SyncStatus.ERROR в сенсоре + persistent_notification с человекочитаемым текстом, HA не падает.
  • Все пути — pathlib.Path, не str. Конфиг-директория HA — hass.config.path(...).
  • Type hints на всех публичных функциях. from __future__ import annotations в каждом модуле.

Read the full file on GitHub · 46 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 46 lines · 1,013 tokens per session scan A fc2baeeb8653

Subscribe to this mod's changes

general is a cursor rule published in the GitHub repository ckrl/ha-gitops (4 stars, last pushed 3mo ago), licensed MIT. It adds 1,013 tokens to every session, about $0.0051 per session on Opus 5. A static security scan graded it A with 1 finding (runs shell commands). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.