If $\gcd(a,n) = 1$, then $a^{\phi(n)}\equiv 1\pmod n$. Here's a three-step proof.
An integer a is invertible means there's some $a^{-1}$ such that $aa^{-1}\equiv 1 \pmod n$. By cause of Jones p84 lemma 5.1 and the Linear Congruence Theorem, an integer $a$ is invertible modulo $n \iff ax \equiv 1 \pmod n \iff \gcd(a,n) \mid 1 \iff \gcd(a,n) = 1.$
Consider the Abelian group of all positive integers less than $n$ which are invertible modulo $n$. This is dubbed $U_n$ in Jones p85 or $\langle(Z_n',{\times})\rangle$ at Proofwiki.
$ \phi(n)$ simply counts the number of positive integers $a$ coprime to a. So by 1., there are $\phi(n)$ elements in $G$. Tthe order of $G$ is $\phi(n)$.Lagrange's Theorem occasions Order of Group Element Divides ORder of Finite Group. Thence there must be some $k$ such that $a^{k}=1$ where $k$ divides the order of the group $\langle (Z_n',{\times})\rangle$. This is just $\phi(n)$. Let's say $km=\phi(n)$ Then $a^{\phi(n)}=(a^k)^m=1^m=1$.
(1) Is the last paragraph errorless? The last sentence contains equalities, but Proofwiki's last steps are congruences modulo $m$.
(2) What's the ground plan of the proof? It feels 'oracular' to me - how can you preconceive to consider this uncanny Abelian group, and then to use a corollary of Lagrange's Theorem?