Cook the pasta 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 pasta and set aside.
In a large skillet over medium heat, add the olive oil and minced garlic. Sauté for about 1 minute until fragrant, being careful not to burn the garlic.
Add the halved cherry tomatoes to the skillet and cook for 5-7 minutes, stirring occasionally, until they start to soften and release their juices.
In a food processor, combine the fresh basil, Parmesan cheese, salt, black pepper, and red pepper flakes (if using). Pulse until finely chopped.
With the food processor running, slowly drizzle in the olive oil until the mixture is smooth and well combined.
Add the cooked pasta to the skillet with the tomatoes. Pour the pesto over the pasta and toss to combine. If the pasta seems dry, add reserved pasta water a little at a time until desired consistency is reached.
If using, toast the pine nuts or walnuts in a dry skillet over medium heat for 3-4 minutes until golden brown. Sprinkle on top of the pasta before serving.
Serve warm, garnished with extra Parmesan cheese and fresh basil if desired.