Cook the pasta according to package instructions.
Prepare the onions by slicing them thinly.
Heat olive oil in a large skillet over medium heat, and add the sliced onions with salt.
Caramelize the onions, stirring frequently, for 25-30 minutes until golden.
Add black pepper and red pepper flakes to the onions, cooking for another 2-3 minutes.
Add the cooked pasta to the onion mixture, tossing to combine.
Drizzle in the chili oil and a little reserved pasta water as needed, tossing to coat.
Serve topped with grated Parmesan and fresh basil.