Cook the spaghetti 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 spaghetti and set aside.
In a blender or food processor, combine the avocados, basil, lemon juice, garlic, red pepper flakes (if using), and olive oil. Blend until smooth and creamy. If the sauce is too thick, add a little reserved pasta water to reach desired consistency.
Season the avocado sauce with salt and pepper to taste.
In a large mixing bowl, combine the cooked spaghetti and avocado sauce. Toss until the pasta is evenly coated.
If using, sprinkle the grated Parmesan cheese over the pasta and toss again.
Serve immediately, garnished with halved cherry tomatoes.