We all were at one time. We learn through experience the longer we ride. Did you notice when you applied for motorcycle insurance they ask you how long you've been riding and owned a cycle? They base their rates from statistics of MC accidents and yrs of driving experience.
The best and foremost tip I can offer you is to be alert for the unexpected and have a plan for an escape from harms way if it occurs. For the one you were just in, maybe you could have slowed down earlier coming to the light by downshifting into a lower gear, that way allowing more room ahead of you in anticipation of the lane jumper. Other's will chime in and offer you more tips for riding safely so don't be offended by it, but read, learn and practice them when driving your bike and cager. None of us want to hear of a fellow biker going down and not making it through it. You did, now learn from that experience