Heat the oven to 450 degrees F and arrange a rack in the middle.
In a larger bowl, toss the tomatoes with kosher salt, black pepper, garlic and extra virgin olive oil. Transfer to a sheet-pan and bake in heated oven 25 to 35 minutes or just until the tomatoes collapse and develop some char (if you don't want them too soft, take the tomatoes out earlier). When ready, remove from the oven. (See notes)
While the tomatoes are roasting, cook the spaghetti in boiling water according to the package to al dente (about 10 minutes). Reserve ½ cup of the pasta cooking water. Drain the pasta.
Transfer the cooked spaghetti to a large bowl (same bowl used earlier for the tomatoes). Add the pesto and toss to coat. If you need to, add a little bit of the pasta cooking water to help mix it evenly. Taste, and if needed, add a bit of kosher salt and black pepper to season.
Add the roasted tomatoes and mozzarella to the bowl of pasta. Toss to combine. Serve warm. Garnish with fresh basil, if you like.
Make ahead tips: Both the roasted tomatoes and homemade basil pesto can be prepared in advance. In this pasta. I often use my leftover quick roasted tomatoes, which I store in the fridge in a tight-lid mason jar for 3 to 5 days (make sure the tomatoes are at room temp before storing). Homemade basil pesto will typically keep in the fridge for 1 week (follow this basil pesto recipe for all the tips).
For Mediterranean diet, use whole grain pasta
Leftovers: store leftover pesto pasta in the fridge in a tight-lid container for 2 to nights or so (this will vary depending on whether you prepared any part of it ahead of time).
To add protein: You can add simply seasoned grilled chicken or shrimp to this pesto pasta. Once you toss the pasta with the pesto, add in the protein (it needs to be cooked and warm), then add in the roasted tomatoes and mozzarella.