Set pasta to boil.
If using frozen spinach, defrost it in the microwave for about four minutes and set aside.
While the pasta is cooking, heat the olive oil in a saute pan. Add a touch of butter to keep the garlic and onion from burning, then add the chopped onion and minced garlic. Saute 5 minutes.
Add the chickpeas and spinach, stirring. Season with salt and pepper and, if using, red pepper/chili flakes to taste. Cook, stirring, for several minutes.
Add the cream cheese to the edge of the pan, letting it melt along the edges so that it doesn’t clump up in the middle of the pan as you stir it into the spinach mixture.
Drain pasta and set aside, reserving at least one cup of pasta water. Add the pasta water bit by bit to the spinach mixture, stirring and adding more as necessary to achieve desired consistency.
Toss with pasta; taste and adjust seasonings.
Serve with freshly grated pecorino cheese.