In this article we generalize the Bohr–Sommerfeld rule for scalar symbols at a potential well to matrix-valued symbols having eigenvalues that may coalesce precisely at the bottom of the well. As an application, we study the existence of approximately flat bands in moiré heterostructures such as strained two-dimensional honeycomb lattices in a model recently introduced by Timmel and Mele.