To make the filling, melt the butter in a large, deep, oven-safe skillet over medium heat. Add the onion and carrots and cook, stirring occasionally, until the onion softens and begins to brown, about 8 minutes. Add the ground beef, salt, and pepper and break up the beef into crumbles. Cook, stirring, until the beef is no longer pink.
Add the flour and stir until it absorbs all the moisture in the pan, about 1 minute. Stir in the stock, scraping the bottom of the pan to incorporate all of the flour. Reduce the heat to low and simmer until the carrots are tender, about 10 minutes. Take the skillet off the heat, taste for salt and pepper, and stir in the peas. (You can prepare the shepherd's pie filling up to 2 days in advance and reheat on the stovetop proceeding with the recipe.)
Meanwhile, make the topping by putting the potatoes and garlic cloves in a stockpot and adding enough cool water to cover them by 1 inch. Bring the water to a boil over medium-high heat then reduce the heat to low and simmer the potatoes until they are fork tender, 15 to 20 minutes. Drain the potatoes well, setting aside the garlic cloves, and return them to the pot to steam dry for 5 minutes.
Put the milk and butter into a large mixing bowl. Slip the skins from the potatoes and pass them through a ricer or food mill or hand mash them in the bowl, blending in the reserved garlic cloves, butter, and milk until smooth. Season the mashed potatoes with the salt, pepper, and nutmeg and taste them for seasoning. Whisk in the egg until the mashed potatoes are smooth and light.
Preheat the broiler to medium high with the top rack placed 8 inches below the element. Spread and smooth the mashed potatoes over the top of the filling to make the top "crust." Broil the shepherd's pie until the top is evenly golden brown, 8 to 10 minutes.
Source: Curry, Lynne. "Shepherd's Pie." Pure Beef: An Essential Guide to Artisan Meat with Recipes for Every Cut. Pennsylvania: Running Press Book Publishers, 2012. 86-87. Print.