Cook the spaghetti according to the instructions, not too soft.
In the meantime, fry the garlic, chilli flakes and nuts briefly in olive oil in a pan. Add the chopped anchovies and mash a little more with a wooden spoon. Add 4 - 5 tablespoon pasta water.
Drain the spaghetti and add to the pan. Add the grated Parmesan and stir-fry for 2-3 minutes. Season the dish with salt and pepper. Stir in the chopped basil before serving.