01 - Preheat oven to 375°F and lightly grease a 9x13-inch baking dish.
02 - Bring a large pot of salted water to a boil and cook ziti until al dente. Drain and set aside.
03 - Heat olive oil in a large skillet over medium heat. Add chopped onion and sauté for 3-4 minutes until softened. Add garlic and cook for 1 minute until fragrant.
04 - Add ground beef to the skillet, breaking it up with a spoon. Cook for 5-6 minutes until browned and cooked through. Drain excess fat if needed.
05 - Stir in marinara sauce, Italian seasoning, red pepper flakes (if desired), salt, and pepper. Simmer for 5 minutes, then remove from heat.
06 - In a medium bowl, mix ricotta, 1 cup mozzarella, ¼ cup Parmesan, and egg until smooth.
07 - Spread half of the cooked pasta in the baking dish. Top with half of the meat sauce and half of the ricotta mixture. Repeat layers with remaining pasta, sauce, and ricotta mixture.
08 - Sprinkle remaining 1 cup mozzarella and ¼ cup Parmesan evenly over the top.
09 - Cover with foil and bake for 25 minutes.
10 - Remove foil and bake for an additional 10-15 minutes until cheese is melted and golden. Let rest for 10 minutes before serving.