Preheat the oven to 400°F (200°C).
Peel away the loose, papery layers from each head of garlic, keeping the heads intact. Slice about ¼ inch off the top to expose the garlic cloves. Set aside.
In a large (12-inch) oven-safe skillet, add the diced red onion, sliced mushrooms, and baby spinach.
Nestle the garlic heads, cut side up, into the center of the skillet.
Drizzle the olive oil evenly over everything, making sure the garlic and vegetables are well coated. Sprinkle with salt, pepper, and crushed red pepper flakes (if using).
Add the cubed cream cheese throughout the pan and pour the heavy cream over the mixture.
Cover the skillet tightly with aluminum foil. Bake for 50 minutes.
Remove the foil and bake, uncovered, for an additional 10 minutes, until the mushrooms are golden and the garlic is very soft.
Remove the skillet from the oven. Carefully squeeze the roasted garlic cloves from their skins directly into the skillet, then discard the skins.
Stir until the cream cheese is fully melted and everything is smooth and creamy.
Add the cooked pasta and freshly grated Parmesan cheese. Gently stir until the pasta is coated in the sauce. If the sauce is too thick, stir in a little of the reserved pasta water until the sauce reaches your desired consistency. (I used ¼ cup pasta water.)
Serve warm, garnished with chopped parsley and extra Parmesan.