Knowing the law is important, especially because you want to be watching out for cops if you're breaking it.
If I'm riding in a group, I obey all laws. You shouldn't lead other bikers into danger and following the rules is the best you can do for keeping groups safe. When I'm alone, I ride like I'm a rodeo clown with a dozen bulls trying to get behind me. This includes blowing through a stop sign at speed if it makes sense.
Example: I'm coming up to an intersection where I can clearly see all ingress points clearly. I'm doing 15mph approaching this empty four way stop; and another car is coming up to turn left in front of me. But at my speed I'm obviously seven seconds ahead of that car and I can see it's slowing to make the left turn. I extended the courtesy of blowing through the intersection, exiting it before the other car was ever within five seconds of me. Sure, my chain could have slipped (but it wouldn't because I kept my speed) and I could have crashed in the middle of the intersection. Of course that would be more likely if I was accelerating from a stop. Anyway, I was gone by the time it got to the intersection and I watched it blow through the left turn at 15mph because I was gone. "You're welcome," I said, because I could tell in my heart he had thought, "Thank you."
Had I stopped it would have changed our timing such that I would have had right of way to go first, just as he stopped. Then I would have hesitated to go until I knew he saw me, because I don't know if he's some goody two-shoes that always stops at intersections where nobody else ever does; which means maybe he doesn't see me and so I'm hesitating, but then because he isn't going I can tell he expects me to go, but what if me not going is interpreted as a sign that I want him to go and now I'm really not going because bikers never win a misunderstanding.
I've been riding for 40 years (hit by cars three times in the first five, and never since) and there are so many things to consider that I don't think you can give advice about this and expect it to be good advice, because it all depends. I obey all laws, or safer, when I'm riding in places I haven't ridden a dozen times before. The point I made above is a horrible one, because I know this intersection well, having ridden it thousands of times. But you don't know it. I didn't tell you about the huge pot hole I avoid without thinking; or that I don't do this when it's dark, where I may only see the headlights that were on, and not the others that were drunkenly off, and so on. Is the sun low and blinding me or the drivers?
The only advice that's useful to a forum of strangers is to obey the law, and even then your going to get hit sometimes. I haven't been hit in decades, but that just means I'm lucky. No doubt my luck is increased with experience (my own and what I learn from others) and that experience is very subjective to your experience, your location, your experience with that locaion, the time of day.... My point is that safety first; obeying the law is second; when you don't have tried and true experience with the situation, obeying the law is your best bet for safety.