Preheat oven to 375 degrees F.: The room begins to fill with warm, dry heat that helps the cheese brown evenly, and setting the oven early prevents waiting. You should feel the subtle warmth if you open the oven briefly, and hear a soft fan hum on convection models. A common mistake is putting a cold dish into a cold oven, which can lengthen bake times and produce uneven melting, so set the temperature before you start layering.
Cook the spaghetti to al dente, according to package instructions. Drain and set aside. If the noodles are going to be sitting for several minutes, you can drizzle a little olive oil over them and toss so they don’t stick together.: When the pot reaches a rolling boil, the steam rises and the scent of starch fills the kitchen; cook until the strands have a slight resistance when bitten, not limp. Drain promptly to stop the cooking and toss with a touch of olive oil to prevent clumping, which keeps strands separate while you assemble. If you overcook, the pasta will become mushy in the oven, so test early and often to get the right texture.
Place the beef or sausage in a large skillet and cook over medium heat. Break up with a wooden spoon while cooking until browned and no longer pink. Drain off excess fat and transfer to a plate that has been lined with paper towels. Set aside.: As the meat sizzles, you will hear steady popping and smell savory, browned aromas that signal the Maillard reaction, which is crucial for deep flavor. Break the meat into small pieces to maximize contact with the hot pan so it browns rather than steams. Draining excess fat prevents a greasy sauce, a common error when skipping this step.
In the same large skillet, heat the olive oil over medium-high heat. Add the onion and cook until translucent, about 5 minutes. Add the garlic and cook for 1 minute.: The pan will shimmer as the olive oil warms, and the onion will soften and release a gentle sweetness as it turns translucent. Adding garlic after prevents burning and preserves its aromatic quality; burned garlic tastes bitter and can undermine the sauce, so watch the minute closely and reduce heat if it starts to brown too fast.
Add the marinara sauce, tomatoes, basil, oregano, and red pepper flakes. Turn to low and simmer for 5 minutes. Season with salt and pepper, to taste. Stir the cooked beef or sausage into the sauce.: When the canned marinara sauce and diced tomatoes hit the pan, steam rises and the mixture loosens into a cohesive sauce. Lowering to a simmer allows the dried basil and oregano to rehydrate and release flavor without evaporating too quickly. Stir in the browned meat so it absorbs the seasoned sauce; failing to simmer long enough can result in a flat tasting finish, so allow those minutes for flavor melding.
In a small bowl, combine the ricotta cheese, egg, and Parmesan cheese.: The texture should become creamy and glossy as the egg binds the ricotta cheese and Parmesan cheese . This mixture will provide a luscious layer that contrasts the tomato base. If the mix seems too runny, chilling briefly will firm it up; on the other hand, streaks of undermixed egg can lead to uneven pockets, so whisk thoroughly for an even color and texture.
Spray a 9×13-inch baking pan with nonstick cooking spray. Place half of the cooked spaghetti noodles on the bottom of the pan. Pour half of the meat sauce over the noodles.: The pan should be warm to the touch from ambient kitchen heat, and the first layer of spaghetti creates a sturdy foundation. Spread the sauce so it seeps between strands, ensuring every bite has both pasta and sauce. A common misstep is piling too much pasta in one area, which leads to uneven baking, so distribute the strands evenly across the pan.
Spoon the ricotta cheese mixture over the sauce and use a spatula to spread it in an even layer. Top with 3/4 cup of the shredded mozzarella cheese.: The ricotta will feel cool and creamy against the warm sauce, and spreading it creates pockets that bake into tender, custardy bites. Adding part of the mozzarella cheese now ensures melty layers inside the casserole. If you dollop without spreading, you may end up with uneven pockets, so smooth it gently for consistent slices.
Add the remaining spaghetti and then the rest of the sauce. Top with the remaining mozzarella cheese.: Layering the second half of spaghetti and sauce builds height and ensures each piece contains both elements. The last layer of mozzarella cheese will bubble and brown into a golden crown. Avoid pressing down hard on the top layer, which can compress textures and leave the dish dense rather than light.
Bake for 25-30 minutes or until bubbly and the cheese is melted and starting to brown. Remove from the oven and garnish with extra Parmesan cheese and fresh basil, if desired. Cut into squares and serve warm.: As it bakes, the kitchen will fill with a warm, tomato and toasted cheese aroma, and you may hear gentle bubbling from the sauce. Visual cues include a golden rim and small browned spots on the mozzarella cheese . Let it rest briefly so layers set, making slicing cleaner and preventing hot cheese from sliding off. Cutting too soon can lead to collapse and messy servings, so give it a few minutes to settle.