Managing Spotify Playlists logo

Managing Spotify Playlists

Community
rianvdm
managing-spotify-playlists

Use when the user wants to create, inspect, or change a Spotify playlist (add, remove, reorder, dedupe, rename, visibility, set cover). For designing the cover image use playlist-cover.

Overview

Publisherrianvdm
Repositoryproduct-ai-public
Skill namemanaging-spotify-playlists
Stars
20
Forks
4
Bundled files
Instructions only
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by rianvdm on GitHub. Read the source before you install it.

Installation

Install the Managing Spotify Playlists AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/rianvdm/product-ai-public/tree/main/music/managing-spotify-playlists
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/rianvdm/product-ai-public.git /tmp/product-ai-public
mkdir -p .claude/skills
cp -r /tmp/product-ai-public/music/managing-spotify-playlists .claude/skills/managing-spotify-playlists
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Managing Spotify Playlists in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Managing Spotify Playlists on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Managing Spotify Playlists is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Managing Spotify playlists

Overview

Rian's Spotify account (rianvdm) is writable from this repo. Every call goes through scripts/spotify.mjs, which refreshes a user token, backs off on 429, and follows pagination.

bash
node scripts/spotify.mjs GET "/me/playlists?limit=50" --all
node scripts/spotify.mjs POST /users/rianvdm/playlists '{"name":"X","public":false}'

Importable too: import { api, apiAll } from './scripts/spotify.mjs' — reach for this the moment a task needs more than two calls, because loops and dedupe belong in one script, not fifteen Bash invocations.

The core principle: Spotify has no undo, so capture state before you write. Dump the current track list to the scratchpad before any destructive operation. That single step converts an irreversible mistake into a restorable one, and it costs one API call.

bash
node scripts/spotify.mjs GET "/playlists/<id>/tracks?limit=100" --all > <scratchpad>/before-<slug>.json

Two credentials live in .env — only one can write

SPOTIFY_CLIENT_ID / SPOTIFY_CLIENT_SECRET alone are the client-credentials flow: app-level, zero scopes, public catalog reads only. It cannot see private playlists and cannot write anything. .opencode/skills/playlist-cover/fetch-playlist.mjs uses that flow, which is why it only reads.

Writes need SPOTIFY_REFRESH_TOKEN, also in .env, carrying playlist-read-private, playlist-read-collaborative, playlist-modify-private, playlist-modify-public, ugc-image-upload.

If a call fails with invalid_grant the token was revoked — re-run node scripts/spotify-auth.mjs. That needs http://127.0.0.1:8888/callback registered as a Redirect URI on the Spotify app's client ID. Spotify rejects localhost for loopback and matches the string exactly, so a trailing slash or https fails with INVALID_CLIENT.

Reversibility — check this before every write

OperationCallRecoverable?
Add tracksPOST /playlists/{id}/tracksYes — remove them again
Create playlistPOST /users/{uid}/playlistsYes — unfollow it
Rename, re-describe, change visibilityPUT /playlists/{id}Only if you captured the old values first
ReorderPUT /playlists/{id}/tracks + range_startOnly from a saved copy of the original order
Remove tracksDELETE /playlists/{id}/tracksNo
Replace all (uris on PUT)PUT /playlists/{id}/tracksNo — silently wipes the playlist
Upload coverPUT /playlists/{id}/imagesNo — the previous image is gone
"Delete" playlistDELETE /playlists/{id}/followersUnfollows rather than destroying; restorable from Rian's Spotify account page

uris on PUT /playlists/{id}/tracks is the trap worth naming twice: it reads like an update and behaves like a truncate. Reordering and replacing are mutually exclusive in one request.

Get confirmation before anything in bold above

Rian asked for this rule directly. Before firing a bold-row operation, show him:

  1. The playlist name and its current track count.
  2. The exact tracks affected — title and artist, not URIs — capped at 20 with a count of the remainder.
  3. The resulting track count.
  4. Where the before-state snapshot is saved.

Then stop and wait for a yes. A plan he approved earlier in the conversation is not a yes to the specific write; the diff he approves must be the diff you send.

Adding tracks, creating playlists, and renaming don't need this gate — do them and report what happened.

RationalizationReality
"He asked me to clean it up, so removal is implied"He authorized the goal, not a specific track list. Show the list.
"It's only a few tracks"The count isn't what makes it irreversible.
"He can see the playlist and will notice"Noticing afterwards is not the same as choosing beforehand.
"I already listed them earlier in the conversation"Listed ≠ approved. Ask for the yes.
"Replacing is cleaner than diffing"Replace wipes anything added since you last read the playlist. Diff.
"He said go ahead" (about a different playlist)Approval doesn't travel between playlists or between runs.
"Re-reading to snapshot wastes a call"One call against an unrecoverable loss.

Red flags — stop: you're composing a DELETE or a uris-bearing PUT and there is no before-*.json in the scratchpad; you're about to say "done" for a removal Rian never saw itemised; you're uploading a cover without having checked whether one already exists.

When a metadata field says a large batch of tracks is broken, verify one by playing it before proposing a fix. A field that reports 17 beloved songs as unplayable is more likely to be the wrong field than to be 17 broken songs — and the "fix" it justifies is a destructive edit. Rian caught this one himself with "I tested and they work for me." Ask what the field actually means, and find the call that answers the question directly, before writing a proposal built on it.

Resolving track names

When Rian gives song titles rather than URIs, search resolves each one and the resolved list goes to him before the add, formatted as query → matched title / artist / album / year. Spotify's top hit is routinely a karaoke cover, a live version, a remaster, or a sped-up edit, and none of that is visible in a URI.

Flag any row where the matched artist differs from the requested one, the title carries Live/Remaster/Karaoke/Sped Up, or search returned nothing. Those are the rows he needs to look at; the clean ones he can skim.

The same rule applies to tracks you propose, and there it matters more. A recommendation list written from memory is a list of existence claims, and the resolver is cheap — search each one, print artist / title / album / year / popularity / duration, and read the result before it reaches him. Resolving 20 shoegaze picks on 2026-08-17 caught four separate failures that all look identical in a chat message: three titles that returned nothing at all, and a Fleshwater pick whose duration gave it away as a 77-second interlude. Also print the artist search separately when the band's name is a common word — searching julie returns Julien Baker, not the band, so a name-equality match on the artist endpoint can fail while a artist:… track:… track query succeeds.

release_date is not the original release year on catalogue-heavy genres. Resolving 90s dance picks returned Café Del Mar dated 2005 and Castles in the Sky dated 2015 — both the original recordings, sitting on later compilations, because that is the only copy Spotify carries. So a date outside the playlist's own bracket is not evidence of a re-recording, and a date inside it is not evidence you got the right mix. Say which it is rather than letting the year imply it, and where a track has a famous later remix (For An Angel '98, Delerium's Silence via Tiësto), search for that mix by name — the bare artist:… track:… query returns the album original, which can be a completely different record.

Report a missing catalogue as missing rather than substituting. Hotline TNT resolved only to Audiotree live sessions, no studio album — the honest output is to drop the pick and say why, not to quietly hand over a live version.

API notes that bite

ThingDetail
Batch ceiling100 URIs per add or remove request. Chunk longer lists.
PaginationPlaylist tracks page at 100. Use --all or apiAll — a playlist of 257 needs three calls.
Null tracksitems[].track can be null for unavailable or local files. Filter before mapping .uri.
DuplicatesSpotify permits the same track twice. Dedupe on track.id, not name.
positions on DELETE is ignoredA remove deletes EVERY occurrence of the URI, not the one you targeted. The positions array is from an older API version; the current endpoint accepts it without complaint, returns 200, and removes them all. Removing one copy of a track that appears twice took Faith 131 → 129 on 2026-08-18. To de-duplicate, delete the URI and then re-add one copy with an explicit position — and verify the count, because nothing in the response tells you how many it took.
Empty available_markets does NOT mean unplayableIt usually means track relinking: the ID in the playlist is a market-specific stub Spotify resolves to a playable equivalent at play time, so it is licensed nowhere directly and reads as dead. 17 tracks on I'll Do My Crying In The Rain looked unplayable everywhere and all 17 play fine. Ask with market=US and read is_playable — that is the field that answers the question — and treat a linked_from on the result as proof relinking is doing its job. Reading the wrong field here nearly swapped 17 working tracks out of Rian's most-prized playlist.
snapshot_idPass it on removes to make the write conditional on the version you read.
Cover uploadPUT /playlists/{id}/images, raw base64 JPEG as the body, Content-Type: image/jpeg, 256 KB max payload — that's the base64 size, so the JPEG must be meaningfully smaller. Not JSON, so spotify.mjs's JSON path doesn't apply.
Positionposition on add is zero-based; omit it to append.
OwnerOnly playlists owned by rianvdm are writable. Check owner.id before promising an edit on a followed playlist.
Signaturesapi(method, path, body) takes the method; apiAll(path) does not — it is GET-only. apiAll('GET', p) silently fetches the path "GET".
BASE already ends in /v1So paths start /search, /playlists/…, /artists/…. Writing /v1/search doubles it.
A malformed path returns 410, not 404Both mistakes above surface as 410 GET GET or 410 GET /v1/search… with an empty message, which reads like a deprecated or withdrawn endpoint rather than a path you built wrong. Check the path shape before believing the API changed.

Reordering

uris on PUT truncates, so a reorder is a sequence of single-item moves. Selection-sort against the target list, updating a local copy of the order after each call so the next index is right:

js
for (let i = 0; i < TARGET.length; i++) {
  const j = cur.indexOf(TARGET[i], i);
  if (j === i) continue;
  await api('PUT', `/playlists/${ID}/tracks`, { range_start: j, insert_before: i, range_length: 1 });
  cur.splice(i, 0, cur.splice(j, 1)[0]);
}

Read the playlist back afterwards and assert the result equals the target, rather than trusting that N calls returned 200. An 18-track reorder took 13 moves; a 130-track one took 123.

At album length, sequence by hand; past that, sequence to constraints and say so. Faith is 130 tracks and nearly 13 hours, and a hand-built running order across that is theatre — nobody hears position 70 as following 69. What is actually broken at that length is measurable: 14 places where the same artist played twice in a row, and energy jumps like 0.28 → 0.86. So hand-pick an opening run of about a dozen (the part that actually gets heard) and a closing run of about eight, then generate the middle to hard constraints — no same-artist adjacency, bounded energy step — and report the numbers rather than describing a mood. Round-robin the middle over an energy-sorted list into ~7 waves and arc each one; a greedy nearest-energy walk instead collapses into one monotonic ramp, which is a sort, not a running order.

Group artists into families for the adjacency rule. Spotify's credits split acts that a listener hears as one: Crowder and David Crowder Band are the same man, Hillsong Worship and Hillsong UNITED are the same house. Fold them before checking adjacency or the constraint passes while the playlist still sounds repetitive.

Express the target as track URIs and resolve names to URIs once, up front. Building the target as artist — title strings and matching those against the playlist breaks on typography — Deserta's I'm So Tired is a straight apostrophe in the API and a curly one everywhere a human types it, which failed a whole run. Whatever the target is keyed on, assert the mapping is complete before the first move, so a mismatch aborts instead of half-reordering the playlist.

Re-read the live playlist inside the write script, and abort if it no longer matches the plan you proposed. Rian edits playlists in the Spotify client while a session is running, and it happens often enough to design for: on 2026-08-18 Trance Classics went 20 → 19 between the reorder and the next turn (he removed a duplicate I had flagged), and 24 → 25 midway through a sequencing analysis (he added a track). Both were caught only because the script compared the live order against the snapshot before its first PUT. Don't hardcode a track count from an earlier turn either — assert against what you just read, and make the mismatch a thrown error rather than a warning.

Sequencing data

Energy, valence, danceability, tempo and key come from scripts/audio-features.mjs, which serves them from ReccoBeats. Spotify's own /audio-features, /audio-analysis and /recommendations are dead for this app — 403/403/404, closed to apps without pre-November-2024 access.

bash
node scripts/audio-features.mjs "<playlist url or id>"   # table, plus a coverage line

Coverage is partial and the gap lands exactly where it hurts. ReccoBeats thins out on small-label and recent releases — 16 of 19 on Shimmery Guitars, and the three misses were its three most obscure tracks. Read the coverage line before leaning on the numbers, and sequence the uncovered tracks on artist separation, duration and era, the way you would with no data at all.

Then say which basis you used, per track group rather than for the playlist as a whole: "sequenced on energy and key where ReccoBeats had data, on artist spacing and length for the three it didn't." Describing a whole running order as tuned to energy when a fifth of it was judgement is inventing a measurement.

Cover art

Designing the image and attaching it is playlist-cover, which ships the upload:

bash
node .opencode/skills/playlist-cover/set-cover.mjs "<playlist url or id>" <cover>.png

It handles the JPEG re-encode under the 256 KB base64 ceiling and reads the playlist back to confirm the image took, because 202 Accepted is returned whether or not it did. The rule that matters here is the one this skill enforces: the upload overwrites, Spotify keeps no history, so check the current images[0].url first. A mosaic.scdn.co URL is the auto-generated grid and costs nothing to replace; anything else is a cover Rian chose, and that needs a yes before you overwrite it.

Frequently asked questions

What does the Managing Spotify Playlists AI skill do?

Use when the user wants to create, inspect, or change a Spotify playlist (add, remove, reorder, dedupe, rename, visibility, set cover). For designing the cover image use playlist-cover.

Why use Managing Spotify Playlists on TypingMind?

Because you install it once and use it with any model. Managing Spotify Playlists is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Managing Spotify Playlists in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/rianvdm/product-ai-public/tree/main/music/managing-spotify-playlists. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Managing Spotify Playlists?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Managing Spotify Playlists?

As many as you like. As long as a model supports skills, you can use Managing Spotify Playlists with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Managing Spotify Playlists AI skill free?

Yes. It is published on GitHub by rianvdm under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇