  We show that the performances of a Stern-Gerlach apparatus can be improved by
using a magnetic field profile for the atomic spin evolution designed through
shortcut to adiabaticity technique. Interestingly, it can be made more compact
- for atomic beams propagating at a given velocity - and more resilient to a
dispersion in velocity, in comparison with the results obtained with a standard
uniform rotation of the magnetic field. Our results are obtained using a
reverse engineering approach based on Lewis-Riesenfeld invariants. We discuss
quantitatively the advantages offered by our configuration in terms of the
resources involved and show that it drastically enhances the fidelity of the
quantum state transfer achieved by the Stern-Gerlach device.
