Cook the pasta shells according to the package instructions until al dente. Drain and set aside, reserving some pasta cooking water.
In a large skillet, heat the olive oil over medium heat. Add the minced garlic and chopped shallot, and sauté until fragrant and softened, about 2-3 minutes.
Add the fresh spinach leaves to the skillet and cook, stirring occasionally, until wilted, about 2-3 minutes.
Stir in the drained and rinsed cannellini beans, red pepper flakes (if using), and cooked pasta shells. Toss everything together until well combined.
If the pasta seems dry, add a splash of reserved pasta cooking water to loosen it up.
Season the pasta shells with salt and pepper to taste, adjusting the seasoning as needed.
Serve the pasta shells with spinach and cannellini beans hot, garnished with grated Parmesan cheese if desired.
Enjoy this delicious and nutritious pasta dish as a satisfying meal on its own, or pair it with a side salad or crusty bread for a complete and balanced dinner.