Preheat the oven to 350 degrees. Coat a shallow baking dish or ovenproof skillet with olive oil.
Cook the pasta according to the package directions. Drain and transfer to a large bowl. Add the tomato sauce, pesto, crushed red pepper flakes, 1/2 teaspoon salt, and 1/4 teaspoon black pepper and stir to combine.
Transfer the pasta to the prepared pan and top with the cheese. Cover with foil and bake 20 minutes.
Uncover and bake for 5 to 10 more minutes, until the cheese melts.