Agent Skills › home-assistant/frontend › ha-frontend-types

ha-frontend-types

GitHub

规范 Home Assistant 前端 TypeScript 类型定义,涵盖数据契约验证、现有类型复用、断言处理及 Lit 生命周期类型使用,确保前后端接口一致性与代码质量。

.agents/skills/ha-frontend-types/SKILL.md home-assistant/frontend

触发场景

定义或审查前端 TypeScript 类型 检查数据契约与后端一致性 配置 Lit 组件属性类型

安装

npx skills add home-assistant/frontend --skill ha-frontend-types -g -y
更多选项

非标准路径

npx skills add https://github.com/home-assistant/frontend/tree/dev/.agents/skills/ha-frontend-types -g -y

不安装直接使用

npx skills use home-assistant/frontend@ha-frontend-types

指定 Agent (Claude Code)

npx skills add home-assistant/frontend --skill ha-frontend-types -a claude-code -g -y

安装 repo 全部 skill

npx skills add home-assistant/frontend --all -g -y

预览 repo 内 skill

npx skills add home-assistant/frontend --list

SKILL.md

Frontmatter
{
    "name": "ha-frontend-types",
    "description": "Home Assistant frontend TypeScript conventions. Use when defining or reviewing backend data contracts, optional schemas, shared types, assertions, or Lit lifecycle types."
}

HA Frontend Types

Use this skill for Home Assistant-specific TypeScript contracts and type choices.

Home Assistant Data Contracts

Verify data contracts against the source that owns them, such as Home Assistant Core, Supervisor, a WebSocket handler, or an exported component type. Do not shape a type around assumptions made by its current frontend consumers.

  • Match required, optional, nullable, and defaulted fields to the producer and runtime contract. Preserve optional configuration fields when omission is supported and has defined behavior.
  • Use distinct request and response types when their wire shapes differ.
  • When changing a shared contract, check affected consumers, tests, fixtures, and mocks.

Reuse Home Assistant Contracts

  • Reuse the canonical Home Assistant type when one exists. Define shared contract types in the data or API module that owns them.
  • Reuse types exported by components and helpers rather than reconstructing their payloads. For event types, follow ha-frontend-events.
  • When one domain contract is used across modules, define and export it from the module that owns that contract.

Prefer an existing owning contract. Introduce a frontend-specific type when the frontend shape or boundary genuinely differs.

Assertions

Prefer accurate types and runtime narrowing. Use assertions or TypeScript suppressions at boundaries where the runtime invariant is understood but cannot be expressed cleanly; keep them narrow and explain non-obvious invariants.

Lit Lifecycle Types

For Lit lifecycle methods that receive changed properties, use PropertyValues<this> when the method only needs public reactive properties:

protected willUpdate(changedProperties: PropertyValues<this>) {
  // ...
}

Use unparameterized PropertyValues when the method inspects private or protected reactive properties, which are not keys of this. Do not add assertions solely to retain PropertyValues<this>.

Enforced Baseline

Use import type for type-only imports. This is enforced by the repository ESLint configuration.

版本历史

  • 3c7560a 当前 2026-08-20 08:57

同 Skill 集合

.agents/skills/ha-frontend-components/SKILL.md
.agents/skills/ha-frontend-contexts/SKILL.md
.agents/skills/ha-frontend-demo/SKILL.md
.agents/skills/ha-frontend-events/SKILL.md
.agents/skills/ha-frontend-gallery/SKILL.md
.agents/skills/ha-frontend-lit/SKILL.md
.agents/skills/ha-frontend-query-params/SKILL.md
.agents/skills/ha-frontend-review/SKILL.md
.agents/skills/ha-frontend-styling/SKILL.md
.agents/skills/ha-frontend-testing/SKILL.md
.agents/skills/ha-frontend-user-facing-text/SKILL.md
.agents/skills/ha-frontend-ux-readiness/SKILL.md

元信息

文件数
0
版本
2fdef68
Hash
7723ad49
收录时间
2026-08-20 08:57

首页 - Wiki
Copyright © 2011-2026 iteam. Current version is 2.156.0. UTC+08:00, 2026-11-06 01:28
浙ICP备14020137号-1