composing-semantics-matchers
Installation
SKILL.md
Composing Semantics Matchers — One Matcher, One Error
A SemanticsMatcher is a description string plus a (SemanticsNode) -> Boolean predicate (SemanticsMatcher.kt:26). Compose ships with a rich filter library and three combinators (and, or, not) that produce a single matcher whose error message lists every clause. This skill picks the right factory, composes precise predicates, and replaces brittle assertion chains.
When to use this skill
- The developer wants to find "an enabled Button with text Submit" or any node matching multiple constraints.
- The developer asks how to combine
hasTextandhasClickAction, or how to negate a matcher withnot. - The developer needs to filter by a custom
SemanticsPropertyKey(e.g. a domain-specific role) usingexpectValue/keyIsDefined. - The developer asks about hierarchical matchers like
hasParent,hasAnyAncestor,hasAnyChild,hasAnySibling,hasAnyDescendant. - A test chains multiple
assertIs*calls and the developer wants a single, declarative predicate.
When NOT to use this skill
- The query is "find by tag/text/content description only" — use
../finding-nodes-by-tag-text-content/SKILL.md. - The right node exists but only as a relative — use
../traversing-the-semantics-tree/SKILL.md. - The matcher is fine; only the assertions need rework — see
../../assertions/asserting-node-state-and-text/SKILL.md.