How to prevent my chain from breaking? After my chain has broken what should I know about buying and maintaining a new chain (apart from lubing it and replacing when it 'stretches')? Do you keep a spare chain, or a spare link?

I have a commuter bike (a Kona Dr Dew) with Shimano dérailleurs.

The first chain was replaced "worn to at least 100%" after the first 6 months/5000 km. The cassette seems OK and not worn. This was the second chain, replaced two months ago. I noticed occasional slipping gears but don't know whether that was the chain, or the indexing of the gear shifter.

The chain (the replacement chain, which broke) is an SRAM PC-951 which Google says is "our most economical chain".



Update - it wasn't the removable SRAM link, it was one of the factory links that broke. Because it had been skipping and the previous chain worn more than 100%, I asked to replace the chain and the cassette (even though he agreed that the cassette didn't look really worn, he said 5000 km is too far for a chain); and got a chain stretch measuring tool, if replacing the chain every 6 months isn't often enough. Anyway it's tight again now. The new chain is a more expensive SRAM PC-991 (which cost more than the new SRAM 950 cassette). The original parts I think were all Shimano.
To keep your chain from breaking, keep the derailers properly aligned, ease off of pedaling when you shift, and don't "stomp" on the chain when it's not fully in gear.  (Folks who don't go back to the non-indexed days probably never got into the habit of coasting while shifting, but it wouldn't be a bad thing to practice a bit.)

Broken chains are exceedingly rare, and are almost always the result of putting load on the chain when it's not fully in gear.  The other likely source of damage is having sprockets that are so badly hooked that the chain gets sucked into a knot.

Update -- 6/14/18

An observation I made this week, working on a bike for Christmas Anonymous:

The bike (a 26" full susp BSO) came in with a mangled chain, a mangled rear wheel (half the spokes were broken), and a broken rear derailer.  The chain had actually been twisted 90 degrees at one point (amazing that it didn't break), something I'd never seen before.  It seemed like the chain had gotten twisted up in the rear cluster perhaps, after the rear wheel had gotten mucked up.  (Perhaps a garage accident -- hard to tell with such things.)

So I found a new rear wheel, a new rear derailer, and a new chain, and put it all together.  The rear derailer worked fine, once I got it adjusted (involved some cussing), but then as I tried to get the front derailer to work (blasted twist shifters, plus a cable that was routed so that it collected rainwater) I started having trouble with chain suck on the small front ring.  I could see that this chain suck likely caused the chain to knot up and twist, and it was only after that that the garage accident occurred, taking out both wheel and derailer.

Since the chain suck was consistently on two teeth a one point on the small ring, I was able to use a round file to smooth out the teeth and eliminate the problem.  I'm guessing the teeth had burrs from when the ring was manufactured, and the bike never got used enough to wear them off.