一键导入
hsem-code-quality
Activate before every commit and PR to run the full HSEM quality gate pipeline — lint, typing, quality checks, and tests.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Activate before every commit and PR to run the full HSEM quality gate pipeline — lint, typing, quality checks, and tests.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Activate at the start of any code change to ensure canonical helpers and patterns are used instead of re-implementing them inline.
Activate after every code change to verify all documentation files that describe the changed behaviour are updated and consistent with the implementation.
Activate when making changes that touch Home Assistant integration surfaces — config flows, entities, translations, services, device info, async patterns, or platform setup.
Activate when writing or reviewing Home Assistant integration code to ensure Bronze and Silver quality tier standards — HA constants, entity patterns, coordinator usage, config flow, and async correctness.
Activate when adding, modifying, or using any Huawei Solar inverter/battery sensor entity in HSEM. Follow the full wiring protocol from const.py through coordinator.py.
Activate when making any change to the HSEM planner layer — engine, cost function, SoC simulation, candidate generation, slot population, MILP optimizer, or safety gates.
| name | hsem-code-quality |
| description | Activate before every commit and PR to run the full HSEM quality gate pipeline — lint, typing, quality checks, and tests. |
Activate this skill before every commit and before opening any PR.
Run these in order. If any fails, fix the issues before proceeding.
tox -e lint)tox -e lint
Runs: isort → black → ruff format → ruff check
This auto-formats and checks for style violations. Fix any remaining lint errors.
tox -e typing)tox -e typing
Runs: mypy type checking. Must pass with 0 errors.
Rules:
disable_error_code is empty in pyproject.toml — never add new suppressions# type: ignore without a comment justifying whytox -e quality)tox -e quality
Runs: pyright + vulture static checks. Must pass with 0 errors.
tox -e py314)tox -e py314
Runs: pytest with coverage on Python 3.14.
For faster iteration during development:
pytest tests/ # all tests
pytest tests/test_module.py # specific file
pytest tests/test_module.py::test_fn # specific test
Hard limit: 30 KB per file in planner/ and utils/. Check before PR:
wc -c custom_components/hsem/planner/*.py
wc -c custom_components/hsem/utils/*.py
If a file exceeds 30 KB, split it before adding more features.
pre-commit run --all-files
abs(x) > 1e-9), pytest.approx() in tests| None, not Optional[...]@override: every method that overrides a base class methodhomeassistant.* → custom_components.hsem.*%-formatting for loggingopen(file, encoding='utf-8') in text modepathlib over os.pathgit --no-optional-locks status
Only intended changes should appear. If any of the four gates fail, fix them before committing. Do not submit a PR with formatting, linting, typing, or test failures.