Boil the pasta: Bring a large pot of salted water to a rolling boil. Cook pasta according to package directions until al dente. Drain and rinse briefly under cool water to stop cooking.
Dry the pasta: Shake off excess water and spread the pasta on a sheet pan for 5 minutes.
Slightly dry pasta takes pesto better and prevents clumping.
Prep the mix-ins: Halve the tomatoes, cube the mozzarella, and slice the shallot or onion if using. Toast nuts in a dry skillet over medium heat until fragrant, 3–4 minutes.
Loosen the pesto: In a large bowl, whisk pesto with 1–2 tablespoons olive oil and 1 tablespoon lemon juice. This makes it easier to coat the pasta evenly.
Toss the pasta: Add the pasta to the bowl and toss gently until every piece is coated.
If it looks dry, add a splash more olive oil or a spoonful of pasta cooking water if you saved any.
Add the good stuff: Fold in tomatoes, mozzarella, shallot/onion, and Parmesan. Season with salt and pepper. Add more lemon juice to brighten, if needed.
Finish and rest: Sprinkle with nuts and torn basil.
Chill for 20–30 minutes if you can. This rest helps the flavors meld.
Before serving: Taste and adjust. If it’s been chilled, stir in a teaspoon of olive oil or a spoonful of pesto to refresh the gloss and flavor.