A comprehensive clawdbot skill that integrates with the Spotify Web API, enabling agentic control of playback, queue management, library operations, and music discovery.
This skill provides:
- OAuth 2.0 Authentication - VPS-aware flow with automatic token refresh
- Playback Control - Play, pause, skip, volume, shuffle, repeat
- Queue Management - Add tracks to queue
- Device Control - List devices, transfer playback
- Search & Discovery - Search catalog, get recommendations
- Library Management - Save/remove tracks, view playlists
clawd-spotify/
├── README.md # This file
├── SKILL.md # Clawdbot skill documentation
├── src/
│ └── spotify-oauth.ts # OAuth authentication implementation
└── scripts/
├── lib/
│ └── spotify-api.mjs # Core API client library
├── current.mjs # Show currently playing track
├── play.mjs # Start/resume playback
├── pause.mjs # Pause playback
├── next.mjs # Skip to next track
├── previous.mjs # Go to previous track
├── volume.mjs # Set volume (0-100)
├── shuffle.mjs # Toggle shuffle mode
├── repeat.mjs # Set repeat mode
├── queue-add.mjs # Add track to queue
├── devices.mjs # List available devices
├── transfer.mjs # Transfer playback to device
├── search.mjs # Search Spotify catalog
├── library-tracks.mjs # Manage saved tracks
├── playlists.mjs # List user playlists
└── recommendations.mjs # Get track recommendations
- Go to https://developer.spotify.com/dashboard
- Create a new app
- Set redirect URI to:
http://localhost:8888/callback - Copy your Client ID and Client Secret
Option A: Copy to clawdbot skills directory
# Copy the skill to clawdbot's skills directory
cp -r . /path/to/clawdbot/skills/clawdify/
# Copy OAuth command to clawdbot commands
cp src/spotify-oauth.ts /path/to/clawdbot/src/commands/Option B: Symlink (for development)
# Create symlink to skills directory
ln -s $(pwd) /path/to/clawdbot/skills/clawdify
# Create symlink for OAuth command
ln -s $(pwd)/src/spotify-oauth.ts /path/to/clawdbot/src/commands/spotify-oauth.tsAdd to your clawdbot config (~/.clawdbot/config.json5):
{
skills: {
clawdify: {
clientId: "your-client-id-here",
clientSecret: "your-client-secret-here"
}
}
}Or set environment variables:
export SPOTIFY_CLIENT_ID="your-client-id-here"
export SPOTIFY_CLIENT_SECRET="your-client-secret-here"OAuth implementation is complete and ready to use.
To integrate the OAuth command into your Clawdbot installation:
- See the complete example:
examples/clawdbot-command.example.ts - Read the integration guide:
INTEGRATION.mdhas detailed instructions - Register the command in your Clawdbot's command system
- Run authentication:
clawdbot auth-spotify(or your chosen command name)
The OAuth module (dist/spotify-oauth.js) provides:
loginSpotifyVpsAware()- Auto-detects local vs VPS/SSH environmentloginSpotifyLocal()- Local callback server on localhost:8888loginSpotifyManual()- Manual URL paste for remote environments
Once integrated, the OAuth flow will:
- Open authorization URL in your browser (or show URL for VPS/SSH)
- Request necessary Spotify permissions
- Save OAuth tokens to
~/.clawdbot/auth-profiles.json - Auto-refresh tokens when expired (5-minute buffer)
See SKILL.md for complete documentation of all available commands.
# Show currently playing track
node scripts/current.mjs
# Play a specific track
node scripts/play.mjs spotify:track:6rqhFgbbKwnb9MLmUQDhG6
# Search for music
node scripts/search.mjs "Bohemian Rhapsody"
# Add to library
node scripts/library-tracks.mjs add spotify:track:6rqhFgbbKwnb9MLmUQDhG6
# List available devices
node scripts/devices.mjs- Node.js - For running the scripts
- Spotify Premium - Required for playback control features
- Active Spotify device - Must have Spotify open somewhere (phone, desktop, web player)
The OAuth implementation is complete. The compiled module (dist/spotify-oauth.js) exports:
loginSpotifyVpsAware()- Main entry point, auto-detects environmentloginSpotifyLocal()- Local callback server modeloginSpotifyManual()- Manual URL paste mode for VPS/SSH
To integrate into Clawdbot:
- See
examples/clawdbot-command.example.tsfor a complete, ready-to-use command implementation - Copy/adapt the example to your Clawdbot's command system
- The command should:
- Get client credentials from config or environment
- Call
loginSpotifyVpsAware()to run OAuth flow - Store credentials in
auth-profiles.jsonwith profile IDspotify:default
- See
INTEGRATION.mdfor detailed integration patterns and examples
Credentials are stored in ~/.clawdbot/auth-profiles.json:
{
"version": 1,
"profiles": {
"spotify:default": {
"type": "oauth",
"provider": "spotify",
"access": "BQD...",
"refresh": "AQD...",
"expires": 1704931200000,
"email": "user@example.com"
}
}
}All scripts use the shared lib/spotify-api.mjs library which handles:
- Loading credentials from auth-profiles.json
- Automatic token refresh (5-minute buffer)
- Authenticated API requests
- Error handling
Each script can be tested independently:
# Set environment variables
export SPOTIFY_CLIENT_ID="your-client-id"
export SPOTIFY_CLIENT_SECRET="your-client-secret"
# Run a script
node scripts/current.mjs-
Import the shared library:
import { spotifyRequest } from './lib/spotify-api.mjs';
-
Make API calls:
const data = await spotifyRequest('/me/player');
-
Handle errors gracefully:
try { // API call } catch (err) { console.error(`Error: ${err.message}`); process.exit(1); }
See the troubleshooting section in SKILL.md for common issues and solutions.
This skill is part of the clawdbot ecosystem.