Preheat the oven to 350ºF and line two baking sheets with parchment paper. If you plan to chill or ferment the dough, wait to preheat the oven until you are ready to bake.
In the bowl of a stand mixer, beat the softened butter on medium speed for about 1 minute. Add the brown sugar and granulated sugar, then cream together until light and fluffy.
Add the sourdough discard and egg yolk to the butter mixture. Mix until smooth and creamy, scraping down the sides of the bowl as needed.
In a separate bowl, whisk together the flour, cocoa powder, baking soda, and salt.
Add the dry ingredients to the butter mixture and mix just until combined. The dough should come together into a firm chocolate cookie dough.
At this point, you can scoop and bake the cookies right away, or cover the dough and chill it in the refrigerator for 4 to 6 hours or overnight for more flavor.
Scoop the cookie dough into small, equal portions. Roll each scoop into a ball and place the dough balls on the prepared baking sheets, leaving space between each one. You should have about 24 to 28 cookie dough balls.
Bake for 10 minutes, or until the edges are set and the centers still look slightly soft.
Let the cookies cool on the baking sheet for 5 to 10 minutes, then transfer them to a wire rack to cool completely.
Beat the butter and cream cheese together with the paddle attachment of a stand mixer on medium speed until smooth.
Scrape down the bowl, then add ½ cup powdered sugar, vanilla, and a pinch of salt. Mix until fluffy. If the filling seems too thin, add more powdered sugar a little at a time until it is thick enough to hold between the cookies.
Spread or pipe the filling onto the flat side of half the cookies. Top with the remaining cookies, press down lightly, and enjoy.