Cook spaghetti according to package directions. Reserve about 1 cup of pasta water before draining.
While spaghetti is cooking, heat olive oil in a large skillet over medium heat. Add minced garlic and red pepper flakes (if using) and cook until fragrant, about 1 minute. Be careful not to burn the garlic.
Add the chopped spinach to the skillet and cook until wilted, about 2-3 minutes. Season with salt and black pepper.
Add the drained spaghetti to the skillet with the spinach and garlic. Toss to combine.
Gradually add the reserved pasta water, a little at a time, tossing the pasta until a light sauce forms and coats the spaghetti.
Serve immediately, topped with grated Parmesan cheese.
Notes
For extra flavor, you can add a squeeze of lemon juice before serving.