effect-cache

effect-cache is a skill for Claude Code, Codex from mpsuesser/pi-effect-harness. It costs 89 tokens per session (6,821 once invoked), scanned A, original, MIT.

An in-memory cache for results of keyed lookups, with expiration, least-recently-used removal, refresh, invalidation, and protection against duplicate concurrent lookups.

In plain words
What is it for?
Use it to cache API and database reads, add time-based expiration, refresh or invalidate entries, and manage cached resources that need cleanup.
Why use it?
It avoids repeating the same API or database work while a result is still usable. It also helps control memory use and coordinate callers asking for the same missing value at once.

Skill for Claude CodeCodex

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 skills/mpsuesser/pi-effect-harness/effect-cache
Any agent
npx skills add mpsuesser/pi-effect-harness --skill effect-cache
Clone the repo
git clone --depth 1 https://github.com/mpsuesser/pi-effect-harness

Made for: Claude Code, Codex.

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 effect-cache

README.md
[![agentmods](https://agentmods.dev/badge/skills/mpsuesser/pi-effect-harness/effect-cache.svg)](https://agentmods.dev/skills/mpsuesser/pi-effect-harness/effect-cache)
Your own site
<a href="https://agentmods.dev/skills/mpsuesser/pi-effect-harness/effect-cache"><img src="https://agentmods.dev/badge/skills/mpsuesser/pi-effect-harness/effect-cache.svg" alt="Measured on agentmods" height="20"></a>
Per session 89 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 6,821 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 $0.00089 $0.06821
Opus 5 $0.00044 $0.03410
Sonnet 5 $0.00018 $0.01364
Haiku 4.5 $0.00009 $0.00682

Measured 4d ago against content hash 49dabd453c75, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

effect-cache 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 4d 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.

harnesses/effect/skills/effect-cache/SKILL.md · 562 lines

How it starts

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

You are an Effect TypeScript expert specializing in in-memory caching with Cache and ScopedCache.

Effect Source Reference

The Effect v4 source is available at ~/.cache/effect-v4/. Browse and read files there directly to look up APIs, types, and implementations.

Reference this for:

  • Cache model, make/makeWith, and all combinators (packages/effect/src/Cache.ts)
  • ScopedCache — the variant whose entries own a Scope (packages/effect/src/ScopedCache.ts)
  • Precise behavioral semantics: LRU order, TTL, failure caching (packages/effect/test/Cache.test.ts)
  • Finalizer timing on eviction/expiry/invalidation/close (packages/effect/test/ScopedCache.test.ts)
  • Single-value memoization Effect.cached* (packages/effect/src/Effect.ts, category "caching")

Core Model

A Cache<Key, A, E, R> is a mutable keyed store populated by an effectful lookup function. Cache.get returns the cached value on a hit and runs the lookup on a miss or expired entry. Both are exposed as module functions (Cache.get(cache, key)), not methods. Every function taking extra arguments is dual (Cache.get(cache, key) or cache.pipe(Cache.get(key))); the unary ones (size, keys, values, entries, invalidateAll) are piped bare: cache.pipe(Cache.size).

import { Cache, Duration, Effect, Exit, Option, ScopedCache } from 'effect';
import { TestClock } from 'effect/testing';
interface Cache<Key, A, E = never, R = never> {
	readonly capacity: number;
	readonly lookup: (key: Key) => Effect.Effect<A, E, R>;
	readonly timeToLive: (exit: Exit.Exit<A, E>, key: Key) => Duration.Duration;
}

How to think about it:

  • Entries store the lookup Exit — successes and failures are cached. A failed lookup keeps failing from cache until the entry expires, is invalidated, or is refreshed.
  • Concurrent gets of the same missing key share one lookup. The first caller runs the lookup on its own fiber; the rest await the same Deferred.
  • Insertion-ordered map = LRU. Reads move the entry to the back; when capacity is exceeded the oldest entries are evicted.
  • TTL is computed per entry from the lookup Exit and the key, against the fiber's ClockTestClock works. Expiry is lazy: entries are removed when next touched.
  • ScopedCache is the same model where each entry additionally owns a Scope: resources acquired during the lookup live exactly as long as the entry is cached.

Read the full file on GitHub · 562 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. 4d ago First seen · 562 lines · 89 tokens per session scan A 49dabd453c75

Subscribe to this mod's changes

effect-cache is a skill published in the GitHub repository mpsuesser/pi-effect-harness (23 stars, last pushed 2mo ago), licensed MIT. It adds 89 tokens to every session and 6,821 once invoked, about $0.0004 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-08-30.