Bring a large pot of water to a boil and salt the water. Add small shell pasta and cook the pasta to al dente doneness which means that the pasta will still have a bite to it or be a little chewy. The pasta will soak up more juice and keep on cooking after we drain it, so we need it to be a little under cooked. The shells will probably cook about 9 or 10 minutes.
Preheat a deep, big skillet or a medium sauce pot over medium heat.
Place garlic on the cutting board and place the flat of your knife on top of each clove. Carefully give the garlic a whack with the palm of your hand to separate the cloves from the skins. Throw out the skins and chop up the garlic. Remember to keep your fingers curled under and the edge of your sharp, chef's knife tilted slightly away from your body.
Add extra-virgin olive oil to the pan by pouring a slow stream of it twice-around-the-pan. This will be about 2 tablespoons of extra-virgin olive oil just enough to coat the bottom of the pan. Do not let the oil pour out too fast. You are looking for a slow, steady stream. Add the garlic to the oil. To chop the onion, cut the ends off and cut the whole onion down the center. Wrap half and save it. Cut the other half into thin slices then twist the slices a quarter turn and chop them again. Hold the tip of knife on the cutting board and lift the back of the knife up and down over the onion to make the pieces really small. Add the chopped up onion to the garlic and oil. Cook, stirring a lot, 5 minutes until the onions are mushy and look cooked.
Add the tomatoes to the onions and stir. When the tomatoes come to a bubble, reduce the heat under the sauce to low. Stir in basil pieces to wilt them. Season the sauce with salt and peppe, to your taste.
Preheat your broiler to high and place a rack in the center of the oven.
Drain pasta shells. Add them to a flameproof casserole dish. Add pesto sauce, 1 cup of ricotta cheese and a handful of grated Parmigiano, too. Stir carefully and coat the hot pasta with the pesto and cheeses. Pour the hot tomato and basil sauce over the pasta, as much as you like. You can always serve a little extra at the table, to pass around. Shred up some mozzarella cheese with a grater and scatter it over the pasta. Add a final sprinkle of Parmigiano to the mozzarella as well. Place the casserole under the broiler in the middle of oven, 10 to 12 inches from the heat. Let the cheese melt and bubble on top, 3 to 5 minutes.