Solution (source code)

= Solution

Treat the <BRST transformation> $Q$ as an odd graded derivation. In matrix notation the first three transformations are
$$
QA_\mu=D_\mu c,
\qquad
Qc=-\frac{ig}{2}[c,c]_{\mathrm{graded}},
\qquad
Q\psi=igc\psi.
$$
Then
$$
Q^2A_\mu=D_\mu(Qc)-ig[QA_\mu,c]_{\mathrm{graded}}=0
$$
after substituting $Qc$ and using the <Jacobi identity>. Similarly, the two terms in
$$
Q^2\psi=ig(Qc)\psi-igc(Q\psi)
$$
cancel because the ghost components anticommute and only the Lie-algebra commutator survives. Applying $Q$ once more to $Qc$ gives a sum proportional to $f^d{}_{e[a}f^e{}_{bc]}c^ac^bc^c$, which vanishes by Jacobi. Finally,
$$
Q^2\bar c^a=QB^a=0,
\qquad
Q^2B^a=0.
$$
Thus $Q^2=0$ on every field.