Heat the oil in a heavy-based, ovenproof, nonstick 23 cm (9 inch) frying pan over a low heat. Add the onion and cook, stirring occasionally, for 6–8 minutes until softened. Stir in the courgettes and garlic and cook, stirring, for 2 minutes.
Beat the eggs in a large bowl and season with salt and pepper. Stir in the cooked vegetables, spaghetti and half the Parmesan and basil. Pour the mixture into the frying pan and quickly arrange the ingredients so they are evenly dispersed. Cook over a low heat for 8–10 minutes, or until all but the top of the frittata is set.
Transfer to a preheated very hot grill and place about 10 cm (4 inches) from the heat source. Cook until set but not coloured.
Give the pan a shake to loosen the frittata, then transfer to a plate. Scatter the top with the remaining Parmesan and basil and leave to cool for 5 minutes before serving.