Preheat your oven to 375°F (190°C).
Cook the pasta shells according to package directions, but keep them slightly undercooked (very al dente). They'll finish cooking in the oven. Drain and rinse with cool water to stop the cooking process. Set aside on a baking sheet to prevent sticking.
While the pasta cooks, prepare the filling. Heat olive oil in a large skillet over medium heat. Add the Italian sausage, breaking it into small crumbles as it cooks until browned and no longer pink, about 5-7 minutes.
Add the diced onion to the skillet with the sausage. Cook until softened, about 3-4 minutes.
Stir in the minced garlic and cook for another 30 seconds until fragrant. If using spinach, add it now and cook until wilted, about 1-2 minutes.
Remove from heat and let the sausage mixture cool slightly while you prepare the cheese filling.
In a large mixing bowl, combine the ricotta, egg, 1 cup of mozzarella, 1/4 cup of Parmesan, basil, parsley, oregano, and nutmeg (if using). Season with salt and pepper to taste.
Add the cooled sausage mixture to the cheese mixture and stir until well combined.
Prepare the baking dish by spreading 1 cup of marinara sauce evenly across the bottom.
Fill each pasta shell with a generous spoonful of the sausage and ricotta mixture. Place the filled shells in the baking dish, open side up.
Pour the remaining marinara sauce over the stuffed shells. Sprinkle with red pepper flakes if using.
Top with the remaining mozzarella and Parmesan cheese.
Cover the dish with aluminum foil and bake for 25 minutes. Then remove the foil and bake for an additional 5-10 minutes until the cheese is bubbly and golden.
Let the dish rest for 5 minutes before serving. Garnish with additional fresh herbs if desired.