Cook the spaghetti according to package instructions in a large pot of salted boiling water until al dente. Reserve 1/2 cup of pasta water, then drain the spaghetti and set aside.
In a large skillet, heat the olive oil over medium heat. Add the minced garlic and red pepper flakes (if using), and sauté for about 1 minute until fragrant, being careful not to burn the garlic.
Add the shrimp to the skillet and season with salt and pepper. Cook for 2-3 minutes on each side until the shrimp turn pink and opaque.
Stir in the lemon zest and lemon juice, then add the cooked spaghetti to the skillet. Toss everything together, adding reserved pasta water a little at a time until the desired consistency is reached.
Remove from heat and stir in the chopped parsley. Adjust seasoning if necessary.
Serve immediately, topped with grated Parmesan cheese if desired.