Write

From markusleben/ha-nova · View interactive version

Write is an AI agent skill from the GitHub repository markusleben/ha-nova. Use when creating, updating, or deleting Home Assistant automations/scripts, or importing, saving, instantiating, or deleting blueprints through HA NOVA Relay.

How to use this skill

Skill file

HA NOVA Write

Scope

Mutations of automation and script configs: create, update, delete,

and revert of a verified update — plus one runtime exception: the paired

immediate service call of a DURATION request and automation.turn_off on an

expiry automation this flow just created (../ha-nova/one-shot-automations.md). Blueprints: read ../write/blueprints.md first.

Bootstrap (once per session)

Read and follow ../ha-nova/session-bootstrap.md. An unreachable Relay answers exit 1 RELAY_ERROR

(then ha-nova setup). Multi-server: --server <name>

on every command but apply; name a non-default server once per response.

Relay Contract

For automations/scripts, this skill sends no raw ha-nova relay config write; blueprints use raw plans:

Draft: full config as one JSON object in a client-private scratch

file, posted byte-exactly.

variables, trigger_variables, script fields evaluate top-down: preserve

key order. Updates pass --id <config_id> from get --config; creates

--create (refuses existing ids and automation draft id). Script keys derive from alias or --id

(script.<key>). Update diff without a before side: item gone, STOP and ask.

Flow

Multi-target logical changes: present the plan first (../ha-nova/write-safety.md → Multi-Target Changes). 2 to 20 automation/script writes or deletes (mixed): plan each, show each Phase 2 preview without its ask, then ha-nova plan batch --plan <id> --plan <id> … in run order and its say; one confirmation, one apply (../ha-nova/batch-safety.md → CLI Batch). With other families in the task: ../ha-nova/grouped-change-set.md.

Input-device remaps: run the capability preflight per ../ha-nova/input-capability-preflight.md before drafting; the write stays blocked while the chosen gesture is only assumed or its evidence conflicts. Repurposing or cleaning up an input additionally runs ../ha-nova/consumer-discovery-preflight.md; incomplete coverage is disclosed, never claimed as "unused".

A one-shot intent ("just today", "tell me when the laundry finishes") takes the self-disabling pattern in ../ha-nova/one-shot-automations.md and skips unsolicited improvement offers — the Suggestion Block and Phase 5. A recovery, watchdog, self-healing, or retry intent reads ../ha-nova/recovery-workflows.md before drafting; the preview names the attempt bound — and the persistent-fault path only where the intent promises watchdog/self-healing continuity: an explicitly one-shot recovery keeps an attempt bound of one.

Every draft follows ../ha-nova/smallest-solution.md.

Phase 1: Resolve

  1. Bare undo-update: plan revert; undo-delete: result's restore verbatim. Update/delete/named revert: ha-nova find (exact entity_id wins; disabled: --include-disabled), then ha-nova get <entity_id> --config. managed: yaml/CONFIG_NOT_FOUND: YAML/package item, ha-nova:yaml-config, never plan write/plan delete. Ambiguity, no match, or an open choice (which garage door): ask one blocking question before any draft, not inside a preview. No second ambiguity question. Correct invalid premises.
  2. Resolve every entity the draft uses with ha-nova find/get. A trigger or condition on a room, floor, or group ("in the living room", HA 2026.7+) takes a purpose-specific one (temperature.crossed_threshold, motion.detected) that get_triggers_for_target/get_conditions_for_target lists for its area, floor, or label, not one sensor's state/numeric_state: ../ha-nova/best-practices.md → Triggers, Conditions, and Targets.
  3. Suggestion candidates per ../ha-nova/smallest-solution.md → Write Suggestion Candidates.

Phase 2: Preview + Confirm

  1. Build the draft. Update: full-replacement merge (base=current, overlay=user changes); never rewrite unrelated structure, aliases, or formatting (key order included). Treat notification copy as user-authored content: preserve notification titles, messages, templates, metadata; rename/timing changes must not restyle, relocalize, or restructure existing text, and requested wording changes change only the requested copy. A create gets a one-sentence description. New or explicitly edited notification actions follow the canonical contract ../ha-nova/mobile-notification-composition.md. Its recurring-workflow INTENT classification is not so limited: it runs before the write preview on EVERY recurring-workflow write — existing notification actions and trigger-only edits included, their payloads staying byte-for-byte untouched — and may add an exception-only Suggestion Block item.
  2. Scope: draft only what was asked; never rewrite the name, alias, or description unasked, even one quoting the old value (../ha-nova/smallest-solution.md rule 7).
  3. Suggestions + Pre-Write Checks (skip for delete and revert):

Track findings by check type for dedup in Phase 4, except R-18.

  1. Plan: ha-nova plan write (delete/revert: plan delete|revert). Exit 3: stored plan, plan.confirm natural|code. Exit 0 (none): no preview or ask; apply per next_step. A draft notice: add the in-between state it names to from: (../review/checks.md R-31) and plan again. Exit 4: CONFIG_NOT_UI_MANAGED → ha-nova:yaml-config; CONFIG_ID_IN_USE → check earlier apply first, never duplicate; otherwise automation: omit --id, script: ask another name, --id <new> --create; NO_UNDO_SNAPSHOT → nothing revertible; REVERT_UNSUPPORTED → helper checkpoint, specify --target <config_id> or ha-nova:helper. Delete exit 5: absent. Revert exit 2 REVERT_DRIFT: changed since verified update, nothing planned; show live config, ask desired change.
  2. Preview (fixed shape: ../ha-nova/write-safety.md):
  1. Confirmation: the CLI decides — plan.confirm none → apply; natural → show the preview and wait for the user's reply; code → follow say/next_step (window, phone, form, or chat code), never a menu. A duration pair takes its stricter plan's confirmation for both halves. Relay say and add no other reason; never cite, link, or name this skill or any HA NOVA rule file. A code counts only as a reply that is only the code, after the preview. After a "yes" to a code plan, repeat say's note and code block. Never pass a code they did not type. Pre-preview consent is draft-only; a changed draft needs a new plan and preview. An answer to a clarifying question is never a confirmation: end the turn with each new or changed plan's preview (except Phase 3 step 4's natural-confirmation duration call re-plan with action and tier unchanged).

Phase 3: Apply + Verify

  1. ha-nova apply --plan <id> (a plan.code: --confirm <the user's exact text> before --plan; else per next_step). Exit 2: the live config changed since the preview, nothing written; show the new diff and ask again. Never retry after exit 6 or 7.
  2. verified = the read-back equals the planned body (content and variables/fields order), Home Assistant loaded it, the registry entity is live; unverified says why in verification[].note or .observed (not loaded in time: saved, but whether it runs is unknown; say so); exit 7: relay say, then read ha-nova get <entity_id> --config and name it; before_config in the result is the way back. An undo notice: the update is not revertible; say so. Do not report destructive success until verification proves the target is gone.
  3. Deletes: the CLI saves the pre-delete config snapshot (snapshot in the result). SNAPSHOT_FAILED deleted nothing: offer pruning the snapshot store, a full safety backup (ha-nova:backup), or proceeding without one; only after the user picks the last, apply [--confirm <code>] --plan <id> --no-snapshot.
  4. Duration requests carry an immediate action too — "sprinkler for 30 minutes" is the expiry automation PLUS the turn-on under one preview (../ha-nova/automation-patterns.md): plan both first (plan write, plan call) for the one preview. Apply and verify the automation, re-check deadline margin and restore value — if stale, disable the armed expiry immediately and remove it through the delete flow before re-previewing. The new automation watches the actuator, so the call plan drifts: re-plan it (plan call) and apply the new plan under the same confirmation only if action and tier are unchanged (a new plan.code: the user types it); otherwise it fails below. VERIFY the immediate action by reading the target back; on any failure — every non-zero exit but CONFIRM_WAITING (rerun per next_step) — disable the automation at once (ha-nova call automation.turn_off <entity_id>) and clean it up through the delete flow before anything is re-previewed. Never hand the immediate half back to the user as a separate step.

Phase 4: Post-Write Review (MANDATORY)

Not via ha-nova:review.

  1. Reviewed config: the draft when verified, else ha-nova get <entity_id> --config. If verification[].entity_id differs from the requested slug, report it — do not silently assume the requested slug won.
  2. Checks: verified → skip what Phase 2 covered, re-run R-18 on the read-back; a differing read-back → full checks per ../review/checks.md → Application. Dedup: findings the user saw in 3b MUST NOT repeat (by check type) — except R-18 still matching the persisted config: report it again as a persisted runtime risk with the reorder fix. Do not auto-trigger or auto-read traces outside an accepted Phase 5 test plan. R-19 follows normal dedup. Actions referencing helpers: always H-01..H-11.
  3. Collision scan: ha-nova get <entity_id> --related on the entities it triggers on and acts on, minus the item itself (3c fail-closed rule); read max 3 related configs.
  4. Localized output (../ha-nova/output-cards.md → Findings, Empty States): Findings real issues; Collision check related items or failed scan ("couldn't check what uses it"); Advisory non-empty only — never print an empty "none" bucket; nothing at all → no review line beyond say. Never emit Questions to consider, Suggestions, or Instant help post-write; never repeat an item across Findings and Advisory. Sole exception: the one-line Replication Line after a verified create; Phase 5's line closes.
  5. Update-Revert: an update (a revert too) lands on the undo stack automatically — reflect the save receipt in the result — the undo receipt (replaced: only this newest update stays revertible; evicted targets are no longer revertible) and offer revert unless its say already names the way back (write-safety → Update-Revert). Creates → cleanup via normal HA NOVA delete flow (preview, its confirmation, absence verification); never promise a code. Deletes → offer restore (one plan + apply), else Home Assistant Backups.

Phase 5: Test Offer (create/update only)

Every saved create/update ends, in the same response as the result's say, with one closing line offering a test preview ("Want a test preview? I'll show which devices would change before anything runs.", localized). Only exceptions: a one-shot or duration intent; a batch or grouped change set (on request); the user stopped these offers this session. An earlier test is no exception. A "yes" asks for the card, never a run (Test Plan Card mechanics: ../ha-nova/test-run.md). Never execute anything unconsented; the choice confirms only that card, and the card confirmation never replaces the typed confirmation. Skip this phase for deletes.

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.

Render Cards per ../ha-nova/output-cards.md. A create summary (or a deleted item's restore) names the item and devices, triggers, conditions, actions (scripts: inputs/steps); mode only if not single, in plain words; ids and the full config only when asked.

Safety

Guardrails

References

Always load:

On demand — read only when the trigger applies:

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.