In this paper we study the security of the key of compact McEliece schemes based on alternant/Goppa codes with a non-trivial permutation group, in particular quasi-cyclic alternant codes. We show that it is possible to reduce the key-recovery problem on the original quasi-cyclic code to the same problem on a smaller code derived from the public key. This result is obtained thanks to the invariant code operation which gives the subcode whose elements are fixed by a permutation in Perm(C). The fundamental advantage is that the invariant subcode of an alternant code is an alternant code. This approach improves the technique of Faugere, Otmani, Tillich, Perret and Portzamparc which uses folded codes of alternant codes obtained by using supports globally stable by an affine map. We use a simpler approach with a unified view on quasi-cyclic alternant codes and we treat the case of automorphisms arising from a non affine homography. In addition, we provide an efficient algorithm to recover the full structure of the alternant code from the structure of the invariant code.