don't be a target: Porcupines do this with personal armor but you could also put elephants in this due to size and squirrels and birds in this due to being hard to catch as they go up trees or fly away. This was my strategy by being a nice person. This attack showed that it is not good enough when I have to deal with intruders.
Build a safe environment: Beavers and muskrats make water their safe place. Burrowing animals make their small entrance to be a security door. Burrowing animals usually have a second exit they can use if necessary. Squirrels make nests in trees to limit the size of potential danger. I can use security bars on windows and have a second exit if needed. Right now I do not have an alternative to the front door. I had my intruder get into a fairly high window so I need security bars on ALL windows but for fire safety (and that second exit) they need to be easy to get out of in a hurry.
Some prairie rodents and antelope rely on having good vision to see danger long before it becomes dangerous (and are daytime animals) and they have watch guards. I will make the doors and windows visible from the street and the alley and have everything well lit ("daytime" at night) and I will install security cameras and door peepholes so all activity can be monitored and recorded.
Some animals make alternative counter-attacks such as skunk stink or porcupine quills or poisonous blood of African striped mice. If I become a volunteer neighborhood watch person, they police know all about me and will go out of their way to get anybody that gives you trouble. I can use those help buttons that you can wear so help will be quick, I can carry pepper spray and I can learn martial arts to give perpetrators more then they bargain for.
Some characters are just well protected like turtles or the butt ends of wombats or the armor of armadillos and pangolin. I could wear a bullet-proof flap jacket and ride my bike everywhere for an excuse to always be wearing a hermit (they knocked me out before kicking my face in... Both hard to do with a good hermit on) Steal-toed boots could come in handy too (even as weapons).