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.
git clone --depth 1 https://github.com/PaulJPhilp/EffectPatternsWrote 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.
[](https://agentmods.dev/rules/pauljphilp/effectpatterns/add-caching-by-wrapping-a-layer)<a href="https://agentmods.dev/rules/pauljphilp/effectpatterns/add-caching-by-wrapping-a-layer"><img src="https://agentmods.dev/badge/rules/pauljphilp/effectpatterns/add-caching-by-wrapping-a-layer/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/rules/pauljphilp/effectpatterns/add-caching-by-wrapping-a-layer"><img src="https://agentmods.dev/badge/rules/pauljphilp/effectpatterns/add-caching-by-wrapping-a-layer.svg" alt="Reviewed on agentmods" width="80" height="20"></a>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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00729 | $0.00729 |
| Opus 5.5 | $0.00292 | $0.00292 |
| Sonnet 5.5 | $0.00146 | $0.00146 |
| Haiku 4.5 | $0.00073 | $0.00073 |
Grade A, and why
add-caching-by-wrapping-a-layer 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 3mo 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.
How it starts
The opening of the file, as written. The whole thing — 93 lines — stays where its author put it; the contents beside it link to each section on GitHub.
description: Use a wrapping Layer to add cross-cutting concerns like caching to a service without altering its original implementation. globs: "**/*.ts" alwaysApply: true
Add Caching by Wrapping a Layer
Rule: Use a wrapping Layer to add cross-cutting concerns like caching to a service without altering its original implementation.
Example
We have a WeatherService that makes slow API calls. We create a WeatherService.cached wrapper layer that adds an in-memory cache using a Ref and a Map.
import { Effect, Layer, Ref } from "effect";
// 1. Define the service interface
class WeatherService extends Effect.Service<WeatherService>()(
"WeatherService",
{
sync: () => ({
getForecast: (city: string) => Effect.succeed(`Sunny in ${city}`),
}),
}
) {}
// 2. The "Live" implementation that is slow
const WeatherServiceLive = Layer.succeed(
WeatherService,
WeatherService.of({
_tag: "WeatherService",
getForecast: (city) =>
Effect.succeed(`Sunny in ${city}`).pipe(
Effect.delay("2 seconds"),
Effect.tap(() => Effect.log(`Fetched live forecast for ${city}`))
),
})
);
// 3. The Caching Wrapper Layer
const WeatherServiceCached = Layer.effect(
WeatherService,
Effect.gen(function* () {
// It REQUIRES the original WeatherService
const underlyingService = yield* WeatherService;
const cache = yield* Ref.make(new Map<string, string>());
return WeatherService.of({
_tag: "WeatherService",
getForecast: (city) =>
Ref.get(cache).pipe(
Effect.flatMap((map) =>
map.has(city)
? Effect.log(`Cache HIT for ${city}`).pipe(
Effect.as(map.get(city)!)
)
: Effect.log(`Cache MISS for ${city}`).pipe(
Effect.flatMap(() => underlyingService.getForecast(city)),
Effect.tap((forecast) =>
Ref.update(cache, (map) => map.set(city, forecast))
)
)
)
),
});
})
);
// 4. Compose the final layer. The wrapper is provided with the live implementation.
const AppLayer = Layer.provide(WeatherServiceCached, WeatherServiceLive);
// 5. The application logic
const program = Effect.gen(function* () {
const weather = yield* WeatherService;
yield* weather.getForecast("London"); // First call is slow (MISS)
yield* weather.getForecast("London"); // Second call is instant (HIT)
});
Effect.runPromise(Effect.provide(program, AppLayer));
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.
- 3mo ago First seen · 93 lines · 729 tokens per session scan A edd47f6570bd
add-caching-by-wrapping-a-layer is a cursor rule published in the GitHub repository PaulJPhilp/EffectPatterns (807 stars, last pushed 5mo ago), licensed MIT. It adds 729 tokens to every session, about $0.0029 per session on Opus 5.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.
add-caching-by-wrapping-a-layer compared with cursor rules from other repositories
| Mod | Type | Stars | Last push | Licence | Scan | Tokens | Works with |
|---|---|---|---|---|---|---|---|
| add-caching-by-wrapping-a-layerPaulJPhilp/EffectPatterns | Cursor rule | 807 | 5mo ago | MIT | A | 729 | Cursor |
| spring-boot-redislsampaioweb/ai-instructions | Cursor rule | 1 | 10d ago | MIT | A | 0 | Cursor |
| django-orm-for-database-operationsWebDevPeterGriffin/The-VibeCode-Bible | Cursor rule | 42 | 26d ago | none | A | 48 | Cursor |
| nosql-specialist-intelligentshahshrey/cursor-hub | Cursor rule | 15 | 20d ago | none | A | 150 | Cursor |
| caching-managementhhx465453939/mcp-pubmed-server | Cursor rule | 6 | 9mo ago | Apache-2.0 | A | 0 | Cursor |
| canonical__eedisBilal140202/the-lord-of-the-skills | Cursor rule | 6 | 2mo ago | MIT | A | 468 | Cursor |
| ponytailDietrichGebert/ponytail | Cursor rule | 201k | 8d ago | MIT | A | 604 | Cursor |