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.
git clone --depth 1 https://github.com/ckrl/ha-gitopsWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/rules/ckrl/ha-gitops/code-style)<a href="https://agentmods.dev/rules/ckrl/ha-gitops/code-style"><img src="https://agentmods.dev/badge/rules/ckrl/ha-gitops/code-style/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/rules/ckrl/ha-gitops/code-style"><img src="https://agentmods.dev/badge/rules/ckrl/ha-gitops/code-style.svg" alt="Reviewed on agentmods" width="80" height="20"></a>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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00000 | $0.00943 |
| Opus 5.5 | $0.00000 | $0.00377 |
| Sonnet 5.5 | $0.00000 | $0.00189 |
| Haiku 4.5 | $0.00000 | $0.00094 |
Grade A, and why
code-style 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 1mo ago.
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.
- Свои исключения — в `git_manager.py`: `GitError(Exception)`, опционально `GitAuthError`, `GitConflictError`. Не пробрасывать `subprocess.CalledProcessError` наружу. How it starts
The opening of the file, as written. The whole thing — 99 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Code Style & Practices
Базовые правила
- Python 3.11+,
from __future__ import annotationsв каждом модуле. - Type hints обязательны на всех публичных функциях/методах и dataclass-полях. PEP 604 (
X | None) предпочтительнееOptional[X]. - Имена:
snake_caseдля функций/переменных,PascalCaseдля классов,UPPER_SNAKEдля констант. DOMAIN всегдаha_gitops. - Docstring — короткий, императивно, на английском. Достаточно одной строки для тривиальных методов.
- Не писать комментарии-нарративы (
# increment counter). Комментарии — только про неочевидные намерения, ограничения, edge cases.
Lint & Format
- ruff (lint + import sort) и black (format) — настраиваются в
pyproject.toml. Line length: 100. - Включённые ruff-наборы (рекомендуется):
E,F,W,I,N,UP,B,SIM,ASYNC,PTH,RUF. mypy --strictдляcustom_components/ha_gitops/**— желательно, минимум безAnyв публичном APIGitManager.
Async & I/O
- Все методы
GitManager—async def. Никаких sync-обёрток над async (asyncio.runв продакшен-коде запрещён). - Любой блокирующий вызов (file I/O,
chmod,Path.write_text) — черезawait hass.async_add_executor_job(...). - subprocess — только
asyncio.create_subprocess_execсstdout=PIPE, stderr=PIPE. Никогдаshell=True.
Errors & Logging
- Логгер:
_LOGGER = logging.getLogger(__name__)на уровне модуля. - Свои исключения — в
git_manager.py:GitError(Exception), опциональноGitAuthError,GitConflictError. Не пробрасыватьsubprocess.CalledProcessErrorнаружу. - Wrap внешних ошибок:
raise GitError(f"git push failed: {stderr.strip()}") from exc. - Уровни:
DEBUG— argv git-команды (БЕЗ env),INFO— успешные операции,WARNING— recoverable (нечего push),ERROR— провал операции. - НЕ логировать: содержимое
GIT_SSH_COMMAND, путь к ключу с токенами, stderr с возможными credentials.
Snippets (use these by default)
-
Логгер модуля:
import logging _LOGGER = logging.getLogger(__name__)
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.
- 1mo ago First seen · 99 lines · 0 tokens per session scan A e3658e9a81e5
code-style is a cursor rule published in the GitHub repository ckrl/ha-gitops (5 stars, last pushed 5mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 943 tokens. 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.
Other cursor rules, from other repositories
python-tooling
Python tooling for the add-on source — uv, ruff, pytest, Python 3.13.
python_tests
We use the unit tests to cover internal behavior that can work without the web / backend counterpart. We aim for 95%+ unit test coverage of our Python code in lib/streamlit.
python-llm-ml-workflow-cursorrules-prompt-file
Cursor rules for Python LLM & ML development with workflow integration.
python
Python best practices and patterns for modern software development with Flask and SQLite.
python-containerization-cursorrules-prompt-file
Cursor rules for Python development with containerization integration.
django
Definitive guidelines for writing maintainable, performant, and secure Django applications, emphasizing modern best practices, clear code organization, and efficient patterns.