We develop a new approach for characterizing $k$-primitive matrix families. Such families generalize the notion of a primitive matrix. They have been intensively studied in the recent literature due to applications to Markov chains, linear dynamical systems, and graph theory. We prove, under some mild assumptions, that a set of $k$ nonnegative matrices is either $k$-primitive or there exists a nontrivial partition of the set of basis vectors, on which these matrices act as commuting permutations. This gives a convenient classification of $k$-primitive families and a polynomial-time algorithm to recognize them. This also extends some results of Perron--Frobenius theory to nonnegative matrix families.