Just to add some things of my own note. Personally I take it as a personal challenge to have zero idlers (the thing about "enough idle to pull a lever" is good, but I try to arrange things so that emergency levers (which the uncounted idlers that are children/some nobles can do anyway) aren't a life-or-death-this-instant thing. Of course, that requires planning things so that they aren't.
As more or less said, "farmer" could well be a dwarf with relatively equal but low-level shearing, bee-keeping and plant-gathering skills. Although if you haven't turned off the (o)ption for "All dwarves harvest" (or whatever it is again), then random dwarves will increase their planter/grower-type skill (especially children!), and it may supersede their
intended primary skill (such as Architect) if you don't level them up in that so much. I usually find something (constructing rock blocks? smoothing walls?) that the 'lesser' farmers, or indeed any otherwise untrained-in-anything-currently/imminently/eventually-useful dwarf, can be assigned to, just to keep them useful. And then there's hauling, but without a level-up possibility or any relevance towards future moodcrafts[1] I generally reserve that to those already qualified enough to do something important but not currently needed. (Which in effect is everyone not either assigned to a specific craft, smoothing the hell out of my impending magmaduct/water-pipe in preparation or being a "Construction Mason" (not itself a skill-learning experience, but vitally important when I've got above-ground and over-ground structures needing placing.)
And, indeed, Dwarf Therapist is invaluable for managing all the above.
In my forts, if I lost a cook to an ambush (except maybe
really early on), I'd be doing something very wrong indeed. But then I (as others have mentioned) partition off territory as a compound and (except for further outer-area construction) don't let civvies wander around outside this area. Meanwhile I often have ranged-combat dwarves walking the tops of the compound walls (perhaps behind fortifications) and mêlée/ranged troops or guard animals stationed to reveal sneaking enemies (single snatchers/thieves or units of ambushers) with suitable warning times. But these are
my forts, and I'm a control-freak in this regard.
Perhaps the best defence for you is more watchtowers, more watchers, and see if you can get some (more?) ranged troops drafted. This might help soften up invaders before they get into range of a cook (or, even, your sworddwarves!). Although for advanced points you'd set it up so that you'd have a sealable "killing zone". Sealable inside and out. When your early-warning system alerts you to shock-troops (or single enemies) you
let them half way through, then attack them (either from afar, with ranged troops, by them crossing traps of some kind to be partially killed and/or captured or by sending in your best mêlée troops through a side-door). With them (and your troops, if appropriate) sealed into the killing zone then they may cannot run away, and you can continue (by whatever means) to kill and/or capture them. For maximum gathering of Goblinite, and or live-targets for your more advanced firing range or sparring-arena. This is what I try to do, anyway, although obviously you need to finesse some of this (and take some risks, while at it).
Also note that traps currently (as of a very recent version change) also block Wagon travel. You cannot cover your trading-route into your base with traps and still expect to get wagons visiting. However by making "wall-like" extensions of traps part way across a double-width entryway (alternating from each side) you can grant a wagon a (windy) route through the traps, while non-wagons (immigrants, non-wagon traders, diplomats, and of course every type of hostile) will walk straight across the lines of traps. With the non-[TRAP_AVOID]ing hostiles succumbing to your trap defences, probably. (A more advanced method is to create a "straight route" that relies on raised bridges being lowered, perhaps, so that you can speed wagons in/out of your fort when you know they are coming in, but with the bridges raised (or retracted, if over unpathable ditches) you have a not-quite-so-short trap-laden route ready for the hostiles and a longer 'wagon-friendly' route so that surprise wagons don't assess your Depot as inaccessible without giving you the chance to grant them the better access. I repeat, this is a more advanced approach, and you might need to try to work out some of the details yourself to better understand what I mean here.)
[1] Some people might do something like (say) set up a forge to produce something simple like gauntlets, restrict it to low-level armourers and then apply "armour making" to every dwarf that isn't otherwise useful. At some point it's possibly that a constructive mood strikes a marginally-skilled armourer and they then become
very good at it. Also some skill gives dwarves a trade to offset "demobbing" bad thoughts for those otherwise doomed to become occasional rank and file. Along the way you get potential trade-goods (or, if you pick your chosen product, something that you use even at low quality). Anyway, you can rinse and repeat for other similar 'worthy' trades. Or indeed spam several
different worthy trades over the whole gamut of candidates, and then as you attain your one legendary dwarf (or two, for security/speed?) you can cut the rest off from this skill and see if the next mood gets you... weaponsmith, or whatever. Note that I don't do this myself, so my theory and recall of the process might not match the practice, but it could always be worth a try.
A (long) postscript on caverns: I tend to (try to) break into them from above, before having a walkable access (sealing off any inadvertent walkable access straight away if I ever make them). Then I'm at leisure to decide what I want to do in them (or, indeed, whether I want to open them up so fully in
order to do anything in them). Often I'll merely tap into a cavern pool of water as a water-source (the full description of how I'd do that is lengthy, but I basically tap them for water in a manner that prevents simple creature movement into my fort through said water-access, whether it be a well or just flowing through a side-channel), and similarly exploit the magma sea when I find it. I've very rarely been tempted to go in there to mine the cavern walls (although I know that I could), because I usually find enough non-wall tiles that I can mine of gems or ore or otherwise interesting rocks. Once the caverns are breached I can (if I want) make sure that the plants and 'trees' that are found in the caverns can grow in non-cavern voids of my own making, in fact sometimes I find I'm spending effort to
stop them doing so. Spider silk is probably the one resource I'd consider going into a cavern to get, especially GCS-silk. But the normal stuff is (as per cavern-fauna) now probably available in areas under my direct control, and GCS-silk farming has its risks associated (that one doesn't get with a good trade relationship bringing in the raw or processed materials, thereof).
So, for me, I find I don't "walk through" caverns, although by breaching (and then re-sealing) the ceilings of said caverns from above, somewhere near the limits of the last sight-line, I get a decent look at what I'd be missing and also get to know
how to miss the caverns, when I'm trying to get further down the geological stack (perhaps to find and identify the next cavern, but ultimately it's the Magma Sea that I crave!). And every now and then I actually use the space down there (as opposed to "digging round it", or even building walls and floors into the 'roof space' to allow me to continue my subterranean dig-plan even across the inconvenient void I've just hit), but only so very occasionally.
Anyway, given you're killing things, perhaps my general "hands off" approach is far too cautionary to be included in your playing style. You seem capable enough. (As are my units, often, but I'm just a control-freak with an aversion to
needless bloodshed.
)