Bring a large pot of water to a rolling boil and season generously with salt, then add the spaghetti and cook until al dente according to package directions.
While the pasta cooks, heat the olive oil in a large skillet over medium to medium-low heat.
Add the thinly sliced garlic to the oil and stir frequently to prevent burning; cook just until the garlic turns golden.
Stir in the red pepper flakes, then remove the skillet from the heat to prevent the garlic from overcooking.
When the pasta is done, reserve at least 1/2 cup of the pasta cooking water, then drain the pasta in a colander.
Transfer the drained pasta to the skillet with the garlic and oil, add about 1/2 cup of the reserved pasta water, and toss with tongs until the pasta is evenly coated; add more pasta water as needed to loosen the sauce.
If using, add the chopped parsley and grated Parmesan and toss lightly to combine.
Serve immediately.