Prepare the spaghetti squash:
Preheat your oven to 400°F (200°C). Cut the spaghetti squash in half lengthwise and scoop out the seeds. Drizzle the cut sides with olive oil, and sprinkle with salt and pepper. Place the squash cut-side down on a baking sheet. Roast for 40-45 minutes, or until the flesh is tender.
Once cooked, use a fork to scrape the flesh into strands. Set aside.
Prepare the filling:
In a large skillet over medium heat, cook the ground meat until browned. Drain any excess fat. Add the onion and garlic, cooking until softened and fragrant. Stir in the marinara sauce, Italian seasoning, red pepper flakes (if using), and season with salt and pepper. Simmer for 5-7 minutes.
Assemble the casserole:
Spread the roasted spaghetti squash evenly in the bottom of a greased 9x13-inch baking dish. Pour the meat sauce over the squash, spreading it evenly. Sprinkle the mozzarella and Parmesan cheeses over the top.
Cover the dish with aluminum foil and bake for 20 minutes. Remove the foil and bake for an additional 10-15 minutes, or until the cheese is bubbly and golden brown.
Serve:
Remove the casserole from the oven and let it cool for a few minutes. Garnish with fresh basil or parsley if desired. Serve warm and enjoy!