1Heat the oven to 350°F and arrange a rack in the middle. Line 2 (12-well) muffin pans with paper liners; set aside.
2Whisk together the flour, baking soda, and salt in a medium bowl; set aside.
3Whisk together the cocoa and boiling water in a small bowl until combined. Slowly whisk in the milk; set aside.
4Place the butter in the bowl of a stand mixer fitted with a paddle attachment and beat on medium-high speed until fluffy and light in color, about 3 minutes. Add the sugar and vanilla and continue to beat for another 4 minutes. Stop the mixer and scrape down the sides of the bowl and the paddle with a rubber spatula.
5Return the mixer to medium-high speed. Add the eggs 1 at a time, letting each incorporate fully before adding the next. Stop the mixer and scrape down the sides of the bowl and the paddle.
6Add a third of the flour mixture and turn the mixer to low speed, mixing until the flour is just incorporated. Add half of the cocoa mixture and mix until just incorporated. Continue adding the remaining flour mixture and cocoa mixture, alternating between each and ending with the flour, until all of the ingredients are incorporated and smooth. Stop the mixer, remove the bowl, and stir in any remaining flour streaks by hand, making sure to scrape the bottom of the bowl.
7Divide the batter among the muffin wells (the wells will be about two-thirds full). Place the pans side by side in the oven and bake for 15 minutes. Rotate the pans front to back and side to side and bake until a toothpick inserted into the center of the cupcakes comes out clean, about 10 minutes more.
8Place the pans on wire racks and let them cool for 10 minutes. Remove the cupcakes from the pans and cool completely on the racks before frosting, about 40 minutes. Meanwhile, make the frosting.
For the peanut butter frosting and decorating:
1Place the butter, peanut butter, and salt in the bowl of a stand mixer fitted with a paddle attachment and beat on high speed until light, fluffy, and fully incorporated, about 3 minutes. Stop the mixer and scrape down the sides of the bowl and the paddle with a rubber spatula.
2Turn the mixer to low and slowly add the powdered sugar until it’s incorporated, about 30 seconds. Stop the mixer, scrape down the sides of the bowl and the paddle, and turn the mixer to medium-high speed. Mix until the frosting is creamy and fluffy, about 3 minutes.
3Frost the cupcakes and sprinkle with the chocolate, if using. If you don’t plan to eat the cupcakes within 4 hours, refrigerate them until the frosting stiffens, then tent loosely with plastic wrap for up to 3 days. Before serving, let the cupcakes sit at room temperature for about 45 minutes to take the chill off.