Skip to content

Reuse and specialize templates

Templates keep a prompt’s wording, actions, and machine contract together. Define a reusable template once, then instantiate it under prompts wherever that same contract applies.

templates:
shop.confirm-fixture:
title: Verify fixture
message: Confirm that the fixture is installed and clamped.
severity: warning
actions:
- id: continue
label: Continue
intent: primary
allow_abort: true
prompts:
left-fixture-check:
template: shop.confirm-fixture
right-fixture-check:
template: shop.confirm-fixture
title: Verify the right fixture
size: lg

Both instances share the template behavior. The second replaces title and size for that configured prompt only.

A template may omit fields and act as a partial base. Every configured prompt must resolve to a title, message, severity, action list, and allow_abort value after inheritance and instance overrides are applied.

A custom template can extend a shipped or custom template:

templates:
shop.manual-tool-change:
template: builtin.manual-tc
title: Manual tool change required
prompts:
manual-tc:
template: shop.manual-tool-change

Template inheritance may have several levels, but each template has only one parent. Unknown parents and inheritance cycles prevent startup.

Overrides are shallow: an overridden field replaces the complete inherited field. This matters most for structured fields:

  • overriding hal replaces the entire inherited HAL contract;
  • overriding actions replaces the entire action list;
  • overriding details replaces the entire detail list; and
  • supplying a locale map for title or message replaces the inherited string or map.

For example, do not add one result pin by overriding only part of hal. Repeat the trigger, value pins, existing result pins, and the new pin as one complete contract. The same principle applies when adding one action to an inherited action list.

Prefer instance overrides for genuinely instance-specific text or size. If several instances need the same override, introduce a named child template so that shared behavior still has one owner.