Logo vun Managing Spotify Playlists

Managing Spotify Playlists

Communautéit
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.

Iwwersiicht

Editeurrianvdm
Repositoryproduct-ai-public
Skill-Nummmanaging-spotify-playlists
Stären
20
Forks
4
Matgeliwwert Fichieren
Nëmmen Instruktiounen
LizenzMIT
Linken
  • Instruktiounen am Markdown-Format

    Eng SKILL.md-Datei, déi de Modell bei Bedarf luet, soudatt nëmmen Token ufalen, wann eng Ufro tatsächlech dozou passt.

  • Funktionéiert mat all LLM

    KI-Skills si reng Markdown, keen ubidderspezifesche Code. Dofir funktionéiert dëse Skill mat GPT, Claude, Gemini, Grok oder engem lokale Modell.

  • Alles an den Instruktiounen

    Alles, wat de Modell brauch, steet an den Instruktiounen — keng zousätzlech Dateien ze synchroniséieren.

  • Open Source

    Vum rianvdm op GitHub verëffentlecht. Liest de Quelltext, ier Dir de Skill installéiert.

Installatioun

Installéiert de KI-Skill Managing Spotify Playlists an TypingMind, fir e mat all LLM ze benotzen, oder füügt en an en anere KI-Agent an, deen SKILL.md liest.

1

An TypingMind installéieren

TypingMind installéiert e Skill direkt aus sengem GitHub-Dossier — dobäi gëtt SKILL.md gelies, d'Ressourcedateie gi gebëndelt an d'Resultat gëtt lokal gespäichert.

  1. Maacht d'App op a gitt op Plugins → Skills.
  2. Wielt „Vun GitHub installéieren“.
  3. Pecht d'URL vum Skill-Dossier hei drënner an a bestätegt.
    https://github.com/rianvdm/product-ai-public/tree/main/music/managing-spotify-playlists
  4. Aktivéiert de Skill an all Chat, an deem Dir e benotze wëllt.
Plugins → Skills → Skill afügen → Vu GitHub-URL, pecht dann d'URL vum Dossier an a klickt op Weider.
2

An engem anere KI-Agent installéieren

All KI-Agent, deen d'Format Agent Skills liest, kann dëse Skill benotzen — kopéiert den Dossier an de Skill-Verzeechnes vun deem KI-Agent.

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
Start Claude Code nom Kopéieren nei, fir datt den neie Skill erkannt gëtt.

An TypingMind benotzen

Aktivéiert Managing Spotify Playlists an engem Chat vun TypingMind, an de Modell iwwerhëlt de Rescht. Den Numm an d'Beschreiwung stinn am System-Prompt. Soubal eng Ufro dozou passt, luet de Modell déi komplett Instruktioune selwer — Dir musst de Skill ni manuell opruffen, an et fale keng Token un, bis en tatsächlech benotzt gëtt.

De Modell luet Managing Spotify Playlists automatesch, soubal eng Ufro dozou passt.

Funktionéiert mat all KI-Modell

KI-Skills si reng Markdown-Instruktiounen amplaz vun ubidderspezifeschem Code. Dofir ass Managing Spotify Playlists net un de Modell gebonnen, fir deen de Skill geschriwwe gouf. Installéiert en eemol an TypingMind a benotzt e mat GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama oder engem lokale Modell, deen Dir selwer bedreift — alles mat Ären eegenen API-Keys.

  • Gëtt nëmme gelueden, wann et néideg ass

    De System-Prompt enthält nëmmen den Numm an d'Beschreiwung. D'Instruktioune gi bei der éischter passender Ufro gelueden, soudatt en onbenotzte Skill näischt kascht.

  • De Modell am lafende Chat wiesselen

    Well de Skill aus Instruktiounen amplaz vu Code besteet, funktionéiert en och no engem Modellwiessel — den nächste Modell liest déi selwecht SKILL.md-Datei.

Skill-Instruktiounen

Dëst ass den Inhalt vu SKILL.md, deen de Modell luet. Liest e virun der Installatioun — e Skill besteet aus Instruktiounen, déi Äre Modell befollegt.

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.

Heefeg gestallte Froen

Wat mécht de KI-Skill 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.

Firwat Managing Spotify Playlists op TypingMind benotzen?

Well Dir en eemol installéiert a mat all Modell benotze kënnt. Managing Spotify Playlists besteet aus einfachem Markdown amplaz vun ubidderspezifeschem Code. Dee selwechte Skill funktionéiert also mat GPT-5, Claude, Gemini, Grok oder engem lokale Modell – an Dir kënnt de Modell matzen am Chat wiesselen, ouni datt de Skill ophält ze funktionéieren. TypingMind benotzt Är eegen API-Schlësselen, sou datt Dir d'Ubidder direkt bezuelt amplaz vun engem Abonnement pro Benotzerplaz. Är Skills a Chats bleiwen an Ärem eegene Späicher.

Wéi installéieren ech Managing Spotify Playlists an TypingMind?

Maacht an TypingMind Plugins → Skills → Vu GitHub installéieren op a setzt https://github.com/rianvdm/product-ai-public/tree/main/music/managing-spotify-playlists an. TypingMind liest d'Datei SKILL.md an installéiert de Skill, deen Dir pro Chat aktivéiere kënnt.

Wéi eng KI-Modeller kënnen Managing Spotify Playlists benotzen?

All Modell, deen Dir an TypingMind verbënnt. KI-Skills sinn einfach Markdown-Instruktiounen an net ubidderspezifesche Code. Dofir kënne GPT, Claude, Gemini, Grok a lokal Modeller dëse Skill lueden, wann eng Ufro dozou passt.

Wéi vill KI-Modeller kann ech mat Managing Spotify Playlists benotzen?

Esou vill Dir wëllt. Soulaang e Modell Skills ënnerstëtzt, kënnt Dir Managing Spotify Playlists domat benotzen – GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama a méi – alles op TypingMind mat Ären eegenen API-Schlësselen.

Ass de KI-Skill Managing Spotify Playlists gratis?

Jo. De Skill gëtt vum rianvdm ënner der Lizenz MIT op GitHub publizéiert. Dir bezuelt nëmmen Ären eegene KI-Ubidder fir d'Token, déi Dir benotzt.

Wat si KI-Skills?

E KI-Skill ass e weiderverwendbaart Pak vun Instruktiounen, dat engem KI-Modell bäibréngt, wéi en eng bestëmmt Aufgab erfëllt. E follegt dem oppenen Agent Skills-Format: eng Datei SKILL.md mat engem Numm an enger Beschreiwung, plus all Scripten, Virlagen oder Referenzdateien, déi de Modell eventuell brauch. De Modell liest d'Instruktiounen eréischt, wann Är Ufro zum Skill passt. En installéierte Skill kascht also näischt, bis e benotzt gëtt.

Wéi ënnerscheede sech KI-Skills vu Plugins oder MCP-Serveren?

E Plugin oder MCP-Server gëtt engem Modell nei Tools, déi en opruffe kann – Code, deen iergendwou leeft an e Resultat zeréckgëtt. E KI-Skill gëtt dem Modell dogéint Wëssen an eng Virgoensweis: wéi en eng Aufgab ugeet, wéi eng Schrëtt en nokënnt a wéi eng gutt Ausgab ausgesäit. Skills bestinn aus einfachem Markdown, brauche kee Server, keen API-Schlëssel a keng Lafzäitëmfeld a funktionéiere mat all Modell.

All weisen

Elo Ären eegene KI-Workspace ariichten

Abonnéiert Iech op eisen Newsletter, fir iwwer nei Funktiounen an zukünfteg Gewënnspiller informéiert ze ginn 👇