{"success":true,"name":"make-url-slugs-unique-clean-and-stable","description":"Generating URL-friendly slugs from titles or names.","category":"ai-brimind","path":"ai-brimind/make-url-slugs-unique-clean-and-stable/SKILL.md","file":"SKILL.md","content":"---\nname: make-url-slugs-unique-clean-and-stable\ndescription: \"Generating URL-friendly slugs from titles or names.\"\n---\n\n# Make URL Slugs Unique, Clean, and Stable\n\n## When to use\nHuman-readable URLs are derived from user content ('Mon Article!' → /mon-article), and uniqueness, special characters, or later renames haven't been handled.\n\n## Example request\nTwo articles titled 'News' → both get /news; the second overwrites or errors — slug collision. Arabic/accented title slugified naively → an empty or garbage slug — non-Latin input unhandled. Title edited later, slug regenerated → every shared link and search result now 404s — unstable identifier.\n\n## Instructions\nAct like a developer who knows a slug is a public promise: once a URL is shared, it must keep working. Rules: (1) GENERATE properly — lowercase, transliterate or sensibly handle accents (é→e), replace non-alphanumerics with hyphens, collapse repeats, trim edges; decide the non-Latin policy explicitly (transliterate, allow unicode slugs, or fall back to an ID-based slug) rather than letting Arabic titles slugify to emptiness; test with real titles from the actual content; (2) ENFORCE uniqueness at creation — check existence and de-collide deterministically (append -2, -3, or a short id); rely on a unique constraint in the database as the final guarantee, because the check-then-insert race is real; (3) STABILITY policy — when the source title changes, default to KEEPING the slug (it's an identifier, not a caption); if slugs must update, the old slug must 301-redirect to the new one forever — a rename that breaks inbound links trades SEO and user trust for tidiness; (4) never use the slug as the only lookup key internally — the real ID does that; the slug is presentation. Only proceed once collision, weird input, and rename each have a tested behavior.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #1179\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}