Review

From markusleben/ha-nova · View interactive version

Review is an AI agent skill from the GitHub repository markusleben/ha-nova. Use when analyzing, reviewing, auditing, or checking Home Assistant automations, scripts, helpers, scenes, or dashboards for errors, best-practice violations, and conflicts. Do not invoke `ha-nova:read` separately — this skill handles discovery and reading internally.

How to use this skill

Skill file

HA NOVA Review

Scope

Read-only quality review for automations, scripts, helpers, storage scenes, and storage dashboards:

Read-only analysis. Exception: after explicit user confirmation, one Quick-Fix service call may be executed to correct an acute state problem detected during review.

Bootstrap (once per session)

Read and follow ../ha-nova/session-bootstrap.md.

Relay Contract

Relay CLI: ha-nova relay

Target Resolution

If user provides an exact automation/script entity_id (e.g., automation.main_lights), skip search and go directly to config read.

Storage scenes resolve like automations (registry unique_id → GET /api/config/scene/config/<id>; name-based requests search the scene. domain in the compact registry exactly like the automation keyword search). The Editability Guard from ha-nova:scene applies. A scene without registry unique_id is YAML-backed: run SC checks only when that scene's exact YAML is already in context; otherwise STOP and ask for the pasted scene YAML — never emit an empty or inferred review. Storage dashboards resolve by url_path (lovelace/dashboards/list → lovelace/config), and D-02/D-05 additionally read lovelace/resources. Apply the SC/D families from ../review/checks-extended.md; cross-item HX rules run in aggregate/bulk mode OR whenever their required registry/state context is already loaded. A dashboard D-01/D-06 pass normally loads that context, so apply HX-05 to visible card actions without expanding the workset. Flow adaptation for these targets: a SCENE replaces the Step-2 collision scan with a consumer scan (search/related on the scene entity — who activates it) and skips conflict analysis; a DASHBOARD skips Steps 2–4 entirely (no collision surface, no Quick-Fix) — its review is the D config-quality pass plus suggestion synthesis. Output for both: keep the Report shape but include ONLY the sections that ran (findings, consumers for scenes, suggestions, next step) — never render empty collision/conflict/Quick-Fix sections for checks that were intentionally skipped.

For helpers, resolve the family first:

Asked only about broken or missing references: ../ha-nova/bulk-patterns.md → Dead-Reference Sweep before any shortlist or Static Pass; its report is the answer.

If the target config is not already in the thread context, resolve it yourself:

  1. If the user asks for a bulk audit by prefix, domain, area, or label, build a shortlist first using ../ha-nova/bulk-patterns.md.
  1. Search by name using entity registry (compact fields: ei=entity_id, en=name/alias):

Skip this step when step 1 already produced a resolved current review set.

Create <payload-file> with {"type":"config/entity_registry/list_for_display"}.

Then run:

```text

ha-nova relay ws --data-file <payload-file> --jq-file <filter-file>

```

Write <filter-file> with:

```jq

.data.entities[] | select(.ei | startswith("automation.")) | "\(.ei) | \(.en // "unnamed")"

```

Filter the resulting text with the client's native search/filter tool, not shell-specific pipelines.

For scripts: select(.ei | startswith("script.")).

For helpers: (.ei | split(".")[0]) as $domain | select(["input_boolean","input_number","input_text","input_select","input_datetime","input_button","counter","timer","schedule"] | index($domain)).

  1. If the helper might be from the config-entry family, also read:

```text

ha-nova relay ws --data-file <payload-file> --out <entries-file>

ha-nova relay ws --data-file <payload-file> --out <registry-file>

```

with:

Resolve the target by one of:

Build the canonical metadata item:

  1. If multiple matches remain outside an intentional bulk-selector flow: present top candidates (max 5) and ask one clarifying question. Never guess.
  2. For automation/script targets, resolve unique_id (config key) — the entity_id slug and config key differ for UI-created items (see relay-api.md → ID Types):

Create <payload-file> with the final config/entity_registry/get request in one write step, then run:

```text

ha-nova relay ws --data-file <payload-file> --out <registry-file>

ha-nova relay jq -r --file <registry-file> '.data.unique_id'

```

The jq filter quoting above is a POSIX example. On Windows/PowerShell pass the same filter with native argument quoting.

Use that saved-result + -r form for the scalar. Do not create a separate jq file for .data.unique_id, do not strip quotes with shell substitutions afterward, and do not write placeholder payload templates that are rewritten later with perl -0pi, sed -i, or similar commands.

For scripts: use "entity_id":"script.<slug>".

Skip this step for config-entry helpers — entry_id is already the canonical identity.

  1. Read the target:

```text

# Automation:

ha-nova relay core --method GET --path /api/config/automation/config/<unique_id> --jq-file <config-filter-file> --out <target-file>

# Script:

ha-nova relay core --method GET --path /api/config/script/config/<unique_id> --jq-file <config-filter-file> --out <target-file>

# Helper (storage-based family, WS list + filter):

ha-nova relay ws --data-file <payload-file> --jq-file <helper-filter-file> --out <target-file>

```

Preferred: copy ../ha-nova/config-body-filter.jq to <config-filter-file> and use that copied file directly.

If the canonical file is unavailable (flat-copy installs), recreate it with exactly:

```jq

if .ok then .data.body else error("relay error: \(.error.message // "unknown")") end

```

When writing this jq file, paste that jq program body exactly as shown. Do not add extra shell-escape backslashes around the jq interpolation or run a probe variant first.

POSIX shell example only:

```sh

cat <<'EOF' > "$config_filter_file"

if .ok then .data.body else error("relay error: \(.error.message // "unknown")") end

EOF

```

On Windows/PowerShell, use the native file-writing equivalent or copy the canonical file while preserving the exact jq file body. The jq file body must contain exactly that one jq expression and nothing else. Do not add extra single quotes inside the error string. If you print the file for confirmation, do not compare it against a shell-escaped string, do not store the jq program in a shell variable, and do not wrap it in an if [ "$line" != ... ] guard. If the printed contents differ, overwrite the same config_filter_file with the exact canonical line before the first config read; do not create probe variants or alternate filenames, and do not patch the file afterward with in-place rewrite commands.

Write <helper-filter-file> with:

```jq

if .ok then [.data[] | select(.name | test("<search_term>";"i"))] else error("relay error: \(.error.message // "unknown")") end

```

For config-entry helpers, persist the canonical metadata item from step 3 to <target-file> instead of attempting {type}/list.

Then read the file with the native file-reading tool for complete, untruncated access.

  1. After reading the config for an automation or script, extract the primary controlled entity from the config actions (the first significant entity_id being controlled, e.g., light.main_light, climate.main_zone — NOT the automation/script entity itself). Read its current state (for Quick-Fix detection at end of review):

```text

ha-nova relay core --method GET --path /api/states/<controlled_entity_id> --jq-file <state-filter-file> --out <state-file>

```

Write <state-filter-file> with:

```jq

if .ok then .data.body else empty end

```

Skip this step when the current review set contains more than one target.

If no controlled entity found in actions, or state read fails: continue review — Quick-Fix will be skipped.

For standalone config-entry helper review, skip this step entirely. There is no config body with actions to analyze for a primary controlled entity.

If config is already in the thread context (e.g., user pasted YAML):

Do NOT invoke ha-nova:entity-discovery or ha-nova:read — handle everything within this review flow.

Bulk Mode Gate

After target resolution:

Multi-target rules:

Bulk mode rules:

Flow

Pre-Analysis Reference

Before analyzing, consult these sources:

Official HA docs (fetch selectively based on config content — do NOT fetch all for every review):

Only fetch pages relevant to the triggers, actions, and templates found in the config. Cross-check against documented gotchas and constraints — this catches issues beyond the hardcoded checks below.

Verify-before-flag rule: the canonical sequence lives in

../review/checks.md → Verify Before Flagging, because the post-write

phases load that file without this one. Resolve every finding against a source

before reporting it, and flag it when the source confirms the CLAIM you are

making — semantics or risk for behavioral checks, schema invalidity only for

schema-shaped ones.

Do NOT flag valid HA builtins or documented behavior as errors — but "valid"

alone never clears a behavioral finding: much of the catalog describes config

Home Assistant accepts and that still misbehaves.

Step 1: Config Quality Review

Analyze config against the review catalog plus any additional issues found in the official docs. Report only violations found.

Traverse all variables: mappings in the config, not just the top-level block. Include root variables: on the automation/script plus local variables: actions inside choose, if / then / else, default, repeat, and nested sequence blocks.

Rule Catalog

Apply the catalog:

Step 2: Collision Scan

Find other automations/scripts that control the same entities.

For updates, this same scan is also run pre-write as an advisory impact preview (see ha-nova:write Phase 2 Step 3c, Pre-Write Impact, and the ha-nova:helper update flows). The post-write run here stays mandatory and authoritative against the persisted config.

Branch by target family:

  1. Build the candidate entity list:
  1. For the top 3 most significant candidate entities, run search/related:

```text

ha-nova relay ws --data-file <payload-file> --jq-file <filter-file>

```

<filter-file> is the canonical ../ha-nova/search-related-consumers.jq (recreate per ../ha-nova/relay-api.md → Parsing rule on flat-copy installs).

  1. Collect related automations/scripts (exclude current target).
  2. Read configs of related items (max 5 for a single standalone target; keep a tighter shared budget across a bulk workset; post-write scans inside write/helper deliberately use a tighter budget of max 3 related configs). Resolve unique_id first for automation/script targets (see Target Resolution step 5), then:

```text

# Automation:

ha-nova relay core --method GET --path /api/config/automation/config/<unique_id> --jq-file <config-filter-file> --out <related-file>

# Script:

ha-nova relay core --method GET --path /api/config/script/config/<unique_id> --jq-file <config-filter-file> --out <related-file>

```

  1. If no related items found, report "no conflicts for <scanned devices>" in the Conflicts section and skip Step 3. On a filter error, report the collision scan as inconclusive — never as "no conflicts".

Trace Evidence (automation/script reviews only)

Trace ANALYSIS belongs to ha-nova:diagnose: a runtime complaint ("didn't

fire", "wrong behavior last night") is a concrete incident and routes there,

not here. Stay in this skill only when the user asked for an automation or

script review and traces are supporting evidence for a config finding — never

as the answer to a failure question.

In that case:

  1. Prefer the normalized CLI helper fields from ha-nova trace latest <automation_or_script_entity_id> --json, ha-nova trace list <automation_or_script_entity_id> --json, and ha-nova trace get <automation_or_script_entity_id> <run_id> --json; they are enough for run selection, result status, timestamp, item binding, and most review findings.
  2. Inspect raw trace internals only when step-level evidence is required. Raw trace nodes can be arrays of event records; type-check before reading path, result, changed_variables, or error, and avoid large jq projections as the standard path.
  3. Cross-reference trace findings with config quality findings from Step 1
  4. Verify item_id in every trace matches the target's unique_id before attributing results (Evidence below).
  5. Include trace-based findings in the Findings section with a descriptive title (e.g., 🔴 Condition blocked — condition was never met in last 3 runs). Localize at runtime per ../ha-nova/output-rules.md.

Step 3: Conflict Analysis

For each related automation/script, apply the 3-step conflict test:

Step 3a — Action Polarity:

Step 3b — Trigger Temporal Relationship:

Step 3c — Guard Conditions:

Use the known safe/problem patterns from ../review/checks.md when deciding whether a related automation pair is truly benign or a real conflict.

Step 4: Quick-Fix Detection (single-target only)

Skip this step entirely in bulk mode.

After completing Steps 1-3, check if the current entity state (from the earlier <state-file> read) shows an acute, fixable problem.

Qualifies as Quick-Fix:

Does NOT qualify:

If qualified:

  1. Show current state vs expected state
  2. Show exact service call that would fix it
  3. Ask for natural confirmation bound to this exact service-call preview (same tier as ha-nova:service-call; relay the plan's say; Safety below).

On confirmation:

Execute the planned call once, verified by the CLI:

ha-nova apply --plan <id>

Relay the result's say (../ha-nova/output-rules.md → Verb Results); exit 2 means the state changed since the plan — show the new plan and ask again; never retry after exit 6 or 7.

Step 5: Explorative Questions (standalone automation/script only)

Skip this step in bulk mode and for helper reviews.

Run this step only when at least one complexity gate matches:

Ask only non-binding "what happens if...?" questions that go beyond the fixed checklist:

Rules:

Step 6: Suggestion Synthesis (standalone single-target only)

Skip this step in bulk mode.

Derive candidate suggestions only from verified evidence already present in the current review context:

Do not invent intent or removal justification from appearance alone.

Design-intent gate for remove/simplify ideas:

After the gate, rank confident suggestions by intervention depth:

  1. Fix existing
  2. Simplify existing
  3. Extend existing
  4. Add new

Rules:

Output Format

Apply ../ha-nova/output-rules.md: plain words, HA names verbatim; unless asked or names clash, no ids, "entity", modes, Relay/HA URLs, snapshots, raw JSON.

Review output is sectioned, not card-framed; only a Section 8 quick-fix proposal renders as the service-call Preview Card (output-cards.md → Cards) when it proposes a call.

Exception: if a maintainer-provided release-validation or machine-check prompt explicitly pins exact section titles or machine markers, follow that override exactly so automated validation can compare the fixed headings. This exception does not allow internal check codes in normal user-facing prose.

Standard mode

For resolved automation/script/helper targets == 1, keep this 8-section output in the same order every time (scene/dashboard targets omit skipped sections per Target Resolution):

Section 1 — Review target:

Section 2 — Findings:

Section 3 — Collision check:

Section 4 — Conflicts:

Section 5 — Questions to consider:

Section 6 — Suggestions:

Section 7 — Summary:

Section 8 — Instant help:

Aggregate multi-target mode

For resolved targets > 1, return exactly these 6 sections:

Section 1 — Scope:

Section 2 — Summary:

Section 3 — High-Risk Findings:

Section 4 — Repeated Patterns:

Section 5 — Items Checked:

Section 6 — Collisions by Cluster:

Evidence

Each finding's data belongs to the reviewed item (matching entity_id, unique_id, or item_id, never a name alone), is complete (say when a read was truncated or failed), and is current. Unverified findings say so ("this likely means …", "could not verify …"), never in a verified tone.

Safety

Guardrails

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.