Bring a large pot of salted water to a boil. Add the pasta and cook according to package instructions until al dente. Reserve 1 cup of pasta water and drain the rest using a colander.
In a large skillet, heat the olive oil over medium heat. Add the minced garlic and sauté for about 1 minute, or until fragrant.
Add the sliced mushrooms to the skillet. Cook for 5-7 minutes, stirring occasionally, until the mushrooms are tender and browned.
Stir in the chopped spinach and cook for another 2-3 minutes, until wilted.
Lower the heat and pour in the heavy cream. Stir well to combine, and let it simmer for about 2 minutes.
Add the cooked pasta to the skillet along with the reserved pasta water and Parmesan cheese. Toss everything together until the pasta is well coated in the sauce.
Season with salt, black pepper, and red pepper flakes if using. Remove from heat and let it sit for a minute to thicken.
Serve hot, garnished with fresh basil or parsley if desired.