Preheat the oven to 350°F (175°C). Lightly grease a standard 12-cup muffin pan.
In a medium bowl, whisk together the flour, cocoa powder, baking soda, and salt.
In a separate large bowl, beat the softened butter, granulated sugar, and brown sugar until smooth and creamy.
Beat in the egg and vanilla extract until fully combined.
Gradually add the dry ingredients and mix just until a soft chocolate dough forms. Avoid overmixing.
Divide the dough evenly among the muffin cups. Press each portion gently into the bottom and slightly up the sides to create a cup shape
Bake for 10 to 12 minutes, until the edges are set and the centers are still slightly soft.
Remove the pan from the oven. While the cookies are warm, gently press the centers down with the back of a small spoon or rounded measuring spoon to deepen the cavities.
Let the cookie cups cool in the pan for several minutes, then transfer them to a cooling rack.
To make the filling, combine the sugar, cocoa powder, and flour in a small saucepan. Gradually whisk in the milk until smooth.
Add the egg yolks and salt. Cook over medium heat, whisking frequently, until the mixture thickens into a smooth chocolate custard.
Remove from the heat and stir in the butter and vanilla until smooth and glossy. If needed, strain the filling through a fine-mesh sieve.
Allow the filling to cool, then spoon or pipe it into the cooled cookie cups.
For the whipped cream, beat the cold heavy cream, powdered sugar, and vanilla until soft to medium peaks form.
Spoon or pipe whipped cream over each chocolate-filled cookie cup.
Garnish with chocolate shavings or mini chocolate chips.
Refrigerate for at least 30 minutes before serving.