The AI does sometimes leave its starting city undefended, but this is uncommon. Usually, the AI will have one or more Warriors defending its capital from the start.
One way to prevent this problem is to play on a higher difficulty setting. At higher difficulties the AI will start with extra units, which greatly reduces the chance that it will leave its capital undefended for long.
Another way would be to play without lairs. Even an AI that leaves it capital undefended (initially) will be able to build a defender before barbarians start appearing normally, but lairs are a possible "early" source of barbarian units. Turning off lairs should virtually eliminate situations where the AI is killed before it can build a defender. (I say virtually, because it is still possible to spawn barbarians from a Tribal Village. To completely eliminate early barbarians you would also need to disable Tribal Villages.)
I have found that the current AI is eliminated in the early game much less frequently than with the previous AI (pre-H), because of the large numbers of units it produces. If AIs are being eliminated too frequently in your games, and the above suggestions are not to your liking, then you can always add an extra AI or two in your games to compensate.