Heat the olive oil in a medium skillet with a lid over medium heat. Add the shallot and a small pinch of salt and cook until softened, about 3 minutes. Add the garlic and red pepper flakes and cook, stirring, for another 30 seconds. Add the tomatoes along their juices and cook, breaking them apart with a wooden spoon or spatula. Add about ½ teaspoon of pepper and tear in half the basil leaves and cook until the tomatoes break down and become jammy, about 8 minutes. Make 4 small wells in the tomatoes and crack an egg into each well. Season each egg with a little salt and pepper.
Scatter the mozzarella all around the dish, place the lid on the skillet and cook until the whites of the eggs are set, and the cheese is melting, about 10 minutes.