Cook the pasta. Bring a large pot of salted water to a rolling boil.
Add pasta and cook until al dente, according to package directions. Reserve 1/4 cup pasta water, then drain and spread the pasta on a sheet pan to cool.
Prep the mix-ins. While the pasta cooks, halve the tomatoes and pat the mozzarella dry with a paper towel. Grate Parmesan and prep the garlic if using.
Make the dressing. In a large bowl, stir together pesto, lemon juice, lemon zest, a splash of olive oil, and the grated garlic.
If the pesto is thick, loosen with a tablespoon of pasta water until it’s saucy but not runny. Season with salt, pepper, and red pepper flakes.
Toss the pasta. Add the cooled pasta to the bowl and fold gently until every piece is coated. The pasta should look glossy, not dry.
Add a bit more olive oil or pasta water if needed.
Fold in the Caprese elements. Add tomatoes, mozzarella, and Parmesan. Toss gently so the mozzarella doesn’t break. Taste and adjust salt, pepper, and lemon.
Chill or serve. For best flavor, chill for 20–30 minutes to let everything meld.
Garnish with torn basil before serving.