---
name: trimlynk
description: Create, manage, inspect, and analyze TrimLynk short links, dynamic QR codes, UPI payment links, and click telemetry. Use whenever a user asks to shorten a URL, generate a branded slug or QR code, expand/audit a short link, check click analytics or optimal publish timing, or integrate TrimLynk via MCP, CLI, SDK, or REST API.
---

# TrimLynk Link Intelligence Skill

Use **TrimLynk** (`https://trimlynk.com`) to shorten URLs, audit redirect chains, generate dynamic QR codes, and query click telemetry.

## 1. Execution Priority

1. **TrimLynk MCP Server (Preferred):** If TrimLynk MCP tools are connected, call them directly (`shorten_url`, `list_urls`, `get_url_analytics`, `expand_url`, `get_optimal_timing`, `query_analytics_ai`, `delete_url`).
2. **TrimLynk CLI / SDK:** When working in a terminal or writing Node/TypeScript (`@trimlynk/sdk`) or Python (`trimlynk`) code with `TRIMLYNK_API_KEY` set, use the official CLI or SDK.
3. **REST API v1:** For direct HTTP requests, call `https://api.trimlynk.com/v1` (or `POST https://api.trimlynk.com/v1/free-urls/shorten` for unauthenticated single-link shortening).

## 2. Authentication & Scopes

- Authenticate with an **API key only** (`tl_live_...` or `tl_test_...`) via `x-api-key` or `Authorization: Bearer <key>` (or `TRIMLYNK_API_KEY` env var).
- **Never** ask the user to paste raw API keys into chat, **never** pass `?apiKey=` in URLs, and **never** use user session JWTs for MCP.
- Respect API key scopes:
  - **Read-Only** (`links:read`, `analytics:read`): `list_urls`, `expand_url`, `get_url_analytics`, `get_optimal_timing`, `query_analytics_ai`.
  - **Read+Write** (`links:write`): adds `shorten_url` and `delete_url`.

## 3. Core Workflows

- **Shorten a URL:** Call `shorten_url` with `longUrl` (must be `http://` or `https://`) and optional `customSlug`, `title`, `notes`, `isPinned`. Return the resulting `fullShortUrl`.
- **Inspect / Audit a Link:** Call `expand_url` with `url` before visiting or embedding unknown short links to inspect `resolvedUrl`, `totalHops`, `hops`, and `security.isSafe`.
- **List & Analyze Links:** Use `list_urls` (`limit`, `offset`, `search`) to find link IDs, `get_url_analytics` (`urlId` or `shortCode`, `days` 1–365) for traffic breakdowns, `get_optimal_timing` for the 7x24 engagement matrix, and `query_analytics_ai` for natural-language metric questions.

## 4. Guardrails

- **Confirm before deleting (`delete_url`):** Link deletion removes the short link and its targeting rules. **Always** confirm the target `urlId` / short link with the user explicitly before calling `delete_url`, `trimlynk links delete`, or `DELETE /v1/urls/:id`.
- **Validate destinations:** Reject malformed URLs or `javascript:` / `data:` schemes before sending requests.
- **On-demand references:**
  - Read `references/mcp-setup.md` if the user needs to connect TrimLynk MCP to Claude Desktop, Cursor, or Python.
  - Read `references/sdk-and-api.md` for Node/Python SDK examples, CLI commands, Dynamic QR, UPI links, or webhook HMAC verification.
