How is a wing designed to be stall or spin proof?
It's really two separate questions. In both cases the wing is not alone, it is the whole configuration, especially when it comes to spins.

A stall is unavoidable. At some point the airflow over the wing will start to separate, and if this flow separation is extensive enough to limit the increase in lift with increasing angle of attack (AoA), the wing stalls.

To make stall characteristics benign, the outer wing should still have mostly attached flow to enable the ailerons to correct roll angle. If the stall starts on one wingtip, causing a local loss of lift, the aircraft will roll uncontrollably. The downward movement of the wing tip during the rolling motion increases angle of attack further, thus making the stall unrecoverable. You achieve roll control by using washout at the wingtips and/or by using airfoils with a higher maximum AoA, eg. by using slats on the outer wing.

The second condition is a gradual flow separation, starting from the trailing edge. Old five-digit NACA airfoils had a nasty stall characteristic with flow separation starting from the leading edge, resulting in a sudden drop of lift. This is achieved by designing the upper surface with an appropriate chordwise pressure distribution. Then the loss of lift over AoA will be gradual, giving the pilot the opportunity to recover easily.

In all cases, the tail (or in canards the main wing) needs to remain in the attached flow regime to enable pitch control and pitch damping. In addition, the vertical position of the tail should be slightly lower than the wake from the separated flow, still close enough to have some turbulence hitting the elevator (so that the pilot feels the stall with the stick/yoke), but low enough that the airplane will not enter a deep stall (where the wing is fully separated and the tail in the wake of the wing, which reduces control authority to a point where the pilot cannot pitch down anymore).

Spinning needs a fuselage with some mass along the length. The rotation of this mass at a high AoA produces a pitch-up moment which is needed to stabilize the spin. The tail must be able to produce the remaining pitching moment and a yawing moment to stabilize the spin, but also to end it when the pilot so wishes. For this, it is important that the rudder is not in the wake of the horizontal tail. The deHavilland Tiger Moth has two aluminum strakes ahead of the empennage; without them a stall is unrecoverable because the rudder authority is not sufficient. To end a spin in the F-14, the all-flying tailplanes had to be pulled all the way to their minimum angle of -70°, so they would not obstruct the flow to the two rudders. Only when the pilots would pull, they could end the spin.

Just to be clear: Normally you need to push to end the spin. Especially in gliders with their relatively small rudders and large wing inertia, this will put most of the wing back into the normal flow region, and roll damping will stop the rotation. This ends the inertial pitch-up from the fuselage, and the aircraft can be recovered.

In more fuselage-dominated configurations, you end the spin by applying rudder against the spin direction. This reduces the rotation, reducing the inertial pitch-up and allowing the airplane to recover to normal AoAs.

Other than the stall, a spin is not always possible. Sometimes, especially at forward center-of-gravity locations, the pitch authority will not be sufficient to stabilize the spin. You can stall and apply rudder, but the airplane will only enter a spiral dive. Especially on jets the forward fuselage is a major factor in spins, because it produces a wake at high AoA which stabilizes the spin. Details in the shape of the fuselage will determine if the wake is sufficient to enable spins. This is a complex topic - sorry, but this scope makes it hard to get into more details.