Bring a large pot of salted water to a boil. Add the spaghetti and cook according to the package instructions until al dente. Reserve 1 cup of pasta water, then drain the rest and set aside.
In a large skillet, heat the olive oil over medium heat. Add the minced garlic and sauté for about 1-2 minutes until fragrant but not browned.
Add the diced tomatoes (with their juices) to the skillet. Stir in the oregano, red pepper flakes (if using), salt, and pepper. Let it simmer for about 5 minutes to allow the flavors to meld.
Add the chopped spinach to the skillet and cook for an additional 2-3 minutes until wilted.
Add the drained pasta to the skillet, tossing everything together. If the mixture seems dry, add a little reserved pasta water until the desired consistency is reached.
Taste and adjust the seasoning if necessary. Serve the pasta hot, topped with grated Parmesan cheese and garnished with fresh basil leaves if desired.
For a heartier version, consider adding grilled chicken or shrimp.
This dish can also be made in advance and reheated, making it perfect for meal prep.