Heat the butter in a large oven-safe skillet over medium heat. Stir in the onions with a pinch of salt, pepper and thyme. It’s important to season each layer of cooking here! Cook, stirring often, until the onions caramelize, about 30 minutes. Be sure to watch them closely so they don’t burn! Turn down the heat if needed and continue to stir. Once caramelized, stir in the garlic. Turn off the heat once finished, but leave them in the pan.
While the onions are cooking, bring a pot of salted water to a boil and cook the pasta shells according to the directions. Once cooked, drain them and place them on a baking sheet or plate to cool.
Preheat the oven to 400 degrees F.
In a bowl, stir together the ricotta cheese, egg, gruyere cheese, parmesan cheese and a pinch of salt, pepper and dried thyme. Take half of the caramelized onions from the pan and stir them into the ricotta mixture. This is your filling!
Fill each shell with the filling, stuffing it full but not overflowing.
Turn the heat to medium-low under the remaining onions in the pan. Stir in the tablespoon of flour and cook for 1 to 2 minutes. Slowly stream in the stock while stirring. Cook for 2 to 3 minutes - the mixture will thicken a bit. Stir in the cream. Turn off the heat and place the shells open-side up in the french onion sauce. Top with the mozzarella cheese and breadcrumbs.
Bake for 20 to 25 minutes, until golden and bubbly. Serve immediately with extra parmesan and fresh herbs on top.