When working on any electrical component on the vehicle, it is always a good idea to disconnect the negative (-) battery cable. This will prevent potential damage to many sensitive electrical components such as the Powertrain Control Module (PCM), radio, alternator, etc.
Any time you disconnect or remove the battery cables, it is recommended that you disconnect the negative (-) battery cable first. This will prevent your accidentally grounding the positive (+) terminal to the body of the vehicle when disconnecting it, thereby preventing damage to the above mentioned components.
Before you disconnect the cable(s), first turn the ignition to the OFF position. This will prevent a draw on the battery which could cause arcing (electricity trying to ground itself to the body of a vehicle, just like a spark plug jumping the gap) and, of course, damaging some components such as the alternator diodes.
When reconnecting or installing a battery, always attach the negative cable last. This is done as a safety measure, should a tool or component slip while installing the positive battery cable. If the tool touches the battery positive terminal and a chassis ground simultaneously, as long as the negative battery cable is not connected, no damage will occur. Make sure when installing a battery that the positive battery cable is fully installed and tightened before installing the negative battery cable.
When the battery cable(s) are reconnected (negative cable last), be sure to check that your lights, windshield wipers and other electrically operated safety components are all working correctly. If your vehicle contains an Electronically Tuned Radio (ETR), don't forget to reset your radio security code, the radio station presets, and reset the clock.