home-assistant-yaml-style

Applies consistent YAML formatting rules to Home Assistant documentation examples.

9.8k|8.5k|Updated Dec 21, 2014
One-click install
npx skills add https://github.com/home-assistant/home-assistant.io --skill home-assistant-yaml-style
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: home-assistant-yaml-style
Source: https://github.com/home-assistant/home-assistant.io/tree/main/.claude/skills/home-assistant-yaml-style
Command: npx skills add https://github.com/home-assistant/home-assistant.io --skill home-assistant-yaml-style

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Home Assistant documentation contains hundreds of YAML examples for automations, scripts, templates, and configuration snippets, and inconsistent formatting across them confuses readers and complicates reviews. This Skill enforces a single style guide so every YAML example follows the same indentation, quoting, and structural conventions.

Core Features & Use Cases

  • YAML Formatting Rules: Enforces 2-space indentation, true/false booleans, block-style sequences, double-quoted strings, and 80-character line limits.
  • Home Assistant Conventions: Omits default values like mode: single, uses service action targets for entity/area/device IDs, and marks placeholders with capital letters like YOUR_API_KEY.
  • Template Style Guidance: Requires double-quoted templates, helper methods like states() and is_state(), and multi-line splitting for long templates.
  • Use Case: When editing an automation example in the Home Assistant docs, apply this Skill to convert legacy entity_id-in-data patterns into modern target blocks and normalize quoting.

Quick Start

Review this Home Assistant automation YAML example and reformat it to follow the documentation style guide.

Frequently Asked Questions about home-assistant-yaml-style

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I format YAML examples for Home Assistant documentation?

Use 2-space indentation, true/false booleans, block-style sequences, and double quotes for strings. Omit default values like mode: single and empty sections such as data: {}. Keep lines within 80 characters and format examples as if included in configuration.yaml.

How should entity IDs be targeted in Home Assistant service actions?

Use the target block with entity_id, area_id, or device_id keys rather than placing entity IDs at the action level or inside data. The target syntax is the modern, flexible approach and supports combining multiple target types in one action.

Should strings in Home Assistant YAML always be quoted?

Double quotes are preferred, but entity IDs, device classes, platform types, action names, and similar fixed-value identifiers may stay unquoted for readability. Templates must always be double-quoted with single quotes used inside the template expression.

Why use states() instead of the states object in Home Assistant templates?

Helper methods like states(), is_state(), state_attr(), and is_state_attr() avoid errors when an entity is not ready, such as during Home Assistant startup. Accessing the states object directly can raise exceptions in those situations.

When should templates be avoided in Home Assistant YAML examples?

Avoid templates when a pure YAML alternative exists, such as a numeric_state condition instead of a value template. When templates are needed, prefer shorthand style, split long expressions across lines, and space around the filter pipe marker.