To be very good at what you do. It cuts two ways!
First, because you are so good, you can be vert comfortable in your role, and not feeling the pressure to expand and grow your skills. You may be disinclined to seek out other employers, or even partners, where your career would grow. You may just put up with a lot of cr_p!
Second, if you are so good, management is motivated to keep you in your present role. You make your manager look good! Forget a promotion or a new role, you are too hard to replace! Of course, since you are not promoted, forget about getting a raise. The only way to get a bump is to threaten to leave, and if you play that card, upper management labels you as disloyal and a flight risk. Your career will be short!
The good news here that despite of the curse of being good, the bean counters who run the company will still lay you off, so you can still escape this h_ll.