One of the biggest risks while excavating is that of walls collapsing on top of workers. It is almost impossible to predict when an excavated wall will collapse, and therefore all excavations should be considered temporary. With this in mind, steps must be taken to reduce the risk of a collapse.
To dig deep enough, and on an angle of 45 degrees, all the way around and all the way to the bottom of excavation, so as to assure there is no wall that is 90 degrees to the ground. This will greatly reduce the chance of a collapse, because it reduces the amount of weight placed on the soil. And, if by chance a collapse does occur it will be much more minor because gravity is not nearly as strong at 45 degrees compared to 90 degrees.
To reinforce the walls by placing support structures against them.
Any soil removed should be kept at least 3-4 meters away from the edge of the excavation.
Machines should not be near the edge, because of the extra weight and stress placed on the excavation, while there are workers below.
A rescue plan needs to be in place, and rehearsed regularly, incase an accident does occur.