AddThisFeature

Link Shortener

Turn long URLs into short branded links and see how many people actually clicked.

moderate Growth

What it adds

A short-link service with custom or generated slugs, a redirect endpoint, and per-link click counts.

What your agent is told to do

5
  1. 1

    The app already has Shareable Deep Links and Signed Share Links. Extend that machinery with a short-slug alias rather than standing up a second, parallel link table that will drift out of sync with it.

  2. 2

    Let a user accept a generated slug or type their own. Validate a custom slug on the server against reserved application routes, existing slugs, and profanity, and say which rule failed rather than silently generating a different one.

  3. 3

    Record a click on the redirect itself: timestamp, referrer, coarse device type, and coarse location. Feed those into the app's existing Event Tracking so the numbers appear beside the rest of the analytics instead of in an isolated counter.

  4. 4

    Constrain destinations. Either restrict them to hosts the account controls, or run every destination through the same allowlist and safe-browsing check the app already applies to user-submitted URLs before the redirect is ever served.

  5. 5

    Do not count the click inside the request that performs the redirect if that write can block or fail. The redirect must still happen when the counter is unavailable; record the click asynchronously and accept that a small number are lost.

Edge cases it handles

8
  • A slug that collides with a real application route hijacks part of the app. Reserve every top-level path the router already claims, plus the ones you are likely to add later such as admin, api, login, and settings, and reject those slugs at creation time.
  • An unrestricted shortener becomes an open redirect that lends your domain's reputation to phishing. Refuse destinations that fail the allowlist, and re-check a destination periodically because a host that was safe when the link was created may not stay that way.
  • Link previewers, mail scanners, and browser prefetch all fetch the redirect without a human involved, which inflates counts badly on links shared by email. Identify and exclude them, and deduplicate repeat hits from the same client within a short window.
  • Decide explicitly what a deleted or expired link does. Silently 404 is confusing to someone who was handed the link in good faith; show a short page saying the link is no longer active and offer a route back to the app.
  • A shortened link that drops the query string or fragment breaks tracking parameters and in-page anchors. Append the incoming query and fragment to the destination, merging rather than overwriting parameters the destination already carries.
  • Slugs are read aloud and typed by hand. Treat them case-insensitively and avoid characters that are easily confused, or a link that works when pasted will fail when someone types it off a slide.
  • Reusing a deleted slug for a new destination sends people who kept the old link somewhere unexpected. Retire slugs rather than returning them to the pool.
  • Sequential slugs let anyone enumerate every link in the system. Generate unpredictable slugs, and apply the app's existing Rate Limiting to the redirect endpoint so guessing is not cheap.

Definition of done

9
  • A user can create a short link with a generated or custom slug and is told clearly when a custom slug is rejected.
  • Slugs cannot collide with application routes, and retired slugs are never reissued.
  • Redirects preserve incoming query parameters and fragments.
  • Destinations are validated against the app's existing URL safety checks before a redirect is served.
  • Click counts exclude prefetch and bot traffic and appear in the app's existing analytics.
  • A redirect still succeeds when click recording is unavailable.
  • Deleted and expired links show an explanatory page rather than a bare error.
  • The feature matches the existing design system.
  • No existing functionality is broken.

Related features

How it works

  1. 1

    Copy the link

    Grab the Markdown instruction URL for this feature.

  2. 2

    Give it to your AI

    Paste it into Claude Code, Cursor, v0, Lovable — whatever you build with.

  3. 3

    It inspects, then implements

    Your agent reads your existing app first, then adds the feature to fit it.

Works with your stack

These instructions are written to adapt. They tell the agent to detect your framework, match your existing design system, and reuse what you already have — rather than assuming a particular stack.

Need it tighter than that? Customize the feature and tell it exactly what you're running.