Preheat the oven to 210 fan.
Heat two tablespoons of olive oil in a large, oven-proof pan or shallow casserole dish. (If you don’t have an oven-proof pan, use a large frying pan for now - we’ll transfer to a baking dish later.)
Add the red onion and cook for 8-10 minutes until starting to soften, adding a splash of water to help them along if needed.
Meanwhile, boil the pasta in salted water until just under al dente. Reserve a mug of the pasta water before draining. Or as per packet instructions.
Stir in the garlic, tomato puree and chilli flakes (if using) with a splash of water. Stir to create a paste and cook for 1–2 mins until fragrant and the tomato puree deepens in colour.
Pour in the passata, most of the basil leaves (saving some for garnish) and season with salt and a few cracks of black pepper. Simmer for 7-8 minutes, stirring occasionally, until reduced slightly.
Stir in the butter beans with their bean stock, cooked pasta and spinach, if using. Stir to combine, adding more pasta water to loosen, if necessary. Simmer for 5-6 mins until the spinach wilts. You could mash some of the beans for an even creamier consistency, but keep some whole to appreciate their texture + bite!
If you started in a frying pan, now transfer everything to a large baking dish. If you used an oven-proof pan, keep everything where it is. Top with the grated cheddar, tear over the mozzarella and scatter over the parmesan.
Bake in the oven for 10-15 minutes until golden, bubbling and just starting to crisp on top - you can crank it up to a high grill setting for the final few minutes to help it along. Let rest for 5 mins before serving, alongside garlic bread and a fresh side salad.
