Asking how to survive a hammer is the wrong question. Avoid causing it in the first place. Water is a very rigid fluid, treat it with respect.. 1.Use a VFD or softstart on the pump.
2.Close valves at a controlled rate.
3.Use a surge cushion (accumulator) as a last resort.