Derivation of covariant derivative I'm currently doing Introductory QFT and was confused about the origin of the additional terms in the covariant derivate. My understanding is as follows:
If we begin with the Dirac Lagrangian describing a free fermion:
\begin{equation}
\require{cancel}
L = \bar{\psi}(i\cancel{\partial}-m)\psi,
\end{equation}
where $\bar{\psi} = \psi^{\dagger}\gamma^0$ is the anti-fermion spinor and m is their mass. I believe that we want to describe a world with massless vector bosons so we require local symmetry, meaning I want the spinors to transform as:
$$\psi (x) \rightarrow e^{i\alpha (x)} \psi (x)$$
where $e^{i\alpha (x)}$ is a representation of a unitary transformation as they describe quantum transformations. If $\alpha$ didn't depend on x, then applying the unitary transformations would allow the exponential to pass through the derivative and thus give a global symmetry, however now it does act on the exponential so we want to promote the partial derivate to another kind of derivative which leaves it invariant under unitary transformations:
$$U^{\dagger}D_{\mu}U = D_{\mu}.$$
The only form of the covariant derivative which has this property is:
$$\partial_{\mu} \rightarrow D_{\mu} = \partial_{\mu} + ieA_{\mu} (x)$$
My question is where does this particular form of $D_{\mu}$ come from and how to we derive it?
 A: To make the lagrangian local gauge invariant you need to add a gauge field. The interaction could take any form so long as it satisfied the invariance. That one is just the simplest, nothing else.
A: I can provide you with the motivation (it doesn't make sense to say "derivation" as that would imply we already know what the object is exactly) of this covariant derivative in the context of the Klein-Gordon equation. You can try to think about how it would be in the context of the Dirac equation (hint: it's the same idea!)
From special relativity, we know that in the presence of an electromagnetic field, the 4-momentum is given by
$$
p^{\mu} = P^{\mu}+qA^{\mu}
$$
where $P^{\mu}$ are the components of the 4-momentum in the free case and $A^{\mu}$ are the components of the electromagnetic 4-vector.
Now, apply Einstein's energy relation $E^2=\mathbf{p}^2c^2+m^2c^4$ which can be rewritten as $(P^{0})^2-\mathbf{p}^2=m^2c^2$ where $P^{0}=E/c$ is the timelike component of the free 4-momentum. With the Minkowski metric, we then have:
$$
P^2 = (p-qA)^2 = m^2c^2
$$
Using index notation:
$$
(p_{\mu}-qA_{\mu})(p^{\mu}-qA^{\mu}) - m^2c^2 = 0
$$
Now, to turn this into a (relativistic) equation of quantum mechanics, we assign to each observable an operator
$$p_{\mu} \rightarrow i\hbar \partial_{\mu}$$
$$A_{\mu} \rightarrow A_{\mu}$$
and apply them on a "wavefunction" $\varphi(x^{\nu})$ as follows:
$$
\left((i\hbar \partial_{\mu}-qA_{\mu})(i\hbar \partial^{\mu}-qA^{\mu}) - m^2c^2 \right) \varphi(x^{\nu})
$$
We now define $i\hbar D_{\mu} = i\hbar \partial_{\mu}-qA_{\mu}$ as the covariant derivative so that the Klein-Gordon equation can be written as
$$
(\hbar^2 D_{\mu} D^{\mu}+m^2c^2)\varphi(x^{\nu}) = 0
$$
The reason it is defined this way is to mirror the Klein-Gordon equation in the free case: $(\hbar^2 \partial_{\mu} \partial^{\mu}+m^2c^2)\varphi(x^{\nu}) = 0$.
Of course, you can check that this derivative is indeed covariant by checking for gauge invariance.
A: Well, let's motivate it.
if we have the transformation you gave, $L = {\bar \psi}\left(i\cancel{\partial} -m \right) \psi$ transforms into $L = {\bar \psi}\left(i\cancel{\partial} -m \right) \psi - {\bar \psi}\left({\cancel \partial}\alpha\right) \psi$.  So, the Lagrangian density needs some other term that picks up minus this extra term if it is going to be invariant.  But we already know that the gauge transformation rule from ordinary electromagnetism is $A_{a} \rightarrow A_{a} + \partial_{a}\alpha$, and that the rules for commuting derivatives tell us that $F_{ab} = \partial_{[a}A_{b]}$ transforms into itself for any $\alpha$.  Therefore, we know that if we add a coupling ${\bar \psi}{\cancel A}\psi$ and the kinetic term for the electromagnetic field to our Langrangian density to get:
$$L = {\bar \psi}\left(i\cancel{\partial} -m \right) \psi + \frac{1}{4}F^{ab}F_{ab} + e{\bar \psi}{\cancel A}\psi$$
then we know it is invariant.  At this level, it can then simply be taken to be a convenience to define $D_{a} = \partial_{a} - ieA_{a}$, but quantities like this are known to have deep geometrical reasons, and in this case, it cleans up our Lagrangian by getting rid of that last term for the final result
$$L = {\bar \psi}\left(i\cancel{D} -m \right) \psi + \frac{1}{4}F^{ab}F_{ab} $$
This is of course not a rigorous derivation, and you could probably imagine coming up with other auxiliary fields that would produce the same effect, but we already know about electromagnetism, so it's a natural enough choice. and the coupling $ e{\bar \psi}{\cancel A}\psi$ is multiplied by the real vector valued $A^{a}$ that doesn't act on the Clifford algebra, to get $A_{a}e{\bar \psi}\gamma^{a}\psi$, and if we take $j^{a} = e{\bar \psi}\gamma^{a}\psi$, this suddenly looks a lot like the classical Maxwell interaction term.
A: When you try to  substitute $\phi ' = e^{i\alpha (x)} \phi$ into the partial derivative $\partial _{\mu}\phi$, you get the extra term $\partial _{\mu} \alpha$
$$(\partial _{\mu} + \partial _{\mu} \alpha)\phi'$$
This extra term is the reason the partial derivative is not covariant under the transformation. So we postulate a field $A^{\mu}$ which is defined to have the precise transformation properties to swallow this extra term. It is designed to transform like $A_{\mu}\rightarrow A'_{\mu}-\partial _{\mu} \alpha$. So the term:
$$(\partial _{\mu} + A_{\mu})\phi$$
remains invariant under the simultaneous transformations $\phi '=e^{i\alpha (x)}$ and $A_{\mu}\rightarrow A_{\mu'}-\partial _{\mu} \alpha$. The second transformation rule is defined to swallow the same extra $\partial _{\mu} \alpha$ term that the first transformation spits out, so that the entire thing is covariant.
We then realize that the electromagnetic field four-potential $A_{\mu}$ has this exact gauge transformation symmetry. So we add the elctromagnetic field's kinetic term to get the full interacting theory of the Scaler field and the electromagnetic field.
