Solution (source code)

= Solution

Use <Minkowski spacetime> signature $(-,+,+,+)$ and write $dot x^\mu=dx^\mu/d\lambda$. The reparametrization-invariant <relativistic charged-particle action> is
$$
\boxed{
S[x]=-mc\int_{\lambda_i}^{\lambda_f}
\sqrt{-\eta_{\mu\nu}\dot x^\mu\dot x^\nu}\,d\lambda
+q\int_{\lambda_i}^{\lambda_f}A_\mu(x)\dot x^\mu\,d\lambda.
}
$$
The first term is $-mc^2\int d\tau$ because
$$
\frac{d\tau}{d\lambda}
=\frac1c\sqrt{-\dot x^2}.
$$

An electromagnetic <gauge transformation> is
$$
A_\mu\longmapsto A_\mu+\partial_\mu\chi.
$$
It leaves the <electromagnetic field tensor> unchanged because antisymmetrized second derivatives commute. The action changes only by
$$
\Delta S
=q\int_{\lambda_i}^{\lambda_f}
\partial_\mu\chi\,\dot x^\mu d\lambda
=q\int_{\lambda_i}^{\lambda_f}\frac{d\chi(x(\lambda))}{d\lambda}d\lambda
=\boxed{q\bigl(\chi(x_f)-\chi(x_i)\bigr)}.
$$
This endpoint term has zero variation for fixed endpoints, which is the <gauge invariance of the charged-particle worldline action>.