HA Integration Reviewer
Review integration code from the perspective of a strict Home Assistant Reviewer.
Prerequisites
| Tool | Type | Required | Install |
|---|
| git | cli | Yes | or git-scm.com |
| gh | cli | No | then (for referencing other integrations) |
| Context7 MCP | mcp | No | npx -y @upstash/context7-mcp
— add to Claude Code MCP settings (for HA developer docs) |
Do NOT proactively verify these tools on skill load. If a command fails due to a missing tool, directly guide the user through installation and configuration step by step.
Review Process
1. Define Review Scope
bash
# 获取待审查的文件(ha-core 使用 dev 分支)
git diff --name-only HEAD~1 # 最近一次提交
git diff --name-only dev # 与 dev 分支的差异(ha-core 主分支)
Or directories/files specified by the user.
2. Launch Inspection Agents in Parallel
Use the Task tool to launch multiple specialized inspections in parallel, see review-workflow.md for details.
Other Agent Environments: The following inspections are independent of each other and can be executed sequentially.
text
Agent 1: Quality Scale 规则检查
Agent 2: 代码风格检查
Agent 3: Config Flow 检查
Agent 4: 测试覆盖检查
Agent 5: 文档与 Manifest 检查
- Quality Scale Validation - Read quality_scale.yaml and verify done rules
- Code Style Check - Compare against copilot-instructions.md
- Config Flow Check - Validate unique_id and test coverage
- Test Coverage Check - Confirm coverage >= 95%
- Documentation Check - Validate strings.json and README
After all inspections are completed, summarize the results to generate a unified report.
3. Dynamically Obtain the Latest Specifications
Do NOT use outdated static documentation, dynamically obtain the latest specifications for each review:
Quality Scale Rules
text
WebFetch: https://raw.githubusercontent.com/home-assistant/developers.home-assistant/refs/heads/master/docs/core/integration-quality-scale/rules/{rule_name}.md
Other Environments: Use
as an alternative.
Coding Specifications
text
WebFetch: https://raw.githubusercontent.com/home-assistant/core/dev/.github/copilot-instructions.md
Other Environments: Use
as an alternative.
Developer Documentation
Use Context7 to obtain the latest Home Assistant developer documentation.
If Context7 MCP is not installed, obtain directly from the GitHub repository:
curl -sL https://raw.githubusercontent.com/home-assistant/developers.home-assistant/refs/heads/master/docs/...
4. Reference Other Integrations
Check implementations of similar integrations in ha-core:
bash
gh api repos/home-assistant/core/contents/homeassistant/components/{integration_name}
5. Summarize Review Report
Output a structured report including:
- Results of each inspection dimension
- Specific issues and their file locations
- Fix suggestions and priorities
Quick Reference for Inspection Checklist
See common-issues.md, which includes:
- Common code style issues
- Log specifications
- Exception handling
- Entities and devices
- Config Flow
- Service registration
- Documentation specifications
Quality Scale Verification Key Points
Use quality-scale-rule-verifier Agent
The ha-core repository provides a dedicated Quality Scale verification agent:
Location:
repos/ha-core/.claude/agents/quality-scale-rule-verifier.md
Invocation Method:
text
# 验证单个规则
"Check if the {integration} integration follows the {rule_name} rule"
# 验证整个等级
"Verify that this integration reaches the {tier} quality scale"
This agent dynamically fetches rule documents and validates implementations, which is more accurate than static checks.
Done Rules
Verify whether the code truly complies with the rule requirements, not just marked as done.
Todo Rules
Check if they are close to completion, and prompt users to consider completing them to improve the Quality Scale tier.
Exempt Rules
Evaluate whether the exemption reason is reasonable and if the rule is truly not applicable to the integration.
Key Review Standards
Asynchronous Programming
- All external I/O must be async
- Blocking operations in the event loop are prohibited
- Use instead of await in loops
Exception Handling
- Narrow the scope of try blocks
- Use to handle input errors
- Use to handle communication failures
Config Flow
- unique_id is set correctly
- 100% test coverage
- UI text specifications (avoid "Click", bold button labels)
Testing
- Located in
tests/components/{domain}/
- Use fixture and snapshot testing
- Coverage >= 95%