Bring a large pot of water to a rolling boil and add a generous pinch of salt, then add the spaghetti and cook until al dente according to package directions (about 8–12 minutes).
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 constantly so it cooks evenly without burning; cook just until the garlic turns light 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 at least 1/2 cup of the reserved pasta water, and toss thoroughly to coat the spaghetti; add more pasta water as needed to create a silky sauce.If using, add the chopped parsley and grated Parmesan, toss lightly to combine, and adjust seasoning with salt if needed.
Serve immediately.