Heat the oil and 2 tbsp butter in a large, shallow, flameproof casserole or frying pan over a low-medium heat and fry the onion with a pinch of salt for 10 mins until soft and translucent. Add the garlic and chilli flakes, and fry for 1 min more. Tip in the tomatoes, 1 tsp sugar and pesto. Season and simmer, uncovered, for 10 mins, stirring often. Tip in the spinach and cook for another 5 mins until wilted.
STEP 2
Heat the grill to high. Make eight gaps in the sauce with the back of a spoon and crack an egg into each. Dot over the ricotta and scatter with the parmesan. Cover and cook for 5 mins, then slide under the hot grill for a few minutes until the egg whites are set and the yolks runny. Scatter with the basil and serve with crusty bread for dunking.