01 - Preheat oven to 350°F. Line two baking sheets with parchment paper.
02 - Melt dark chocolate and butter together in a heatproof bowl over a pot of simmering water, stirring until smooth. Remove from heat and let cool slightly.
03 - Whisk together granulated sugar, brown sugar, eggs, and vanilla extract in a large mixing bowl until pale and slightly thickened, about 2 minutes.
04 - Stir the sourdough discard into the egg mixture until fully incorporated.
05 - Pour the melted chocolate-butter mixture into the egg mixture, whisking until smooth and glossy.
06 - Sift together flour, cocoa powder, baking powder, and sea salt. Fold dry ingredients into the wet mixture with a spatula until just combined.
07 - Gently fold in chocolate chips and nuts, if using.
08 - Drop dough onto prepared baking sheets using a cookie scoop or tablespoon, about 2 tablespoons each, spacing 2 inches apart.
09 - Bake for 10–12 minutes until cookies are puffed with crackly tops and just set around edges. Centers will look soft.
10 - Cool on baking sheet for 5 minutes, then transfer to wire rack to cool completely.