platform-pattern-3-persistent-key-value-storage

platform-pattern-3-persistent-key-value-storage is a cursor rule for Cursor from PaulJPhilp/EffectPatterns. It costs 982 tokens per session, scanned A, original, MIT.

A TypeScript rule for storing and retrieving simple key-and-value data that persists between program runs.

In plain words
What is it for?
Use it for session data, simple caches, and other small persistent values.
Why use it?
It provides lightweight storage for small pieces of state without requiring a full database.

Cursor rule for Cursor

Written for Cursor: a Cursor rule (.mdc).

Good fit Use it for session data, simple caches, and other small persistent values.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/pauljphilp/effectpatterns/platform-pattern-3-persistent-key-value-storage
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.

Clone the repo
git clone --depth 1 https://github.com/PaulJPhilp/EffectPatterns

Made for: Cursor.

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 platform-pattern-3-persistent-key-value-storage

README.md
[![agentmods](https://agentmods.dev/badge/rules/pauljphilp/effectpatterns/platform-pattern-3-persistent-key-value-storage/github.svg)](https://agentmods.dev/rules/pauljphilp/effectpatterns/platform-pattern-3-persistent-key-value-storage)
Your own site
<a href="https://agentmods.dev/rules/pauljphilp/effectpatterns/platform-pattern-3-persistent-key-value-storage"><img src="https://agentmods.dev/badge/rules/pauljphilp/effectpatterns/platform-pattern-3-persistent-key-value-storage/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.

agentmods 80×15 button for platform-pattern-3-persistent-key-value-storage

Your own site · 80×15
<a href="https://agentmods.dev/rules/pauljphilp/effectpatterns/platform-pattern-3-persistent-key-value-storage"><img src="https://agentmods.dev/badge/rules/pauljphilp/effectpatterns/platform-pattern-3-persistent-key-value-storage.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 982 This file is loaded in full into every session.
When invoked 982 The same file — it is already loaded in full.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
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.00982 $0.00982
Opus 5.5 $0.00393 $0.00393
Sonnet 5.5 $0.00196 $0.00196
Haiku 4.5 $0.00098 $0.00098

Measured 2mo ago against content hash 06913bd3bf85, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

platform-pattern-3-persistent-key-value-storage 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 2mo 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.

content/published/rules/cursor/platform-pattern-3-persistent-key-value-storage.mdc · 141 lines

How it starts

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

description: Use KeyValueStore for simple persistent storage of key-value pairs, enabling lightweight caching and session management. globs: "**/*.ts" alwaysApply: true

Platform Pattern 3: Persistent Key-Value Storage

Rule: Use KeyValueStore for simple persistent storage of key-value pairs, enabling lightweight caching and session management.

Example

This example demonstrates storing and retrieving persistent data.

import { KeyValueStore, Effect } from "@effect/platform";

interface UserSession {
  readonly userId: string;
  readonly token: string;
  readonly expiresAt: number;
}

const program = Effect.gen(function* () {
  console.log(`\n[KEYVALUESTORE] Persistent storage example\n`);

  const store = yield* KeyValueStore.KeyValueStore;

  // Example 1: Store session data
  console.log(`[1] Storing session:\n`);

  const session: UserSession = {
    userId: "user-123",
    token: "token-abc-def",
    expiresAt: Date.now() + 3600000, // 1 hour
  };

  yield* store.set("session:user-123", JSON.stringify(session));

  yield* Effect.log(`✓ Session stored`);

  // Example 2: Retrieve stored data
  console.log(`\n[2] Retrieving session:\n`);

  const stored = yield* store.get("session:user-123");

  if (stored._tag === "Some") {
    const retrievedSession = JSON.parse(stored.value) as UserSession;

    console.log(`  User ID: ${retrievedSession.userId}`);
    console.log(`  Token: ${retrievedSession.token}`);
    console.log(
      `  Expires: ${new Date(retrievedSession.expiresAt).toISOString()}`
    );
  }

  // Example 3: Check if key exists
  console.log(`\n[3] Checking keys:\n`);

  const hasSession = yield* store.has("session:user-123");
  const hasOther = yield* store.has("session:user-999");

  console.log(`  Has session:user-123: ${hasSession}`);
  console.log(`  Has session:user-999: ${hasOther}`);

  // Example 4: Store multiple cache entries
  console.log(`\n[4] Caching API responses:\n`);

  const apiResponses = [
    { endpoint: "/api/users", data: [{ id: 1, name: "Alice" }] },
    { endpoint: "/api/posts", data: [{ id: 1, title: "First Post" }] },
    { endpoint: "/api/comments", data: [] },
  ];

  yield* Effect.all(
    apiResponses.map((item) =>
      store.set(
        `cache:${item.endpoint}`,
        JSON.stringify(item.data)
      )
    )
  );

  yield* Effect.log(`✓ Cached ${apiResponses.length} endpoints`);

  // Example 5: Retrieve cache with expiration
  console.log(`\n[5] Checking cached data:\n`);

  for (const item of apiResponses) {
    const cached = yield* store.get(`cache:${item.endpoint}`);

    if (cached._tag === "Some") {
      const data = JSON.parse(cached.value);

      console.log(
        `  ${item.endpoint}: ${Array.isArray(data) ? data.length : 1} items`
      );
    }
  }

  // Example 6: Remove specific entry
  console.log(`\n[6] Removing entry:\n`);

  yield* store.remove("cache:/api/comments");

  const removed = yield* store.has("cache:/api/comments");

  console.log(`  Exists after removal: ${removed}`);

  // Example 7: Iterate and count entries
  console.log(`\n[7] Counting entries:\n`);

  const allKeys = yield* store.entries.pipe(
    Effect.map((entries) => entries.length)
  );

  console.log(`  Total entries: ${allKeys}`);
});

Effect.runPromise(program);

Read the full file on GitHub · 141 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. 2mo ago First seen · 141 lines · 982 tokens per session scan A 06913bd3bf85

Subscribe to this mod's changes

platform-pattern-3-persistent-key-value-storage is a cursor rule published in the GitHub repository PaulJPhilp/EffectPatterns (807 stars, last pushed 5mo ago), licensed MIT. It adds 982 tokens to every session, about $0.0039 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-09-03.

Related

platform-pattern-3-persistent-key-value-storage compared with cursor rules from other repositories

platform-pattern-3-persistent-key-value-storage next to 6 cursor rules from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
platform-pattern-3-persistent-key-value-storagePaulJPhilp/EffectPatternsCursor rule8075mo agoMITA982Cursor
spring-boot-redislsampaioweb/ai-instructionsCursor rule110d agoMITA0Cursor
django-orm-for-database-operationsWebDevPeterGriffin/The-VibeCode-BibleCursor rule4226d agononeA48Cursor
nosql-specialist-intelligentshahshrey/cursor-hubCursor rule1520d agononeA150Cursor
caching-managementhhx465453939/mcp-pubmed-serverCursor rule69mo agoApache-2.0A0Cursor
canonical__eedisBilal140202/the-lord-of-the-skillsCursor rule62mo agoMITA468Cursor
ponytailDietrichGebert/ponytailCursor rule201k8d agoMITA604Cursor