Preheat the oven to 400°F
Slice the spaghetti squash in half lengthwise and scoop out the seeds
Drizzle with olive oil and sprinkle with the salt, black pepper, and garlic powder
Place the squash cut side down on a baking sheet and roast for 35-45 minutes, or until tender
Once cooked let the squash cool slightly, then scrape the flesh into strands with a fork
If using uncooked ground beef, cook it while the squash bakes
In a skillet, sauté onion in a little olive oil until soft, then add garlic and cook 1 minute more
Stir in the ground beef, marinara sauce, Italian seasoning, and any remaining salt and black pepper
Simmer for a few minutes, taste and adjust seasonings as desired
In a large bowl, combine the spaghetti squash strands with the marinara mixture
Stir in the ricotta, half of the mozzarella, the Parmesan, and the egg if using
Spread the mixture into a greased 9x13-inch baking dish
Top with the remaining mozzarella and a sprinkle of Parmesan
Bake at 375°F for 20-25 minutes, or until bubbly and golden on top
Let rest for 10 minutes before serving