The goal of this guide is to help you, a humble game developer, make plans to deal with the ever-present threat of layoffs. Along the way it might also help with other things.
There are two complementary approaches here: dodge, and soak.
The art of the dodge is in not being in the firing line when layoffs happen.
Be good at your job. This is your starting point: if you're really good at what you do, you're less likely to be laid off. Joel Spolsky characterises good employees as having two attributes: "smart" and "gets things done". Try to be those things. Of course, in order to be good at your job, you need to:
Understand what your job actually is. This may or may not bear any relation to your job description, or what you've been told the job is. Your actual job is, in almost all cases, to keep happy all the people who are involved in deciding whether or not to keep paying you. If you want to be good at your job, you need to figure out what these people actually want you to do. Note that they may not know this themselves. And of course, to do this, you need to:
Understand how decisions are really made at your company. Again, this may or may not bear any relation to the org chart or anything you've been told. Most companies' real decision-making structures are not hierarchies, they're complex webs. Mapping this out should be a priority. Doing so should reinforce the point that:
You can't do good work without help. Creative work is inherently collaborative, and to do your part well, you will need other people with other skills to support you. Building and maintaining good working relationships with everyone you interact with is probably the single most useful thing you can do if you want to stay employed: it makes it much easier to "get things done", and as a bonus makes people who have a say in the matter less inclined to put you in the first round of redundancies. You will likely find, though, that:
People won't help you if they know you don't trust them. Wanting to make sure the final product is as good as it can be is all well and good, but at the end of the day everyone's got a job to do, and if you act like you think others can't do theirs, they will resent you and this will make you less effective at your own job because they'll stop helping you when you need it.
Going through the above process will make you much better at your job. Along the way, it will likely reinforce the point that games companies are usually badly-run. Senior people will often do things that are stupid and/or illegal, mostly because they don't know any better. Factor this into your planning, and don't make the mistake of assuming that, just because certain things shouldn't happen, they won't.
In particular, be wary of people who cannot plan effectively. "You can't plan creative work" is demonstrably wrong, and usually means "I can't plan creative work (because I've never seriously tried)". This mindset leads to two problems for you as a developer: firstly, it means you will likely be crunching extensively (which will damage your physical and mental health while having no actual benefit to either you or the company); and secondly, a company that cannot plan its work cannot predict its completion date/quality, and therefore cannot predict its future cashflows, and therefore is quite likely to run out of money unexpectedly.
It's possible to mitigate some of the negative consequences of badly-run companies if you learn to leave paper-trails. There's some judgment involved here, because too much arse-covering makes people suspect you're doing something wrong, but after key conversations relating to your employment, an email to everyone else involved summarising your understanding of the situation can save you all kinds of bother, and even just taking personal notes at the time can swing a years-later he-said she-said decisively in your favour. If there's money or status at stake, relying on someone's better nature (or their functioning memory) will screw you over more often than you'd think, not least because:
Contracts are serious business. Breach of contract can get you hauled in front of a judge and asked to pay substantial fines, and in most legal systems "I didn't know, I never read it" will not get you out of trouble. It will be boring and full of confusing sentences. Read it from end to end, and make notes - ideally, before you sign it.
Finally in this section, it's usually better to jump before you're pushed. One of the consequences of the industry's generally terrible management is that mental health issues abound, particularly burnout. If you're feeling thoroughly jaded, work drains you and/or you no longer feel like its worth making the effort to be professional at the office, you should start looking for a new job immediately, because a) moving on will likely make your life much better, and b) you're probably a fair way down the road to being fired already. It's easier to hang on until the bitter end, of course, but doing so rarely works out in your favour in the long run.
The optimal play can't dodge everything. Sometimes the publisher unexpectedly runs out of money, and sometimes layoffs hit everyone but the lowest-paid people in each department. Thus, even if your dodge game is on point, expect at some point to lose your job - probably to layoffs, possibly to a firing. The art of the soak is to roll with the punch and not let it hurt.
The first step is to plan what you'd do if you lost your job. Expect it to take three to six months from the day you start looking for a job to the day you start being paid at a new job. Figure out how you're going to secure housing, food, and the wherewithal to job-hunt. If your plan is to move back in with one or more parents, it might be worth your while figuring this out with them now. If you plan to keep supporting yourself, figure out what changes you'd need to make. In either case, determine how much doing so will cost. Which will make you probably sad and possibly frightened, and hammers home the need to:
Build a cash reserve. As a junior developer this can be hard, because typical industry pay is frankly not great. A good target to work towards is being able to sustain yourself for six months in your current residence. This might take a decade or more of work to achieve, depending on your circumstances - particularly if you want to also spend money on things like "fun" in the meantime, which you definitely should. It's daunting, but it's also a great life goal. To this end:
Pay rises aren't about greed, they're about financial security. You should be chasing better pay because the games industry is dumb and you're gonna need it at some point. Conduct all your negotiations with this in mind. Speaking of which:
Know what you're worth. It's a tricky one, but obviously important given the above. Soak up any data you can on pay levels for your discipline; there's a number of surveys kicking around (GDC survey, Game Developer Magazine survey etc) that can shed some light on this. Your best bet, though, is to just:
Keep an eye on the job market. Knowing what sorts of jobs are available and how much they pay is invaluable, even if you have no intention of actually leaving. The more you know about the state of the job market, the better you can plan for losing your job, particularly in terms of how often similar jobs come up and where they're located. And, of course, you might just land a much better job without really trying. To figure out what counts as "a much better job", though, you need to:
Know what you actually want. There's a range of metrics to evaluate a job on: location and pay are obvious, but you might also consider how much you're likely to learn, how it will look on your CV, and whether you think you'll enjoy working there. It's worth having a good think about your real priorities (and how they differ from what you think your priorities "should" be) while you have time, so when something interesting pops up you can quickly decide whether it's actually something you want to do.
In the process of evaluating the local job market, you may notice that there are fewer jobs in your field than there are people in that field at your company - meaning that, if your company suddenly went under, there would be more people looking for jobs than there are jobs to be had. Layoffs often turn into a game of musical chairs. This sucks - some people are going to have look further away to find a job, and the others are probably going to get lower offers than usual. Thus, it is in your interests to try to:
Leave early to avoid the rush. Keep an eye out for signs your company might be in trouble, and start planning your exit as soon as you spot one. You don't need to hand in your notice immediately, of course, but doing some aggressive job-hunting puts you in a better position if things go south quickly. The first hint of trouble often comes from a clutch of senior staff leaving over a short period, which can put the company into a downward spiral. The real danger signals though are signs of financial distress, both obvious (revenue below expectations, major project delays, no "next project" plans) and subtle (bins no longer being emptied, fruit bowls not being refilled and other easy-to-cancel services disappearing). If these signs persist but the company keeps operating, it may just be going through a temporary rough patch... but it's more likely that you're going to be summoned to a car-park meeting to announce the doors have been locked and there's no money left to pay you. Speaking of which:
If your company ever misses payroll, GTFO. Best case scenario, the company has the money but is merely incredibly badly run. More likely, there isn't enough money in the bank to pay you. Even if it's only a slip of a few days, it means the company is barely staying solvent and the most likely outcome is loss of all jobs with no notice period/pay.
Finally, there are two special cases when it comes to pay: bonuses, and shares.
Never plan around getting a bonus. If a promised bonus is written into your contract, or if the company has a clear and consistent history of paying substantial bonuses, it may be worth counting promised bonuses when comparing potential jobs. If neither of those things is true, treat all promises of a bonus as being worth zero.
As a baseline, assume stock options are worthless. As a general rule of thumb, good options only work for the company if the employees understand them; bad options only work if they don't. If a company hasn't taken the time to ensure that its employees fully understand a stock options scheme, chances are it's not worth the paper it's printed on. More broadly, unless you understand both a) the full process of exactly how your options turn into actual money, and b) the company's plans to have that actually happen, assume they're worthless. Even more broadly, options and shares can make silly amounts of money if you happen to be working in a financially fashionable field (there are game developers who made a lot of money out of the VR bubble) or on an indie smash hit, but aren't likely to ever be worth a whole lot otherwise, even in the unlikely event that you do get the chance to cash them in.