I want to emphasize that I am not a lawyer. I will not be making any direct legal claims in this post; I will be quoting what I consider to be reputable sources. Any statements made in this post are only as accurate as the quoted sources.
Stay In the Vehicle (Unless Otherwise Instructed)
From this law firm:
Stay in the car. If you get out of the car as soon as you stop, it may give the impression to the officer that you’re going to be aggressive or you have something to hide in the car.
Keep Your Hands Visible at All Times
While presumably most traffic stops are non violent, police officers have no idea if you have any violent intent. From this law firm:
Keep your hands resting on the wheel in plain sight and don’t make any sudden movements. You don’t want to give him or her any reason to believe you’re a threat. Wait for the officer to ask for your documents so they know what you’re doing. Don’t try to expedite the process by getting your license and registration ready while the officer approaches your car. If your documents are somewhere other than your glove compartment, let the officer know that you’ll be reaching somewhere unexpected. After you’ve handed the officer your paperwork, return your hands to the steering wheel. It keeps them visible to the officer.
Can Police Search Your Vehicle?
From Flex Your Rights
While police generally need a warrant to search you or your property — during a traffic stop, police only need probable cause to legally search your vehicle. Probable cause means police must have some facts or evidence to believe you’re involved in criminal activity.
In other words, an officer’s hunch without evidence of illegal activity is not enough to legally search your car. Before searching, he must observe something real. Common examples of probable cause include the sight or smell of contraband in plain view or plain smell, or an admission of guilt for a specific crime. The presentation of any of these facts would allow an officer to perform a search and make an arrest.
Be aware that minor traffic violations (e.g. speeding, broken tail-light, or expired registration) are not considered probable cause.
Whether they frisk you or not, police may ask you a series of questions. They will probably include something like “You don’t mind if I have a look in your car?” Beware of that question: It’s the legal loophole that the officer wants to snare you in. (It might even sound like a command, but it’s technically a request.)
In response to such request, you may politely decline by saying “Officer, I know you’re just doing your job, but I don’t consent to searches.” Some officers may use their authority to make you feel obligated to prove your innocence by asking “What do you have to hide?” Don’t fall for such tricks. If necessary, repeat your refusal.
Remember: The 4th Amendment protects your right to refuse search requests, but it doesn’t require police to tell you about your right to refuse. In fact, consenting to searches automatically makes them legal in the eyes of the law. So if you’re pulled over, don’t try to figure out whether or not the officer has probable cause to legally search you. You always have the right to refuse searches.
Don't Ever Physically Resist Arrest
Again from Flex Your Rights
If police detain and frisk you, you have the right to clearly state your refusal to consent to the search. For example, you may say “Officer, I’m not resisting. I do not consent to this search.” But you should only verbally refuse. Never physically resist. Just touching an officer could get you tasered or beaten. You could also get a felony charge for assaulting a police officer.
You Have the Right to Remain Silent
Per the 5th amendment, you have the right to remain silent. This excellent video explains how even saying only things that are 100% true could still be used against you.
Can You Record the Police?
From a CNN article
Just as law enforcement can and does tape traffic stops on dashcam recorders, so, too, can a driver or anyone in a car, as long as the recording doesn't interfere with an officer's ability to investigate, legal and law enforcement experts said.
Do keep in mind that I found at least one source that says you might have to get the consent of the police officer to record them.
This should go without saying, but be polite. Sometimes officers will reduce your ticket or let you off with a warning (particularly for a first time offense); being rude will almost certainly prevent that from happening.