$npx -y skills add fabioc-aloha/spotify-skill --skill spotify-apiCreate and manage Spotify playlists, search music, and control playback using the Spotify Web API. UNIQUE FEATURE - Generate custom cover art images (Claude cannot generate images natively, but this skill can create SVG-based cover art for playlists). CRITICAL - When generating c
| 1 | # Spotify API Skill |
| 2 | |
| 3 | **Version**: 0.9.1 | **Release Date**: October 22, 2025 |
| 4 | |
| 5 | ## Overview |
| 6 | |
| 7 | **This skill directly interacts with the Spotify Web API to manage music and playlists.** |
| 8 | |
| 9 | ### ⚡ Unique Capability: Image Generation |
| 10 | |
| 11 | **🎨 This skill can GENERATE IMAGES** - something Claude cannot do natively! It creates custom SVG-based cover art for Spotify playlists with large, readable typography optimized for thumbnail viewing. Each cover art is dynamically generated with theme-appropriate colors, gradients, and text layouts. |
| 12 | |
| 13 | Use this skill when you need to: |
| 14 | - 🎨 **Generate cover art images** - Create custom playlist covers (Claude's built-in image generation limitation is bypassed!) |
| 15 | - 🎵 **Create playlists** from artist names, themes, or specific songs |
| 16 | - 🔍 **Search** for tracks, artists, albums |
| 17 | - ➕ **Add/remove tracks** from playlists |
| 18 | - ▶️ **Control playback** (play, pause, skip) |
| 19 | - 📊 **Get user data** (profile, top tracks, listening history) |
| 20 | |
| 21 | **When to use this skill:** The user wants you to create a playlist, search for music, manage their Spotify account, **or generate custom cover art images**. |
| 22 | |
| 23 | ## Core Capabilities |
| 24 | |
| 25 | 1. **🎨 Cover Art Image Generation** - Generate custom images with SVG → PNG conversion (Claude cannot generate images natively!) |
| 26 | 2. **Intelligent Playlist Creation** - Create playlists by artist, theme, lyrics, or song list |
| 27 | 3. **Playlist Management** - Create, list, update, delete playlists |
| 28 | 4. **Search & Discovery** - Find tracks, artists, albums, playlists |
| 29 | 5. **Track Management** - Add/remove tracks, get recommendations |
| 30 | 6. **Playback Control** - Play, pause, skip, control volume |
| 31 | 7. **User Library** - Access saved tracks, profile, listening history |
| 32 | |
| 33 | ## Quick Start |
| 34 | |
| 35 | All Spotify API operations use the `SpotifyClient` class from `scripts/spotify_client.py`. The client handles OAuth authentication and provides methods for all operations. |
| 36 | |
| 37 | ### Prerequisites |
| 38 | |
| 39 | **1. Enable Network Access (REQUIRED)** |
| 40 | |
| 41 | ⚠️ **This skill requires network access to reach api.spotify.com** |
| 42 | |
| 43 | In Claude Desktop, you must enable network egress: |
| 44 | - Go to **Settings** → **Developer** → **Allow network egress** |
| 45 | - Toggle it **ON** (blue) |
| 46 | - Under "Domain allowlist", choose either: |
| 47 | - **"All domains"** (easiest), OR |
| 48 | - **"Specified domains"** and add `api.spotify.com` (more secure/restricted) |
| 49 | - This allows the skill to make API calls to Spotify's servers |
| 50 | |
| 51 | Without network access enabled, API calls will fail with connection errors. |
| 52 | |
| 53 | **2. Install Dependencies** |
| 54 | |
| 55 | ```bash |
| 56 | pip install -r requirements.txt |
| 57 | ``` |
| 58 | |
| 59 | Required packages: |
| 60 | - `requests>=2.31.0` - HTTP requests for Spotify Web API |
| 61 | - `python-dotenv>=1.0.0` - Environment variable management |
| 62 | - `cairosvg>=2.7.0` - SVG to PNG conversion for **image generation** |
| 63 | - `pillow>=10.0.0` - Image processing for **cover art creation** |
| 64 | |
| 65 | > **💡 Note:** The `cairosvg` and `pillow` packages enable **image generation** - allowing this skill to create cover art images even though Claude cannot generate images natively! |
| 66 | |
| 67 | ### Basic Setup |
| 68 | |
| 69 | The easiest way to initialize the client is using credentials from environment variables (loaded from `.env` file): |
| 70 | |
| 71 | ```python |
| 72 | from spotify_client import create_client_from_env |
| 73 | |
| 74 | # Initialize client from environment variables (.env file) |
| 75 | client = create_client_from_env() |
| 76 | |
| 77 | # If you have a refresh token, refresh the access token |
| 78 | if client.refresh_token: |
| 79 | client.refresh_access_token() |
| 80 | ``` |
| 81 | |
| 82 | Alternatively, you can manually provide credentials: |
| 83 | |
| 84 | ```python |
| 85 | from spotify_client import SpotifyClient |
| 86 | |
| 87 | # Initialize with credentials directly |
| 88 | client = SpotifyClient( |
| 89 | client_id="YOUR_CLIENT_ID", |
| 90 | client_secret="YOUR_CLIENT_SECRET", |
| 91 | redirect_uri="http://localhost:8888/callback", |
| 92 | refresh_token="YOUR_REFRESH_TOKEN" # if available |
| 93 | ) |
| 94 | |
| 95 | # Refresh to get current access token |
| 96 | if client.refresh_token: |
| 97 | client.refresh_access_token() |
| 98 | ``` |
| 99 | |
| 100 | ### Common Operations |
| 101 | |
| 102 | **List ALL user playlists (with pagination):** |
| 103 | ```python |
| 104 | # Get all playlists - handles pagination automatically |
| 105 | all_playlists = [] |
| 106 | offset = 0 |
| 107 | limit = 50 # Max allowed per request |
| 108 | |
| 109 | while True: |
| 110 | playlists = client.get_user_playlists(limit=limit, offset=offset) |
| 111 | if not playlists: |
| 112 | break # No more playlists |
| 113 | all_playlists.extend(playlists) |
| 114 | offset += limit |
| 115 | if len(playlists) < limit: |
| 116 | break # Last page (fewer than limit returned) |
| 117 | |
| 118 | print(f"Total playlists: {len(all_playlists)}") |
| 119 | for playlist in all_playlists: |
| 120 | print(f"- {playlist['name']} ({playlist['tr |