Not as experienced as you but as a younger guy I would like to share my experience - I lasted 4 years and few months before I was asked to go. Even though I never considered myself irreplaceable in a firm of 6K+ coders, it was a revelation how "business strategies" may "require you to be let go" which would be of course "better for your career". Finding another job was super easy for me (I believe that was because of my young developer age). But I was really bitter about the "let go" process and the way things were handled. It was only after few months that I realised that it was actually very good for my career and yes when I look back I see I should have left the place at least 3 years ago when things had started to change and I still didn't act. It was just a good salary, a very tightly knit team, and a relaxed work environment. I had gotten into the comfort zone. When I was out I took that long cherished 3 months cross country solo backpacking trip.
As for the emergency fund - yes, even for a younger person like me with no responsibilities or liabilities a medical insurance (I had been paying for one since I had joined - here in my country medical insurance in general means whatever your firm offers me and usually no one buys any medical insurance on their own) was something I had along with regular transfers from salary account to few deposit accounts and into some equity funds.
> Once you are over 50 like me, you need to be in a position financially to live several years without a paycheck
This! I have been planning for this as a retirement strategy now. Actually as an "involuntary retirement" strategy. It might sound naive and may actually be naive but when I am planning for my MS now, this is one of the use-cases I have in mind. With an MS I will have another career option (or rather call it freelancing) - teaching in colleges and universities as adjunct/visiting faculty. One of my lecturers (actually one of the better ones) did not have a PhD. He told us he was laid off from his job and he didn't want to find another job in the industry and he was considering a PhD (he was 53 at the time). He taught in some other colleges too.
And yes, a company may ask you to go at the first sign of trouble and hence I find it incredibly surprising when employees leaving a company at the first sign of trouble are frowned upon and are often called "disloyal" by some people.
> You need to be in a position financially to live several years without a paycheck because it could take years for the job market dynamics to change and become more favourable for the employee.
How insane is that?
Add to the fact that cost of living is so high now in the Bay Area, and safe returns are so low, that building up any sort of true emergency savings is difficult... Insane.
Layoffs in the tech industry will happen. An emergency fund or F.U. money is required to deal with it. Once you are over 50 like me, you need to be in a position financially to live several years without a paycheck because it could take years for the job market dynamics to change and become more favourable for the employee.
During the time you are out of work for a long stretch take some time to learn some new skills, contributing to open source software is an excellent way to do this.
You must always place your interests ahead of the company you are currently working for, the company is not going to place your interests ahead of it's own. You are just a pawn to them. If the companies interests start to conflict with yours, then you must be prepared to leave (either voluntarily or they'll do it for you at their time and place of choosing).