Preheat your oven to 375°F (190°C). Lightly grease a 12-cup muffin tin with olive oil or melted butter, or line with silicone or paper liners.
In a medium bowl, whisk together the eggs, heavy cream, pesto, garlic powder, onion powder, salt, and black pepper until well combined and smooth.
In a separate large bowl, add the cooked chicken, shredded mozzarella, grated Parmesan, and chopped spinach or basil (if using). Toss to combine and break up any clumps of chicken.
Pour the egg and pesto mixture over the chicken and cheese mixture. Stir everything together until the chicken is evenly coated and the ingredients are well distributed.
Divide the mixture evenly among the 12 muffin cups, filling each about 3/4 full. Use a spoon to make sure the chicken is evenly spread so every cup has a good mix of filling.
Bake in the preheated oven for 18–22 minutes, or until the cups are set in the center and lightly golden around the edges. A toothpick inserted in the center should come out mostly clean.
Remove the muffin tin from the oven and let the cups cool in the pan for about 5 minutes to firm up. Then carefully run a knife around the edges (if not using liners) and lift out the cups.
Serve warm, or let them cool completely before storing. For meal prep, place cooled cups in an airtight container and refrigerate for up to 4 days. Reheat in the microwave for 20–30 seconds or in a low oven until warmed through.