Hey bud. Sorry you're having a hard time with your thoughts and behavior. Have you tried talking to someone? It sounds like your issues would be a bit overwhelming to deal with on your own. That being said, you took a step in the right direction posting here.
The fact that you posted here asking for help eliminating these negative thought loops is a pretty good indicator, at least in my untrained opinion, that you wouldn't actually hurt someone. It does sadden me that you self-harm. From what I understand, self-harm is a cry for help.
Please seek help from a doctor, as they will be able to pinpoint what is causing you to think like this. Again, I'm not a doctor, but any number of things could be causing this: OCD, depression, etc. We could speculate all day, but not arrive at any helpful conclusion since we don't know your eating/sleeping habits, any recent changes in your life, preexisting conditions, drugs you are taking (both illicit and prescribed and their interactions), etc. I hope you're able to get some help soon and are feeling better!