Abstract. In model-driven design, the structure of software is commonly specified by meta-models like uml class diagrams. In this paper we study how graph grammars can be used for this purpose. We extend context-free hyperedge-preplacement—which is not powerful enough for this application—so that rules may not only access the nodes attached to the variable on their left-hand side, but also nodes elsewhere in the graph. Although the resulting notion of contextual hyperedge replacement preserves many properties of the context-free case, it has considerably more generative power—enough to specify software models that cannot be specified by class diagrams alone.