I have a Nema 11 stepper motor with a planetary gearbox and think it is a great stepper motor for a project I'm trying to do. One thing I noticed is that the output shaft of the gearbox has some rotary play - I think due to the gears. I need to remove that slack and was thinking of using a torsion spring connected to the stepper case and the adapter which will be mounted on the output shaft of the gearbox. The torsion spring - I think should solve the slack problem. The disadvantage of this is that I wouldn't be able to rotate the stepper motor 360° (which would be ok) but I wanted to ask if there are any alternatives that I could implement.
The problem you are describing (rotary play) is also known as "backlash". There are several approaches to a solution but you could investigate backlash compensation which includes techniques for software solutions. e.g., If there is 0.1 mm of play then add 0.1 mm to the target position when travelling out and subtract 0.1 mm when travelling in.