1. Sounds obvious but unless you actually ensure that your chickens are in their coop, the hatch is down and locked, attack is inevitable. Around half of all attacks happen because hens haven't been locked up!! Likewise check that the nesting box flap is locked too.
2. When building your run it helps to have 6ft high sides, buried at least a foot into the ground and splaying outwards. Always build runs from WELDED mesh not chicken wire. Both foxes and badgers have enough strength to bite or rip through chicken wire quite easily. If you've already built your coop or you have a mobile ark then try tip 3.
3. Foxes and badgers avoid humans, so making your coop area smell as human as possible will help enormously. Why not ask your barber or hairdresser for a bag of cut hair which you can stuff into old tights and hang from the run? Human hair stinks! Likewise if you have a family member with smelly feet, hang an old pair of trainers close by. Male urine also helps to mark your territory so either ask any obliging menfolk to relieve themselves around the run perimeter or avail themselves into a bottle which can be distributed afterwards.
4. My favourite tip is to put a cheap battery operated radio into the coop at night, tuned to something chatty like 'Five Live', not a music channel. The sounds of men rabbiting on about sport nearby will deter the keenest predator...either that or bore them to death!
5. If all else fails, it will have to be an electric fence, a little pricey to set up but very effective (as long as you remember to switch it on of course!).