I've had this command as 'git drop-merged' for a few years now (put as a script in your path named git-drop-merged:
#!/bin/sh git branch --merged | egrep -v "(^\*|master|main|dev)" | xargs --no-run-if-empty git branch -d