01 - Preheat the oven to 375°F. Lightly grease a 9x13-inch baking dish.
02 - Bring a large pot of salted water to a boil. Cook the ziti until al dente according to package directions. Drain and set aside.
03 - Heat olive oil in a large skillet over medium heat. Add chopped onion and sauté for 3 to 4 minutes until softened. Add minced garlic and cook for 1 minute until fragrant.
04 - Add ground beef to the skillet. Cook, breaking up the meat with a spoon, until browned and fully cooked, about 5 to 6 minutes. Drain excess fat if necessary.
05 - Stir in marinara sauce, Italian seasoning, crushed red pepper flakes if using, salt, and pepper. Simmer for 5 minutes to develop flavor. Remove from heat.
06 - In a medium bowl, combine ricotta cheese, 1 cup of mozzarella, ¼ cup Parmesan, and the egg until fully blended.
07 - Spread half of the cooked ziti in the prepared baking dish. Top with half of the meat sauce, then dollop half of the cheese mixture evenly over the sauce. Repeat layers with remaining pasta, sauce, and cheese mixture.
08 - Sprinkle the remaining 1 cup mozzarella and ¼ cup Parmesan evenly over the assembled layers.
09 - Cover the dish with foil and bake for 25 minutes.
10 - Remove foil and bake an additional 10 to 15 minutes until the cheese is melted, bubbly, and lightly golden.
11 - Allow the dish to rest for 10 minutes before serving. Garnish with fresh basil or parsley as desired.