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.
npx agentmods add rules/ckrl/ha-gitops/code-stylegit clone --depth 1 https://github.com/ckrl/ha-gitopsWhat 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 | $0.00000 | $0.00943 |
| Opus 5 | $0.00000 | $0.00472 |
| Sonnet 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 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.
- Свои исключения — в `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.
- yesterday 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 (4 stars, last pushed 3mo 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
repository
Follow AGENTS.md and CONTRIBUTING.md before working in this repository.
cursorrules
Follow AGENTS.md and CONTRIBUTING.md before working in this repository.
backend-python
Cursor rule "backend-python" from coeusyk/inference-x, covering backend python rules, stack assumptions, code style, fastapi conventions and schema conventions.
api-tester
Expert API testing specialist focused on comprehensive API validation, performance testing, and quality assurance across all systems and third-party integrations.
angular-20
This rule provides comprehensive best practices and coding standards for Angular development, focusing on modern TypeScript, standalone components, signals, and performance optimizations.
dev-standard
Apache Superset development standards and guidelines for Cursor IDE.