--- name: haci-planning description: >- Plan a large change to this Home Assistant custom integration before writing code, or record an architectural decision. Use when asked to "create a plan", "plan this feature", "how should we approach", "propose an architecture", "write an ADR", "document this decision", "record a decision", "supersede a decision", "should we use library X or write our own client", or whenever a change would touch more than about ten files or alter the integration's structure. Covers when a plan is mandatory, the phased plan format, where plans live, and when a decision is worth recording. SYMPTOMS — load this if you are about to: start a refactor spanning more than ten files without confirmation; write a plan whose phases name no files; write one in prose nobody will finish reading; create a planning markdown file in a tracked directory; or make a hard-to-reverse architectural choice without recording why. --- # Plan changes and record decisions ## When a plan is required | Situation | What to do | | ------------------------------------------------ | ------------------------------------------------------ | | Single feature or fix, up to ~8 files | Just implement it completely; no plan needed | | Several independent features | Implement one at a time, suggest a commit between each | | >10 files, or an architectural/structural change | **Write a plan and get explicit confirmation first** | | A choice with long-term consequences | Write the plan _and_ record the decision | Do not start a large refactor because it seems obviously right. The developer decides scope. A plan can only be as good as the requirements under it. If you cannot state the goal back in one sentence, or the phases would encode a guess, run [`haci-grill`](../haci-grill/SKILL.md) first — its brief is the input this plan needs. ## Writing the plan Plans are working documents, not deliverables. Put them in the gitignored directory the project's `AGENTS.md` names for working notes, or ask when it names none. Do not create markdown files elsewhere in the repository without being asked. Structure: ```markdown # Plan: ## Goal ## Current state ## Approach ## Phases ### Phase 1 — - **Files:** `custom_components//coordinator/base.py`, … - **Changes:** - **Verification:** the project's test command on the touched tests, and - **Independently shippable:** yes / no ### Phase 2 — … ## Breaking changes ## Risks and open questions ``` **Write it to be read, not to be complete.** A plan over ~10 files exists to be confirmed before implementation — and a plan nobody finishes reading gets confirmed anyway, which turns that gate into a formality and hands the agent a mandate the developer never actually gave. - Notes, not prose. Fragments beat sentences; drop the grammar that carries no information. - One screen per phase. If a phase needs more, it is two phases. - Do not restate the request, the repository, or the brief. When a [`haci-grill`](../haci-grill/SKILL.md) brief exists, link it — its **Decided** and **Open** lists do not get copied in. - Concision is about wording, never about scope: what you are not doing still has to be written down. Rules that make a plan useful: - Every phase names actual files. "Refactor the coordinator" is not a phase. - Every phase ends in a verifiable state — the test suite passes and Home Assistant still starts. - Order phases so the risky, uncertain part comes early. Discovering the approach is wrong in phase 1 is cheap; in phase 5 it is not. - Keep phases independently reviewable, ideally one commit each. - **Name the seams**, once, under Approach: the shapes one phase fixes and the later ones are then stuck with. Here that is almost always the coordinator's data shape, the API client's exception types, and the unique ID scheme. Together with what you are not doing, this is the part the developer should actually check — a wrong seam is trivial to change while it is a line in a plan, and a migration once three phases have been built on it. - Say what you are **not** doing. Scope creep in a plan is scope creep in the implementation. Present the plan, wait for confirmation, then implement phase by phase. Report deviations from the plan as they happen rather than at the end. ## Recording a decision Some choices outlive the plan: library versus own API client, polling versus push, the shape of `coordinator.data` or `entry.data`, the device model, the unique ID scheme — anything you had to argue yourself into. The bar is all three of: hard to reverse, a genuine trade-off rather than the one sensible option, and surprising to a reader who was not there. **Most sessions produce no record, and that is the normal outcome.** A breaking change before `1.0.0` is not one; its record is the `BREAKING CHANGE:` footer. Where the project keeps decision records, it owns their place and format — its `AGENTS.md` says where — and the index is read before a choice that is hard to reverse, so a new decision does not silently contradict an old one. Where it documents no format, one file per decision: context, the decision, the alternatives and why they lost, and the consequences. **A record is not edited once it lands**, whatever the format: it is the reasoning as it stood that day. Superseding it is a new record that names the old one, and the old one gets nothing but its status changed to superseded, with a link to the new one. Where the project keeps none, put the decision in the plan's **Approach** and offer a home for it rather than creating one. ## Handoff When a plan spans more than one session, leave the plan file in the scratch directory with phase checkboxes updated, so the next session can pick it up without re-deriving the context. **The scratch directory is gitignored**, so it survives the next session but not a fresh clone, a second machine, or a second contributor. Before the work stretches that far, move anything that must outlive it to its real home: a hard-to-reverse choice into a decision record, the project's own vocabulary into its glossary ([`haci-grill`](../haci-grill/SKILL.md)), and everything else into the commit messages of the phases already shipped. What is left in the scratch file should be losable.