Fill a large pot with water, add a pinch of salt, and bring to a boil. Add the spaghetti and cook until al dente.
Before draining, reserve about 1/2 cup of pasta water. Drain the pasta and return it to the pot.
Pour in the heavy cream and add the grated Parmesan, garlic powder, and onion powder. Stir continuously until a smooth sauce forms. If the sauce is too thick, gradually add some reserved pasta water.
Season with salt, freshly ground black pepper, and red pepper flakes, if using. Garnish with parsley when serving.