In general, spaghetti should be cooked until the noodles are fully softened but still have a firmness to them when you bite. This is called “al dente,” which literally means “to the tooth.” You want to have something to chew, not just mush!  In a baked pasta dish like this one, we recommend cooking the pasta according to the shortest time on the package instructions (for example: if the package says 10 - 12 minutes, cook it for 10). That way, when the pasta continues to cook in the oven, it will reach that “al dente” stage instead of overcooking and becoming mushy.