Better understanding of Gauge-Invariance This is a long question and the main points are emphasised in bold.
Consider a non-Abelian SU(N) gauge theory. $t_a $ is an Hermitian
generators of SU(N) so that $$U = e^{i\alpha^a(x)t^a} \tag{1}$$ is an element of
SU(N), where $\alpha^a(x)$ are real. $\phi$ is a scalar field transforming
in the fundamental:
$$\tag{2} \phi(x) \to U(x) \phi(x) $$
Introducing a gauge potential $A^a_\mu$, we can construct a gauge-covariant
derivative:
$$D_\mu \phi = (\partial_\mu - igA^a_\mu t^a) \phi\tag{3}$$
How should $A^a_\mu$ transform to make $\phi^\dagger D_\mu \phi$?

My take on it:

*

*Start by applying $(2)$ to $(3)$:

$$\tag{4} D_\mu \phi = (\partial_\mu -igA^A_\mu t^a) \phi \\= \partial_\mu \left(e^{i\alpha^a (x) t^a} \phi\right) -igA^A_\mu t^a e^{i\alpha^a(x)t^a} \\= e^{i\alpha^a(x) t^a}i \partial_\mu (\alpha^a t^a)\phi - it A^a_\mu t^a e^{i\alpha^a(x) t^a}$$
On the last line, why should the exponential be put on the LHS of the partial differential? After the differentiation by parts, shouldn't it stay on the RHS? Isn't this wrong as these are matrices?

*

*Apply $\phi^\dagger \to \phi^\dagger U^\dagger = \phi e^{-i\alpha^a(x)t^a}$
$$\tag{5} \phi^\dagger D_\mu \phi = \phi e^{-i\alpha^a(x)t^a}e^{i\alpha^a(x)t^a}i \partial_\mu (\alpha^a t^a)\phi - \phi e^{-i\alpha^at^a}igA^a_\mu t^a e^{\alpha^a(x)t^a}\phi\\=\phi \left( i \partial_\mu (\alpha^at^a)\right) \phi - \phi e^{-i\alpha^at^a}igA^a_\mu t^a e^{\alpha^a(x)t^a}\phi $$
How do I transform $A^a_\mu$ to bring $(5)$ back to $\phi^\dagger D_\mu \phi$
Is my transformation for $\phi^\dagger$ correct?
 A: I thought I might add some context to this question and generalise this to the general case for an arbitrary non-Abelian Lie group. You might be pleased to know there is a standard set of transformations one has for each type of field that pops up in our theory.
Suppose we are working in standard $\mathbb{ R } ^ {1, 3 } $ spacetime with the Minkowski metric, and are looking at theories with a gauge symmetry given by a Lie group $ G $, with a corresponding Lie group $ \mathcal{L} ( G ) $. Also suppose that our representation of the Lie group is given by $ R : G \to \text{Mat} _ n ( \mathbb{ C } ) $. Let the associated representation of the Lie algebra be denoted by $ D : \mathcal {L } (G ) \to \text{ Mat } _ n (\mathbb{ C } ) $, where $ n $ is the dimension of our representation space.
Then, in non-Abelian gauge theory, we have that our scalar field is actually a map from this spacetime to the representation space of our Lie group. In other words,
$$ \phi : \mathbb{ R } ^ { 3 , 1} \to V $$ and under a transformation of some element $ g \in G $ which is generated by the element $ X  \in \mathcal{ L } ( G ) $, we have that our scalar field transforms as
$$ \phi \to R ( g ) \phi = \exp \left( D ( \epsilon X ) \right) \phi \implies \delta \phi = \epsilon D(X) \phi  $$
Our vector field $ A _ \mu $ in the covariant derivative is in fact a map from our spacetime to our Lie algebra, and infinitesimally the change is given by
$$ \delta A _ \mu  = - \epsilon \partial _ \mu X + [ X , A_\mu ] $$
Now you should find that, if we define our covariant derivative as
$$ D_\mu  = \partial _ \mu + D ( A _ \mu ) $$ then after a bit of computation you will always find that under an infinitesimal transformation we have that our covariant derivative of the scalar field is given nicely (and what we want) as
$$ \delta ( D _ \mu \phi ) = \epsilon D ( X ) \phi $$
