Start by bringing a large pot of salted water to a boil. Once boiling, add the spaghetti and cook according to package instructions until al dente. Remember to stir occasionally to prevent sticking.
While the pasta cooks, peel and thinly slice the garlic cloves. The thinner you slice, the more flavorful the garlic will be as it cooks in the oil.
In a large skillet, heat the olive oil over medium heat. Add the sliced garlic and red pepper flakes. Cook until the garlic is golden and fragrant, about 3-4 minutes. Be careful not to let it burn as burnt garlic can turn bitter.
Once the spaghetti is cooked, reserve about a cup of the pasta water, then drain the rest using a colander.
Add the drained spaghetti to the skillet with the garlic and olive oil. Toss to coat the pasta evenly, adding reserved pasta water a little at a time if the mixture seems dry.
Remove the skillet from heat, then toss in the chopped parsley and basil (if using). Finally, sprinkle in the grated Parmesan cheese and mix well until everything is combined and the cheese has melted slightly.
Plate the spaghetti with olive oil and garlic, adding extra Parmesan and a sprinkle of fresh herbs on top for garnish. Enjoy your delicious and aromatic dish immediately!