Heat olive oil or butter in a large skillet over medium heat.
Add onion (if using) and cook until soft. Add garlic and cook 30 seconds.
Add uncooked pasta and pour in water or broth until just covered.
Bring to a simmer and cook, stirring occasionally, until pasta is tender.
Lower heat and stir in the cream. Let simmer until slightly thickened.
Add pesto and mix until fully combined.
Remove from heat and stir in Parmesan cheese.
Season with salt, pepper, and red pepper flakes.
Top with crispy chicken if using and serve warm.