Bring a large pot of generously salted water to a rolling boil. Add the spaghetti and cook until just al dente, about 8-10 minutes, stirring occasionally. Drain, reserving a cup of pasta water, and set aside.
While the pasta cooks, rinse and chop the ripe tomatoes into small chunks. Thinly slice the garlic cloves and set aside. Rinse the basil leaves and tear or chop them roughly.
Heat the olive oil in a large frying pan over medium heat until it shimmers and begins to smell fragrant. Add the sliced garlic and sauté for about 30 seconds until golden and fragrant, stirring constantly to prevent burning.
Add the chopped tomatoes to the pan. Cook, stirring occasionally, for about 5-7 minutes until the mixture thickens slightly and the oil begins to separate from the sauce. Season generously with sea salt and add chili flakes if using.
Drop the cooked spaghetti into the pan with the sauce. Toss gently with tongs or a wooden spoon to coat the pasta evenly, adding a splash of reserved pasta water if needed to loosen the sauce and help it cling to the noodles.
Add the torn basil leaves to the pasta and stir gently just until they wilt and release their aroma. Cook for another minute to meld the flavors.
Remove the pan from heat, taste and adjust seasoning with more salt or a squeeze of lemon if desired. Serve immediately, garnished with additional basil leaves if preferred.