Unionize.
How many companies this year started layoffs with recruiters, HR, and admin staff and are now turning to laying off software engineers?
I've worked several union and/or government jobs. Yes, it sucks that you end up carrying some of your co-workers. But knowing that your family isn't going to starve because your new manager doesn't like your outfit is nice.