Logotipo de Managing Spotify Playlists

Managing Spotify Playlists

Comunidad
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.

Descripción general

Editorrianvdm
Repositorioproduct-ai-public
Nombre de la habilidadmanaging-spotify-playlists
Estrellas
20
Forks
4
Archivos incluidos
Solo instrucciones
LicenciaMIT
Enlaces
  • Instrucciones en Markdown

    Un archivo SKILL.md que el modelo carga cuando lo necesita, de modo que solo consume tokens cuando la petición encaja con la habilidad.

  • Funciona con cualquier LLM

    Las habilidades de IA están en Markdown, no en código específico de un proveedor, por lo que funcionan con GPT, Claude, Gemini, Grok o un modelo local.

  • Todo en las instrucciones

    Todo lo que necesita el modelo está en las instrucciones: no hay archivos adicionales que sincronizar.

  • Código abierto

    Publicada por rianvdm en GitHub. Revisa el contenido original antes de instalarla.

Instalación

Instala la habilidad de IA Managing Spotify Playlists en TypingMind para usarla con cualquier LLM, o añádela a otro agente que lea SKILL.md.

1

Instalar en TypingMind

TypingMind instala una habilidad directamente desde su carpeta de GitHub: lee SKILL.md, empaqueta los archivos de recursos y guarda el resultado localmente.

  1. Abre la aplicación y ve a Plugins → Habilidades.
  2. Elige «Instalar desde GitHub».
  3. Pega la URL de la carpeta de la habilidad que se muestra a continuación y confirma.
    https://github.com/rianvdm/product-ai-public/tree/main/music/managing-spotify-playlists
  4. Activa la habilidad en cada chat en el que quieras tenerla disponible.
Plugins → Habilidades → Añadir habilidad → URL de GitHub; después, pega la URL de la carpeta y pulsa Continuar.
2

Instalar en otro agente

Cualquier agente que lea el formato Agent Skills puede usar esta habilidad: copia la carpeta en el directorio de habilidades de ese agente.

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
Reinicia Claude Code después de copiarla para que detecte la nueva habilidad.

Úsala en TypingMind

Activa Managing Spotify Playlists en cualquier chat de TypingMind y el modelo se encargará del resto. Su nombre y descripción se incluyen en el prompt del sistema y, en cuanto una petición encaja con la habilidad, el modelo carga las instrucciones completas por sí solo. No tienes que invocarla manualmente y no consume tokens hasta que se utiliza.

El modelo carga Managing Spotify Playlists automáticamente en cuanto una petición es relevante para esa habilidad.

Funciona con cualquier modelo de IA

Las habilidades de IA son instrucciones en Markdown, no código específico de un proveedor, por lo que Managing Spotify Playlists no está vinculada al modelo para el que se creó. Instálala una sola vez en TypingMind y úsala con GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama o un modelo local que ejecutes tú, todo con tus propias claves API.

  • Se carga solo cuando se necesita

    El prompt del sistema solo incluye el nombre y la descripción. Las instrucciones se cargan con la primera petición que encaja con la habilidad, por lo que una habilidad que no se usa no supone ningún coste.

  • Cambia de modelo durante el chat

    Como la habilidad contiene instrucciones y no código, cambiar de modelo no impide que funcione: el nuevo modelo lee el mismo archivo SKILL.md.

Instrucciones de la habilidad

Este es el contenido de SKILL.md que carga el modelo. Léelo antes de instalar la habilidad: contiene instrucciones que tu modelo seguirá.

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.

Preguntas frecuentes

¿Qué hace la habilidad de IA 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.

¿Por qué usar Managing Spotify Playlists en TypingMind?

Porque la instalas una vez y la usas con cualquier modelo. Managing Spotify Playlists está escrita en Markdown, no en código específico de un proveedor, por lo que la misma habilidad funciona con GPT-5, Claude, Gemini, Grok o un modelo local, y puedes cambiar de modelo en mitad del chat sin que deje de funcionar. TypingMind utiliza tus propias claves API, de modo que pagas directamente a los proveedores en lugar de pagar una suscripción por puesto, y tus habilidades y chats permanecen en tu propio almacenamiento.

¿Cómo instalo Managing Spotify Playlists en TypingMind?

Abre Plugins → Habilidades → Instalar desde GitHub en TypingMind y pega https://github.com/rianvdm/product-ai-public/tree/main/music/managing-spotify-playlists. TypingMind lee el archivo SKILL.md de esa carpeta e instala su contenido como una habilidad que puedes activar en cada chat.

¿Qué modelos de IA pueden usar Managing Spotify Playlists?

Cualquier modelo que conectes en TypingMind. Las habilidades de IA son instrucciones en Markdown, no código específico de un proveedor, por lo que GPT, Claude, Gemini, Grok y los modelos locales pueden cargar esta habilidad cuando una solicitud se corresponda con ella.

¿Con cuántos modelos de IA puedo usar Managing Spotify Playlists?

Con tantos como quieras. Siempre que un modelo admita habilidades, puedes usar Managing Spotify Playlists con él: GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama y muchos más, todos en TypingMind con tus propias claves API.

¿Es gratuita la habilidad de IA Managing Spotify Playlists?

Sí. rianvdm la ha publicado en GitHub bajo la licencia MIT. Solo pagas a tu proveedor de IA por los tokens que utilizas.

¿Qué son las habilidades de IA?

Una habilidad de IA es un conjunto de instrucciones reutilizables que enseña a un modelo de IA a realizar una tarea concreta. Sigue el formato abierto Agent Skills: un archivo SKILL.md con un nombre y una descripción, además de los scripts, plantillas o archivos de referencia que pueda necesitar el modelo. El modelo solo lee las instrucciones cuando tu solicitud se corresponde con la habilidad, por lo que una habilidad instalada no supone ningún coste hasta que se utiliza.

¿En qué se diferencian las habilidades de IA de los plugins o los servidores MCP?

Un plugin o un servidor MCP proporciona al modelo nuevas herramientas que puede invocar: código que se ejecuta en algún lugar y devuelve un resultado. En cambio, una habilidad de IA aporta conocimientos y procedimientos al modelo: cómo abordar una tarea, qué pasos seguir y qué se considera un buen resultado. Las habilidades son instrucciones en Markdown, por lo que no necesitan servidor, clave API ni entorno de ejecución, y funcionan con cualquier modelo.

Ver el directorio

Crea ya tu propio espacio de trabajo con IA

Suscríbete a nuestro boletín para recibir avisos sobre nuevas funciones y próximos sorteos 👇