To master large rule sets in ontologies and other logic-based specifications, the ability to divide them into components plays an important role. While a naive approach treats the rule sets as black-box components and composes them via combinators, their relationships are usually so complicated that this approach fails to be useful in many scenarios. Instead, the components should be “opened” before composition. The paper presents several such “gray-box composition” techniques, namely fragment-based genericity and extension, inline template expansions, semantic macros, and mixin layers. All approaches help to structure large ontologies and rule-based specifications into fine-grained components, from which they can be built up flexibly.