Well the AI usually targets weaker neighbours. So the obvious thing to do is either not ally nations, that are pressured by a rival / neighbour of theirs or you make sure your alliance is clearly stronger than anyone around you. (Meaning grow into the regional top-dog asap)I agree , but I don't think I understand fully how to do this. What are the more subtle ways of avoiding a CTA?
As an example, the Teutons are not a good ally, since they'll almost certainly drag you into a war against Poland. Similarly Novgorod is a terrible idea.