Define once with &anchor, reuse with *alias
YAML supports anchors — give a node a name with &name — and aliases — reference it later with *name. The parsed result reuses the same node value, so two anchors-of-the-same-thing produce one logical value (or two copies, depending on the parser's deep-copy policy).
Merge keys (<<:)
Merge keys are a YAML 1.1 extension: <<: *base merges all keys from an anchored map into the current map, with the current map's keys overriding. This is how docker-compose and CI configs share base configuration without duplication.
Heads-up: merge keys are not in YAML 1.2 spec, but PyYAML, ruamel, js-yaml, and most working tools still support them. Treat as 'works almost everywhere; check your parser before relying.'
When to reach for anchors
Two or more nodes that should stay in sync. Without anchors, you have two places to update; with anchors, you have one source of truth. The cost is one extra layer of indirection at read time — worth it once you have repetition.