I've decided to start with what I think should always be the first step. Figuring out your story.
I honestly think it's better to think of a story first and then create a character to fit, not the other way around. This can just make the story confusing and is, in my opinion, the most common way plot holes form. It's easy to see when someone is trying to think of ways to explain a certain characteristic or feature of their OC and instead create plot holes.
If you've chosen to write a fanfic or story set in a different time (e.g. Middle Ages), make sure you research what life would have been like in those times. If you have a character planned first, you should be prepared to adapt them.
YOU ARE READING
Anti Mary-Sue Character Guide
Non-FictionHere is just my list of tips of how to avoid creating/writing a Mary-Sue character. Take them as you wish. Greatest Achievements: #1 in non-fiction!!!