Preheat the oven to 400 degrees F. Line a sheet pan with parchment paper.
Oil the inside of the spaghetti squash with 2 tablespoons oil and sprinkle with a good pinch of salt and pepper. Place cut-side down on the prepared sheet pan and bake until fork-tender, 40 to 45 minutes.
Meanwhile, add the remaining 2 tablespoons olive oil to a large pan over medium heat. When the oil is hot, add the onion, carrot and celery. Season with a pinch of salt and pepper, then cook, stirring, until the vegetables are soft, about 5 minutes. Stir in the garlic, thyme and red pepper flakes. Add the beef, crumbling it as you go, and cook until thoroughly browned, another 5 minutes. Add the marinara sauce and stir to combine. Allow the sauce to simmer until the squash is cooked, 15 to 20 minutes.
Remove the squash and allow it to cool slightly, about 5 minutes, or until cool enough to handle. Use a fork to loosen the squash and form spaghetti-like strands.
Serve the sauce over a bowl of the spaghetti squash noodles, or inside the squash halves, topped with Parmesan and lots of basil.