Car almost shuts off on me while idoling?

I have a 2002 honda civic and replaced my alternator 2 years ago and it has been working fine. But this morning i parked my car and it tried to shut off while it was idoling the lights flashed for a second then it was back to normal… No idea what's wrong?

I assume u r driving stick shift & may be u r releasing the clutch pedal too fast or the parking area is not a flat surface. If the case is not mentioned above, then you may have a battery/clutch issue.

Get a minivan/prius

The instrument panel lights will briefly illuminate if the engine's RPM drops too low (as if it's dying) because when the RPM drops below ~500 the oil pressure and voltage generated by the alternator etc., drop below their normal operating range too. Those lights are to be expected if the engine is dying or about to die (just like you'd expect to see them on right before you start the engine). The lights don't necessarily signal a problem with either system IF they're turning on only when the engine RPM drops to below normal idle.

My guess from your description is that your idle air control (IAC) valve might need attention/replacing. It may be very dirty or simply failing from age/use. When it starts to fail, the engine can idle erratically or die altogether because when the IAC valve is not operating properly the engine is not consistently getting the proper amount of air into it upon idling.

Yes i drive stick, it was parked wasent touching the clutch just randomly tried shutting off. It could be wiring or a bad battery?