01 - Preheat oven to 350°F. Line two baking sheets with parchment paper.
02 - In a heatproof bowl, melt dark chocolate and butter together over a pot of simmering water (double boiler method), stirring until smooth. Remove from heat and let cool slightly.
03 - In a large mixing bowl, whisk together granulated sugar, brown sugar, eggs, and vanilla extract until pale and slightly thickened, about 2 minutes.
04 - Stir 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.
07 - Fold the dry ingredients into the wet mixture with a spatula until just combined.
08 - Gently fold in chocolate chips and nuts, if using.
09 - Using a cookie scoop or tablespoon, drop dollops of dough (about 2 tablespoons each) onto prepared baking sheets, spacing 2 inches apart.
10 - Bake for 10–12 minutes until cookies are puffed with crackly tops and just set around edges (centers will look soft).
11 - Allow cookies to cool on baking sheet for 5 minutes, then transfer to wire rack to cool completely.