agentsclimarketplace

Vercel kv

Skill VRIL-LABS/skill-jam/skills/ai-ml/claude-skills-main/claude-skills-main/plugins/vercel-kv/skills/vercel-kv

Welcome to the skill-jam ☄️🏀

Install
npx -y skills add VRIL-LABS/skill-jam --skill vercel-kv

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

2 things to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
  • 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its author says it does

Copied from the file, not written here

Vercel KV (Redis-compatible key-value storage via Upstash). Use for Next.js caching, sessions, rate limiting, TTL data storage, or encountering KV_REST_API_URL errors, rate limit issues, JSON serialization errors. Provides strong consistency vs eventual consistency.

The file declares its own license as MIT. That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.

SKILL.md

5.9 KB, ~1.4k tokens by cl100k_base, as published. Nobody here has run it

Vercel KV (Redis-Compatible Storage)

Status: Production Ready Last Updated: 2025-12-14 Dependencies: None Latest Versions: @vercel/[email protected]


Quick Start (3 Minutes)

1. Create & Configure

# Create KV database in Vercel dashboard: Storage → Create Database → KV
vercel env pull .env.local

Creates environment variables:

  • KV_REST_API_URL - Your KV database URL
  • KV_REST_API_TOKEN - Auth token

2. Install

bun add @vercel/kv

3. Use in Your App

Next.js Server Action:

'use server';

import { kv } from '@vercel/kv';

export async function incrementViews(slug: string) {
  const views = await kv.incr(`views:${slug}`);
  return views;
}

Edge API Route:

import { kv } from '@vercel/kv';

export const runtime = 'edge';

export async function GET(request: Request) {
  const value = await kv.get('mykey');
  return Response.json({ value });
}

Critical Rules

Always Do

RuleWhy
Set TTL for temporary datasetex('key', 3600, value) - Avoid memory leaks
Use namespaced keysuser:123:profile not 123 - Prevents collisions
Handle null returnsNon-existent keys return null
Use pipeline for batch opsSingle round-trip reduces latency
Serialize JSON-compatible onlyNo functions, circular references
Monitor command usageStay within free tier (30K/month)

Never Do

RuleWhy
Store sensitive data unencryptedKV not encrypted at rest by default
Forget to set TTLKeys without TTL stay forever
Use generic key namesdata, cache will collide
Store large values (>1MB)Use Vercel Blob instead
Use as primary databaseKV is for cache, not persistence
Commit .env.localContains KV tokens

Core Operations

Set/Get with TTL:

import { kv } from '@vercel/kv';

// Set with TTL (expires in 1 hour)
await kv.setex('session:abc', 3600, { userId: 123 });

// Get value
const session = await kv.get('session:abc');

// Delete
await kv.del('session:abc');

Atomic Operations:

const views = await kv.incr('views:post:123');
const wasSet = await kv.setnx('lock:process', 'running'); // Set if not exists

Multiple Keys:

const values = await kv.mget('user:1', 'user:2', 'user:3');
await kv.mset({ 'user:1': data1, 'user:2': data2 });

Known Issues Prevention

This skill prevents 10 documented issues:

#ErrorQuick Fix
1KV_REST_API_URL not definedRun vercel env pull .env.local
2Cannot serialize BigIntConvert to string, use plain objects
3Unexpected data returnedUse namespaced keys: user:123:profile
4Memory grows indefinitelyUse setex() with TTL
5Rate limit exceededBatch operations, upgrade plan
6Value too largeUse Vercel Blob for >100KB
7TypeScript type errorsUse kv.get<Type>() with Zod validation
8Pipeline silent failuresCheck results array from exec()
9Scan timeout errorsLimit count, iterate with cursor
10Session expires too earlyUse expire() for sliding window

See: references/known-issues.md for complete solutions with code examples.


Common Patterns Summary

PatternUse CaseKey API
Cache-AsideRead cachingget → fetch → setex
Write-ThroughWrite consistencysetex on write, del on delete
Rate LimitingAPI protectionincr + expire
Session ManagementUser sessionssetex, get, expire, del
Distributed LockConcurrency controlsetnx + expire + del
LeaderboardRankingszadd, zrange, zrevrank
PipelineBatch operationspipeline().exec()

See: references/common-patterns.md for complete implementations.


Configuration

.env.local

# Created by: vercel env pull .env.local
KV_REST_API_URL="https://your-database.kv.vercel-storage.com"
KV_REST_API_TOKEN="your-token-here"

.gitignore

.env.local
.env*.local

When to Load References

ReferenceLoad When...
references/known-issues.mdDebugging KV errors, type issues, or performance problems
references/common-patterns.mdImplementing caching, sessions, rate limiting, leaderboards, or locks

Dependencies

{
  "dependencies": {
    "@vercel/kv": "^3.0.0"
  }
}

Free Tier Limits: 30,000 commands/month, 256MB storage


Official Documentation


Troubleshooting

ProblemSolution
KV_REST_API_URL not definedRun vercel env pull .env.local
Rate limit exceededUse mget/pipeline, upgrade plan
Values not expiringUse setex() not set()
JSON serialization errorUse plain objects, convert BigInt to string

Token Savings: ~60% (patterns extracted to references) Error Prevention: 100% (all 10 documented issues) Ready for production!

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.