Bring a large pot of water to a boil over medium heat. Salt the water, add the shells and cook for 2 to 3 minutes less than the package directions. Heads up: Remove and reserve 1 cup of cooking water just before draining.
Meanwhile, heat a medium-sized pot or high-sided skillet over medium heat with the extra-virgin olive oil. Add the onions and garlic and saute for 3 to 4 minutes. Stir in the spinach, pulling it apart as you add it, and season with a little freshly grated nutmeg and salt, and pepper, to taste. When the spinach mixture is warmed through, transfer it to a small dish and reserve. Return the pot to the heat, add the butter and let it melt. Stir in the tomatoes and break them up with a spoon. Season with salt and pepper, to taste, add the basil leaves, and cook to thicken the sauce, about 7 to 8 minutes.
Preheat the oven to 400 degrees F.
Drain the pasta and return it to the hot pot. To the pasta, add the spinach, reserved pasta cooking water, ricotta cheese, and half of the Parmigiano-Reggiano. Adjust the salt and pepper, to taste, and transfer it to a baking dish. Top the pasta mixture with the tomato sauce, mozzarella, and remaining Parmigiano. Bake until the cheeses are melted and bubbly, 6 to 8 minutes. Remove the shells from the oven and serve.