KOC Defense Step 1
Cities get attacked, primarily, because the owner made it easy for an attacker to steal resources.
You can minimize this by raising the level of your storehouse. Food, wood, stone and ore that are protected in a storehouse can not be stolen by an attacker. Each level of storehouse protects 100k of each of these resources. Shrinking Powder research (performed in the alchemy lab) helps here too.
A storehouse protects resources in a particular city. So, all storehouses in all cities should be upgraded to protect as many of your resources as possible.
KOC Defense Step 2
Quick response to an attack involves identification and reinforcement.
Your leaders cannot identify attacks quickly if the barb and wild attack reports are cluttering up the reports. It is your responsibility, and the gang's benefit, to delete these regularly.
If you're under attack, other players can reinforce your city. The number of reinforcing armies that your city can handle is determined by your embassy. The higher your embassy level (for each city), the better.
If you're online and are under attack it serves little useful purpose to jump into alliance chat and shout "I'M BEING ATTACKED". Give details - which city is being attacked, who is attacking, and any attacking troop details (type and number). Help us to help you.
KOC Defense Step 3
As a follow-on to the previous step:
Your Watchtower level and Eagle Eyes research level determine the amount of detail you can see. The higher these are, the more detail you get of attacking forces and when you're scouting.
Your Rally Point determines how many armies (and the maximum size of each army) that you can deploy from a city. Your Relief Station determines the city-to-city speed of deployed troops. Obviously, reinforcement is best done "big and fast." It's not good to use up an allied embassy slot with a small reinforcement army. When you do reinforce an allied city, it's polite to send food with the reinforcements.
KOC Defense Step 4
Another way to prevent your city from being farmed is to continue to make your city really unattractive to potential attackers.
How? Make the attacker know he's going to lose troops (and therefore might) by building wall and field defenses. With a high storehouse and embassy level, and lots of sharp and dangerous things protecting your city an experienced attacker is much more likely to stay away. An inexperienced attacker will just be another smear on your city wall, and you'll keep your resources.