Agent Skillshome-assistant/frontend › ha-frontend-lit

ha-frontend-lit

GitHub

提供 Home Assistant 前端 Lit 框架的开发规范,涵盖响应式属性、DOM 查询及渲染状态的最佳实践。指导使用特定装饰器处理组件状态和生命周期,确保代码风格一致性和性能优化。

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

Trigger Scenarios

实现 Lit 组件的状态管理 审查 Lit 组件的 DOM 访问逻辑 处理组件生命周期方法 优化渲染行为

Install

npx skills add home-assistant/frontend --skill ha-frontend-lit -g -y
More Options

Non-standard path

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

Use without installing

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

指定 Agent (Claude Code)

npx skills add home-assistant/frontend --skill ha-frontend-lit -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-lit",
    "description": "Home Assistant frontend Lit conventions. Use when working with reactive properties, internal state, DOM queries, lifecycle methods, or render-derived state."
}

HA Frontend Lit

Use this skill when implementing or reviewing Lit component state, DOM access, lifecycle methods, or rendering behavior. Cross-load ha-frontend-types for Home Assistant data contracts, assertions, and lifecycle parameter types.

Reactive Fields

This project currently uses Lit's TypeScript experimental decorators with useDefineForClassFields: false. Match existing declarations and do not introduce standard-decorator accessor syntax unless the project changes decorator mode.

  • Use @property() for public reactive API and @state() for private reactive state.
  • Prefer inferred types for initialized reactive fields when inference preserves the intended type; annotate when widening or an external contract requires it.

DOM Queries

Prefer Lit's @query() or @queryAll() decorators for fixed selectors in the component's render root.

  • Type the decorated field with the narrowest useful DOM or component interface.
  • Keep the field optional when it may be absent at the point of access, including conditional rendering or pre-render lifecycle access.
  • Use a definite assignment assertion only when every call site runs after the node is guaranteed to exist.
  • The optional second argument to @query(), as in @query("#target", true), caches the first query result. Use it only when later renders cannot replace the queried node.
  • Use a direct query when the selector is dynamic or the target is outside the component's render root. Before querying a child, consider whether the required value belongs in parent state or data flow.

Render-Derived State

  • Prefer render-local values for inexpensive structures used only by that render.
  • Assign a render-local value once when repeated evaluation is non-trivial or a local name improves clarity.
  • Keep purely presentational derivations in render(). Use stored state or willUpdate() when the value must participate in lifecycle work, reflection, CSS, or non-render consumers.
  • Use memoizeOne for pure, argument-derived transforms when stable input identity avoids meaningful repeated work. Keep inputs explicit and limited, and do not add caching without a credible benefit over computing the value directly.

References

Version History

  • 3c7560a Current 2026-08-20 08:57

Same Skill Collection

.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-review/SKILL.md
.agents/skills/ha-frontend-styling/SKILL.md
.agents/skills/ha-frontend-testing/SKILL.md
.agents/skills/ha-frontend-types/SKILL.md
.agents/skills/ha-frontend-user-facing-text/SKILL.md

Metadata

Files
0
Version
3c7560a
Hash
95bccd2a
Indexed
2026-08-20 08:57

- 위키
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-25 08:54
浙ICP备14020137号-1 $방문자$