I noticed maggots in my compost scraps recently (not yet mixed in the tumbler). Is this all right? Should I do something to prevent this in the future? If so, what?
It's common; it's up to you whether it's desirable.
The maggots will eat food scraps in your compost, helping to break them down faster. Then they will turn in to flies, which are annoying and perhaps unsanitary.
Some people deliberately attract Black Soldier Fly maggots, which are particularly good at breaking down compost.
If you're including manure in your compost, I think it's particularly important to discourage maggots/flies, to prevent them from spreading germs.
I have a lot of compost, with lots of manure, but I get 0 flies. I attribute that success to two factors:
I include brown materials (sawdust) in compost, to get a good balance of nice balance of carbon and nitrogen. It's not a delicate balance, but it still matters.
I cover my compost pile with a thick layer of straw. This keeps the attractive smells in, and the flies out.
When I add to my compost pile, I push the straw aside, add the new material, then add more straw on top.
I found this article helpful which stated:
... improperly constructed [compost] piles, piles that are not turned regularly or piles that have thinner areas along the edges can provide refuge and breeding areas for some insects, according to U of I entomologist Phil Nixon. These cooler areas of the pile can harbor stable flies, house flies, and green June beetles.
To avoid the maggots, I suggest you ensure you are turning your compost pile regularly and that you try to minimize the areas that are thinner, and thus cooler. One way this can be accomplished is by not just having a pile for your compost, but having some kind of structure to contain it and provide some regularity to its dimensions.