Control the Spotify macOS app from Raycast.
An extensive walk-through on how to build such an extension can be found on the developers docs.

Plays current track in Spotify.
Pause current track in Spotify.
Toggles play or pause of current track in Spotify.
Skips to the previous track in Spotify.
Skips to the next track in Spotify.
Currently playing track in Spotify.
Skips backward x seconds in Spotify.
Skips forward x seconds in Spotify.
Increase volume in Spotify.
Decrease volume in Spotify.
Sets volume to 25% in Spotify.
Sets volume to 50% in Spotify.
Sets volume to 75% in Spotify.
Sets volume to 100% in Spotify.
Currently playing song's URL in Spotify.
Toggles shuffle mode in Spotify.
Plays current track with shuffle enabled.
Toggles repeat mode in Spotify.
Add Decrease volume and Increase volume commands.
Fixed shuffle and repeat commands on Spotify Controls.
Adds Toggle Repeat and Shuffle mode.
Adds currently playing and copy URL commands.
Add Spotify Controls extension
Add command preferences for enabling Next Track / Previous track HUD.