Skimming foam from stock without removing floating spices
I tend to just stick the spices in a tea egg 

I do this whenever I think the spices will get in the way during my process or when I want to remove them before serving, such as in case of a bouquet garni, cloves or juniper berries. 

Should you be reluctant to use metal in your recipe you can of course use loose leaf tea bags.

Either way you can just lift the spices out whenever you want to skim the top of your broth.