Cook spaghetti squash. (see notes) When cool enough to handle, slice in half, remove seeds and stringy bits and shred with 2 forks. Set aside squash.
In a large saute pan, heat oil over medium heat. Add onions and mushrooms, stirring constantly, about 3-4 minutes. Add garlic and stir another minute or 2, just until fragrant. Don't let garlic brown.
Add tomatoes and continue stirring.
Add cooked spaghetti squash and toss until squash is hot and vegetables are evenly distributed.
Toss with fresh basil and toasted pine nuts. Season to taste with kosher salt, pepper and a pinch of red pepper flakes if desired.