Awareness is the start. At first you may notice after you start to beat yourself up, but you will begin to notice sooner. Find some affirmations to say when you notice. Rather than trying to stop being so hard on yourself, it is easier to replace negative talk with positive talk. Some people recommend snapping a rubber band on your wrist, I think that reinforces a negative. Instead try wearing a pretty bracelet you can touch and look at when you say it. It could be "I am safe, I am strong." When you are in a situation where you are unable to say affirmations out loud the bracelet will become associated with good self talk.
Hugs to you!
Lizzy