Arrange a rack in center of oven; preheat to 400°. In a large ovenproof skillet or medium baking dish, combine shallot, garlic, tomatoes, and all but 1 Tbsp. oil; season with salt and red pepper flakes and toss to combine.
Place feta into center of tomato mixture; drizzle with reserved 1 Tbsp. oil. Scatter thyme sprigs over tomatoes.
Bake sauce until tomatoes are bursting and feta is golden on top, 40 to 45 minutes.
Meanwhile, in a large pot of boiling salted water, cook pasta, stirring occasionally, until al dente according to package directions. Reserve ½ cup pasta water before draining.
To sauce, add cooked pasta, reserved pasta water, and lemon zest (if using) and stir until combined. Top with basil.
