This is an applescript to dismiss MacOS notifications without having to mouse over and fiddle with the disappearing dismiss / clear button. You can download the scpt file and run it with Automator or from Terminal, or you can copy the contents and run it from a launcher like Alfred. I like the latter solution, and have assigned it the command key ⌃⇧D
There are two versions, one for versions up to Monterey (OS 12) and one for Ventura (OS 13).
None of this is my original work. The pre-Ventura code comes from StackExchange user lunzwell on this post with a small addition I pulled from this Apple forum post to return focus when complete. The Ventura version comes from Christian Bender, here.