Check connections such as battery cables, fuses then monitor voltage before jumping to any conclusions. Likely is a connection problem so that's the most productive direction and least costly to investigate. Any chance you didn't get the battery cables tightened? Or have a dirty connection?
It sounds like the issue is voltage related. Does it only do it when the engine is idling?
After checking connections & connections at fuses, try pulling the headlight fuse to see if that reduces the tendency to quit.
If you report battery voltage while running and have checked the other suggestions, post back results and we can see where to go from there.
May be voltage
-related, but not, I think, battery
The battery voltage/charging circuitry and the ignition circuitry are totally separate on Generation 1 KLR650s.
The ignition (CDI, or capacitive discharge ignition) on pre-2008 KLR650s is powered entirely by the exciter coils of the stator; alternating current (vs. the direct current of the battery-charging circuitry).
So, whatever the problem is, don't think the battery voltage has anything to do with it--a Generation 1, in fact, will run without any battery at all.
That said, checking the connections between the exciter coils of the stator and the CDI, and between the pickup coil and the CDI appear to be sound maintenance. The ignition circuit is un-fused; the kill mechanisms (grounding the exciter coil leads by ignition switch or kill switch) might bear watching.
Here's a Generation 1 wiring diagram link: