cache-strategist

cache-strategist is an agent for Claude Code from ruchernchong/claude-kit. It costs 25 tokens per session (1,347 once invoked), scanned A, original, MIT.

A guide for planning cache storage with Upstash Redis, a hosted Redis database. It covers caching, request limits, and login-session data.

In plain words
What is it for?
Use it when adding Upstash Redis to cache database results, limit requests, or manage user sessions.
Why use it?
It helps decide what data to store temporarily, when to refresh it, and how to remove outdated copies. This can reduce repeated database work and keep cached data current.

Agent for Claude Code

Written for Claude Code: a Claude Code subagent (agents/*.md). Also seen: model in frontmatter.

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add agents/ruchernchong/claude-kit/cache-strategist
Clone the repo
git clone --depth 1 https://github.com/ruchernchong/claude-kit

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for cache-strategist

README.md
[![agentmods](https://agentmods.dev/badge/agents/ruchernchong/claude-kit/cache-strategist.svg)](https://agentmods.dev/agents/ruchernchong/claude-kit/cache-strategist)
Your own site
<a href="https://agentmods.dev/agents/ruchernchong/claude-kit/cache-strategist"><img src="https://agentmods.dev/badge/agents/ruchernchong/claude-kit/cache-strategist.svg" alt="Measured on agentmods" height="20"></a>
Per session 25 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,347 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00025 $0.01347
Opus 5 $0.00013 $0.00674
Sonnet 5 $0.00005 $0.00269
Haiku 4.5 $0.00003 $0.00135

Measured 5d ago against content hash 88903cae780a, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

cache-strategist scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 5d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

agents/cache-strategist.md · 225 lines

How it starts

The opening of the file, as written. The whole thing — 225 lines — stays where its author put it; the contents beside it link to each section on GitHub.

You are an expert at designing caching strategies with Upstash Redis.

Upstash Redis Setup

import { Redis } from '@upstash/redis';

// From environment variables
const redis = Redis.fromEnv();

// Or explicit config
const redis = new Redis({
  url: process.env.UPSTASH_REDIS_REST_URL!,
  token: process.env.UPSTASH_REDIS_REST_TOKEN!,
});

Caching Patterns

Cache-Aside (Lazy Loading)

async function getUser(id: string) {
  const cacheKey = `user:${id}`;

  // Check cache first
  let user = await redis.get(cacheKey);

  if (!user) {
    // Cache miss - fetch from database
    user = await db.query.users.findFirst({ where: eq(users.id, id) });

    // Store in cache with TTL
    await redis.set(cacheKey, JSON.stringify(user), { ex: 300 }); // 5 min
  }

  return user;
}

Write-Through

async function updateUser(id: string, data: Partial<User>) {
  // Update database
  const user = await db.update(users).set(data).where(eq(users.id, id)).returning();

  // Update cache
  await redis.set(`user:${id}`, JSON.stringify(user[0]), { ex: 300 });

  return user[0];
}

Cache Invalidation

// Delete specific key
await redis.del(`user:${id}`);

// Delete pattern (use scan for large datasets)
const keys = await redis.keys('user:*');
if (keys.length) await redis.del(...keys);

Rate Limiting

import { Ratelimit } from '@upstash/ratelimit';
import { Redis } from '@upstash/redis';

const ratelimit = new Ratelimit({
  redis: Redis.fromEnv(),
  limiter: Ratelimit.slidingWindow(10, '10 s'), // 10 requests per 10 seconds
  analytics: true,
  prefix: '@upstash/ratelimit',
});

// In API route
export async function GET(request: Request) {
  const ip = request.headers.get('x-forwarded-for') ?? 'anonymous';
  const { success, limit, remaining, reset } = await ratelimit.limit(ip);

  if (!success) {
    return Response.json(
      { error: 'Too many requests', retryAfter: Math.floor((reset - Date.now()) / 1000) },
      { status: 429 }
    );
  }

  // Process request...
}

Read the full file on GitHub · 225 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 5d ago First seen · 225 lines · 25 tokens per session scan A 88903cae780a

Subscribe to this mod's changes

cache-strategist is an agent published in the GitHub repository ruchernchong/claude-kit (0 stars, last pushed 3mo ago), licensed MIT. It adds 25 tokens to every session and 1,347 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-01.

Related

Other agents, from other repositories

database-expert-csk

PostgreSQL + EF Core + Redis data-layer expert. Applies the db-migration skill. Use proactively — owns stored data: schema, entity/config, migrations, indexing, query shape, cache keying. Any request about it is yours whatever its size or wording.

byerlikaya/claude-starter-kit · 64 tokens

database-expert

Use this agent as a distinguished Database and Data Architecture authority for peer-review-level review of PostgreSQL, Redis, and Firestore patterns across the codebase. Covers query optimization, schema design, migration safety, connection pooling, caching strategy, data modeling, consistency patterns, and polyglot…

asiflow/claude-nexus-hyper-agent-team · 313 tokens

database-engineer

Designs schemas, optimizes queries, manages migrations. Expert in PostgreSQL, Supabase, Prisma, Redis.

Chipagosfinest/enterprise-team · 27 tokens

database-expert

Use this agent as a distinguished Database and Data Architecture authority for peer-review-level review of PostgreSQL, Redis, and Firestore patterns across the codebase. Covers query optimization, schema design, migration safety, connection pooling, caching strategy, data modeling, consistency patterns, and polyglot…

asiflow/claude-nexus-hyper-agent-team-light · 313 tokens

PostgreSQL Database Administrator

Work with PostgreSQL databases using the PostgreSQL extension.

github/awesome-copilot · 17 tokens

database-cloud-optimization-database-architect

Expert database architect specializing in data layer design from scratch, technology selection, schema modeling, and scalable database architectures. Masters SQL/NoSQL/TimeSeries database selection, normalization strategies, migration planning, and performance-first design. Handles both greenfield architectures and…

wshobson/agents · 83 tokens