Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Optimize Linktree API integration performance with caching, batching, and rate limit strategies. Use when Linktree API calls are slow, hitting rate limits, or profile pages serve stale link data. Trigger with "linktree performance tuning".
.claude/skills/jeremylongshore-linktree-performance-tuning/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-08 | ✗→✓ | ▲ Improved | 8% | 0% |
| case-01 | ✗→✓ | ▲ Improved | -7% | 0% |
| case-02 | ✗→✓ | ▲ Improved | -24% | 0% |
| case-07 | ✗→✓ | ▲ Improved | 50% | 0% |
| case-09 | ✗→✓ | ▲ Improved | -2% | 0% |
Linktree profiles are high-traffic read endpoints — a single creator's link-in-bio page can receive millions of hits during viral moments. This skill covers caching strategies tuned to Linktree's data volatility, batch link operations, and resilient rate limit handling to prevent stale data and API cost overruns.
typescriptimport Redis from "ioredis"; const redis = new Redis(process.env.REDIS_URL); // Profile data changes infrequently — cache 10 minutes // Link lists update more often — cache 2 minutes const TTL = { profile: 600, links: 120, analytics: 300 } as const; async function getCachedProfile(username: string): Promise<LinktreeProfile> { const key = `lt:profile:${username}`; const cached = await redis.get(key); if (cached) return JSON.parse(cached); const profile = await linktreeApi.getProfile(username); await redis.setex(key, TTL.profile, JSON.stringify(profile)); return profile; } async function getCachedLinks(profileId: string): Promise<LinktreeLink[]> { const key = `lt:links:${profileId}`; const cached = await redis.get(key); if (cached) return JSON.parse(cached); const links = await linktreeApi.getLinks(profileId); await redis.setex(key, TTL.links, JSON.stringify(links)); return links; }
typescript// Fetch multiple profiles in parallel with concurrency limit import pLimit from "p-limit"; const limit = pLimit(5); // Max 5 concurrent Linktree API calls async function batchFetchProfiles(usernames: string[]): Promise<LinktreeProfile[]> { return Promise.all( usernames.map((u) => limit(() => getCachedProfile(u))) ); } // Bulk link updates — group mutations into single request windows async function batchUpdateLinks( profileId: string, updates: LinkUpdate[] ): Promise<void> { const chunks = chunkArray(updates, 10); // 10 links per request for (const chunk of chunks) { await Promise.all(chunk.map((u) => limit(() => linktreeApi.updateLink(profileId, u)))); } }
typescriptimport { Agent } from "undici"; const linktreeAgent = new Agent({ connect: { timeout: 5_000 }, keepAliveTimeout: 30_000, keepAliveMaxTimeout: 60_000, pipelining: 1, connections: 10, // Persistent pool for linktr.ee API }); async function linktreeFetch(path: string, init?: RequestInit): Promise<Response> { return fetch(`https://api.linktr.ee/v1${path}`, { ...init, // @ts-expect-error undici dispatcher dispatcher: linktreeAgent, headers: { Authorization: `Bearer ${process.env.LINKTREE_API_KEY}`, ...init?.headers }, }); }
typescriptasync function withRateLimit<T>(fn: () => Promise<T>, maxRetries = 3): Promise<T> { for (let attempt = 0; attempt <= maxRetries; attempt++) { try { return await fn(); } catch (err: any) { if (err.status === 429) { const retryAfter = parseInt(err.headers?.["retry-after"] ?? "5", 10); const backoff = retryAfter * 1000 * Math.pow(2, attempt); console.warn(`Linktree rate limited. Retrying in ${backoff}ms (attempt ${attempt + 1})`); await new Promise((r) => setTimeout(r, backoff)); continue; } throw err; } } throw new Error("Linktree API: max retries exceeded"); }
typescriptimport { Counter, Histogram } from "prom-client"; const ltApiLatency = new Histogram({ name: "linktree_api_duration_seconds", help: "Linktree API call latency", labelNames: ["endpoint", "status"], buckets: [0.1, 0.25, 0.5, 1, 2, 5], }); const ltCacheHits = new Counter({ name: "linktree_cache_hits_total", help: "Cache hits for Linktree profile and link data", labelNames: ["cache_type"], // profile | links | analytics }); const ltRateLimits = new Counter({ name: "linktree_rate_limits_total", help: "Number of 429 responses from Linktree API", });
| Issue | Cause | Fix | |-------|-------|-----| | Stale links shown to visitors | Cache TTL too long for active creators | Lower link cache TTL to 60s for high-traffic profiles | | 429 during viral traffic spike | Burst of profile reads exceeds rate limit | Enable request queuing with p-limit concurrency of 3 | | Slow profile page renders | Fetching profile + links sequentially | Parallelize with Promise.all([getProfile, getLinks]) | | Connection timeouts to API | No keep-alive, cold TCP for each request | Enable undici connection pooling with 10 persistent sockets | | Analytics data gaps | Report endpoints are slow, callers timeout | Cache analytics for 5min, use background refresh pattern |
After applying these optimizations, expect:
typescript// Full optimized profile fetch — cache + rate limit + pooling const profile = await withRateLimit(() => getCachedProfile("creator-username")); const links = await withRateLimit(() => getCachedLinks(profile.id)); // Alternative: use in-memory Map instead of Redis for low-traffic integrations const localCache = new Map<string, { data: any; expiry: number }>();
See linktree-reference-architecture.
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-08 | fail→pass | 38,660 | 15,785 | -59% | 1 | 1 | 0% | 3,049 | 3,289 | +8% | 0 | 0 | — |
case-01 | fail→pass | 33,039 | 22,299 | -33% | 1 | 1 | 0% | 6,157 | 5,738 | -7% | 0 | 0 | — |
case-02 | fail→pass | 41,655 | 24,107 | -42% | 1 | 1 | 0% | 5,975 | 4,519 | -24% | 0 | 0 | — |
case-03 | fail→fail | 20,892 | 21,932 | +5% | 1 | 1 | 0% | 3,011 | 4,349 | +44% | 0 | 0 | — |
case-04 | pass→pass | 27,102 | 24,305 | -10% | 1 | 1 | 0% | 4,264 | 5,698 | +34% | 0 | 0 | — |
case-05 | pass→pass | 26,620 | 24,003 | -10% | 1 | 1 | 0% | 4,486 | 5,679 | +27% | 0 | 0 | — |
case-06 | pass→pass | 18,008 | 22,013 | +22% | 1 | 1 | 0% | 2,514 | 4,229 | +68% | 0 | 0 | — |
case-07 | fail→pass | 19,462 | 16,313 | -16% | 1 | 1 | 0% | 2,674 | 4,017 | +50% | 0 | 0 | — |
case-09 | fail→pass | 22,102 | 14,656 | -34% | 1 | 1 | 0% | 3,718 | 3,643 | -2% | 0 | 0 | — |
case-10 | fail→fail | 16,817 | 12,008 | -29% | 1 | 1 | 0% | 2,301 | 3,029 | +32% | 0 | 0 | — |
case-11 | fail→pass | 25,722 | 17,608 | -32% | 1 | 1 | 0% | 3,755 | 5,295 | +41% | 0 | 0 | — |
case-12 | pass→pass | 7,710 | 17,101 | +122% | 1 | 1 | 0% | 1,584 | 3,963 | +150% | 0 | 0 | — |
case-13 | fail→pass | 5,395 | 4,654 | -14% | 1 | 1 | 0% | 972 | 2,444 | +151% | 0 | 0 | — |
case-14 | fail→pass | 11,969 | 3,189 | -73% | 1 | 1 | 0% | 1,279 | 2,328 | +82% | 0 | 0 | — |
case-15 | fail→pass | 17,147 | 7,554 | -56% | 1 | 1 | 0% | 2,352 | 3,101 | +32% | 0 | 0 | — |
case-16 | fail→pass | 15,455 | 10,387 | -33% | 1 | 1 | 0% | 1,927 | 2,774 | +44% | 0 | 0 | — |
case-17 | fail→fail | 20,304 | 15,724 | -23% | 1 | 1 | 0% | 2,314 | 3,796 | +64% | 0 | 0 | — |
case-18 | pass→pass | 16,495 | 7,084 | -57% | 1 | 1 | 0% | 2,211 | 3,066 | +39% | 0 | 0 | — |
case-19 | fail→pass | 11,038 | 12,510 | +13% | 1 | 1 | 0% | 2,024 | 3,111 | +54% | 0 | 0 | — |
case-20 | pass→pass | 16,927 | 15,140 | -11% | 1 | 1 | 0% | 2,199 | 3,760 | +71% | 0 | 0 | — |
case-21 | fail→pass | 19,971 | 20,716 | +4% | 1 | 1 | 0% | 2,402 | 4,123 | +72% | 0 | 0 | — |
case-22 | fail→pass | 14,008 | 9,734 | -31% | 1 | 1 | 0% | 1,529 | 2,365 | +55% | 0 | 0 | — |
case-23 | pass→pass | 18,687 | 7,560 | -60% | 1 | 1 | 0% | 2,193 | 2,032 | -7% | 0 | 0 | — |
case-24 | pass→pass | 19,299 | 7,501 | -61% | 1 | 1 | 0% | 1,776 | 2,028 | +14% | 0 | 0 | — |
case-25 | pass→pass | 18,080 | 9,346 | -48% | 1 | 1 | 0% | 1,812 | 2,587 | +43% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 25 cases were attempted. The headline lift of +52 percentage points is the difference between those two pass rates over the 25 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.