| name | spotify |
| description | Control Spotify playback, search, manage playlists, switch devices, and manage library via the spotify CLI. Use when the user wants to play/pause/skip music, search for songs/albums/artists, create or edit playlists, check what's playing, switch playback between devices, adjust volume, manage liked songs, seek within a track, view history, browse top tracks/artists, or get recommendations. Triggers on music-related requests like "play something", "create a playlist", "what's playing", "skip", "switch to iPhone", "add this to my playlist", "seek to 1:30", "show my history", "what are my top tracks", "recommend songs like this". |
Spotify (spotify CLI)
Control Spotify via spotify. Requires Spotify Premium.
- CLI location:
~/repos/spotify-cli/ (source in src/spotify/)
- Run:
uv run --directory ~/repos/spotify-cli spotify <command>
- Config:
~/.config/spotify-cli/config.json
Setup (one-time)
uv run --directory ~/repos/spotify-cli spotify auth
Opens browser → user authorizes → tokens stored automatically.
Commands
Playback
spotify play
spotify play "Sexbomb Tom Jones"
spotify pause
spotify next
spotify prev
spotify volume 60
spotify shuffle on
spotify repeat track
spotify seek 90
spotify seek 1:30
Status
spotify status
spotify status --json
Search
spotify search "Tom Jones"
spotify search "Random Access Memories" --type album
spotify search "Jazz Vibes" --type playlist
spotify search "Jamiroquai" --type artist --limit 5
spotify search "funk classics" --json
Queue
spotify queue "September Earth Wind Fire"
spotify queue add "September Earth Wind Fire"
spotify queue show
spotify queue show --limit 5
spotify queue show --json
History
spotify history
spotify history --limit 50
spotify history --json
Top
spotify top
spotify top tracks
spotify top artists
spotify top --time-range short
spotify top --time-range medium
spotify top --time-range long
spotify top --limit 20
spotify top --json
Recommendations
spotify recommend "Kate Bush"
spotify recommend "Get Lucky" --limit 20
spotify recommend "Billie Jean" --json
Devices
spotify devices
spotify device "iPhone"
spotify device "MacBook Air"
Playlists
spotify playlist list
spotify playlist create "Swagger & Groove"
spotify playlist create "Chill" --description "Relaxing"
spotify playlist add "Swagger & Groove" "Sexbomb" "Baby Come Back" "September"
spotify playlist add "Swagger & Groove" spotify:track:xxx
spotify playlist show "Swagger & Groove"
spotify playlist show "Swagger & Groove" --limit 20
spotify playlist remove "Swagger & Groove" "Sexbomb"
spotify playlist remove "Swagger & Groove" spotify:track:x
spotify playlist delete "Swagger & Groove" --yes
spotify playlist rename "Old Name" "New Name"
spotify playlist edit "My Mix" --name "Better Mix"
spotify playlist edit "My Mix" --description "New desc"
spotify playlist edit "My Mix" --name "N" --description "D"
spotify playlist reorder "My Mix" 3 1
spotify playlist play "Swagger & Groove"
spotify playlist dedupe "My Mix"
spotify playlist dedupe "My Mix" --dry-run
spotify playlist dedupe "My Mix" --json
Library
spotify like
spotify unlike
Agent Patterns
Seek to a specific position
spotify seek 1:30
spotify seek 90
Show listening history
spotify history --limit 10
spotify history --json
Discover top content
spotify top artists --time-range short
spotify top tracks --time-range long
Get recommendations and queue them
spotify recommend "Kate Bush Running Up That Hill" --limit 5
spotify queue add "Track A"
spotify queue add "Track B"
Recommend + play on specific device
spotify devices
spotify device "iPhone"
spotify play "Canned Heat Jamiroquai"
Build a playlist from recommendations
spotify playlist create "Swagger & Groove"
spotify playlist add "Swagger & Groove" "Sexbomb Tom Jones" "Baby Come Back Player" "September Earth Wind Fire" "Get Lucky Daft Punk" "Uptown Funk Mark Ronson"
Add currently playing to a playlist
spotify status --json
spotify playlist add "My Favorites" spotify:track:<uri_from_status>
Clean up a playlist
spotify playlist dedupe "My Mix" --dry-run
spotify playlist dedupe "My Mix"
Notes
- All read commands support
--json for structured output.
- Playlist matching is fuzzy by name; use exact Spotify ID if ambiguous.
spotify play <query> searches tracks by default; for albums use spotify search first.
- If no active device: prompt user to open Spotify on any device, then
spotify devices to verify.
- Auth tokens auto-refresh; no manual renewal needed.
spotify queue <query> (without subcommand) adds to queue for backward compatibility.
spotify top defaults to tracks, medium time range (~6 months), limit 10.
spotify recommend finds a seed track by search, then fetches Spotify recommendations from it.
spotify playlist reorder uses 1-indexed positions: reorder "My Mix" FROM TO moves the track at position FROM to before position TO.
Errors & Gotchas
Error: Insufficient client scope — the stored OAuth token is missing a required scope. Fix: (a) verify the scope is declared in src/spotify/auth.py (SCOPES list), add it if missing; (b) re-run spotify auth. The auth URL passes show_dialog=true, so the consent screen always re-prompts and the new scope is granted automatically — no need to revoke the app at spotify.com/account/apps. (Older builds without that flag silently reused prior consent and required the revoke dance.)
Error: Resource not found right after switching device — happens when play runs immediately after spotify device "<name>", especially for Bluetooth speakers. The device hasn't fully registered as active yet. Wait ~2 seconds (or re-check spotify devices until the target shows the active marker ●), then retry.
Error: Nothing is currently playing. — status, like, unlike, seek, queue add (and friends) all need an active playback session. Start playback in any Spotify client first.
- No active device —
play and friends will fail. Run spotify devices; if empty, open Spotify somewhere.
- Auth subcommand is just
spotify auth — there is no auth status. To inspect token state, look at ~/.config/spotify-cli/config.json (contains access_token, refresh_token, token_expiry).
- Premium required for any playback control; search and read commands work on free accounts.