Bring 4 L of water to a boil in a 5-liter / 5-quart pot. While it heats, halve the tomatoes, slice the garlic thinly, mix the pecorino and Parmigiano in a bowl, and tear the basil. Add 24 g coarse salt once the water boils.
Warm the olive oil, garlic and chili in a 30 cm / 12-inch deep sauté pan over medium-low heat for 2 minutes, until the garlic is pale gold and fragrant. Don't let it brown or it turns bitter.
Add the tomatoes and a pinch of salt, raise the heat to medium, and cook for 12 to 14 minutes. Press the tomatoes with a wooden spoon as they soften, until the skins wrinkle, the fruit collapses and the sauce is jammy with oil glistening at the edges.
While the sauce cooks, add the spaghetti to the boiling water and cook for 2 minutes less than the package time, usually about 8 minutes. Scoop out 250 ml pasta water, then drain.
Tip the spaghetti into the sauce with 120 ml of the pasta water and half the basil. Toss over medium heat for 1 to 2 minutes until the sauce clings to the strands.
Take the pan off the heat and wait 30 seconds. Add the grated cheeses and toss, adding up to 60 ml more pasta water, until the sauce looks glossy and creamy. Finish with black pepper and the remaining basil, and serve at once.