Cook the spaghetti according to package instructions until al dente.
While the pasta is cooking, thinly slice the garlic cloves and heat half of the olive oil in a large pan over medium heat. Add sliced garlic and red pepper flakes (if using) into the pan.
Once the garlic has softened but before it browns, add cooked spaghetti to the skillet with pasta water reserved from draining.
Toss everything together until well coated in oil. Remove from heat and stir in chopped parsley.
Season with salt as needed and serve immediately.