Preheat the oven to 375ºF.
In a large skillet, melt the butter over medium heat. Add the onions and cook until beginning to soften, about 3 minutes.
Add the garlic, Italian seasoning, salt, pepper, and red pepper flakes, and cook another minute.
Add the spinach a few handfuls at a time, allowing it to cook down a bit before adding more. Cook until all of the spinach is wilted, about 5 minutes.
Using a slotted spoon, transfer to a mixing bowl, leaving as much liquid in the pan as possible (be sure to get all the pieces of onion and garlic into the bowl).
Add the cottage cheese, half of the gruyere, half of the parmesan, and the egg. Stir to combine well.
Spread the mixture in a ceramic baking dish that holds 1.5 to 2 quarts. Top with the remaining shredded cheese and parmesan.
Bake about 25 minutes, until the mixture is bubbly, and the cheese is melted and beginning to brown on top.
