  We use a Hilbert series to construct an operator basis in the $1/m$ expansion
of a theory with a nonrelativistic heavy fermion in an electromagnetic (NRQED)
or color gauge field (NRQCD/HQET). We present a list of effective operators
with mass dimension $d\leq 8$. Comparing to the current literature, our results
for NRQED agree for $d\leq 8$, but there are some discrepancies in NRQCD/HQET
at $d=7$ and 8.
