automatically-retry-failed-operations

automatically-retry-failed-operations is a cursor rule for Cursor from PaulJPhilp/EffectPatterns. It costs 949 tokens per session, scanned A, original, MIT.

A TypeScript pattern for retrying stream operations when they fail temporarily, using an Effect retry schedule.

In plain words
What is it for?
Use it when processing lists or streams of items whose API calls may fail and later succeed.
Why use it?
It lets operations recover from transient failures such as a temporarily unavailable API instead of stopping immediately.

Cursor rule for Cursor

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

Good fit Use it when processing lists or streams of items whose API calls may fail and later succeed.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/pauljphilp/effectpatterns/automatically-retry-failed-operations
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 automatically-retry-failed-operations

README.md
[![agentmods](https://agentmods.dev/badge/rules/pauljphilp/effectpatterns/automatically-retry-failed-operations/github.svg)](https://agentmods.dev/rules/pauljphilp/effectpatterns/automatically-retry-failed-operations)
Your own site
<a href="https://agentmods.dev/rules/pauljphilp/effectpatterns/automatically-retry-failed-operations"><img src="https://agentmods.dev/badge/rules/pauljphilp/effectpatterns/automatically-retry-failed-operations/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 automatically-retry-failed-operations

Your own site · 80×15
<a href="https://agentmods.dev/rules/pauljphilp/effectpatterns/automatically-retry-failed-operations"><img src="https://agentmods.dev/badge/rules/pauljphilp/effectpatterns/automatically-retry-failed-operations.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 949 This file is loaded in full into every session.
When invoked 949 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.00949 $0.00949
Opus 5.5 $0.00380 $0.00380
Sonnet 5.5 $0.00190 $0.00190
Haiku 4.5 $0.00095 $0.00095

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

Security

Grade A, and why

automatically-retry-failed-operations 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.

content/published/rules/cursor/automatically-retry-failed-operations.mdc · 98 lines

How it starts

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

description: Compose a Stream with the .retry(Schedule) operator to automatically recover from transient failures. globs: "**/*.ts" alwaysApply: true

Automatically Retry Failed Operations

Rule: Compose a Stream with the .retry(Schedule) operator to automatically recover from transient failures.

Example

This example simulates an API that fails the first two times it's called. The stream processes a list of IDs, and the retry operator ensures that the failing operation for id: 2 is automatically retried until it succeeds.

import { Effect, Stream, Schedule } from "effect";

// A mock function that simulates a flaky API call
const processItem = (id: number): Effect.Effect<string, Error> =>
  Effect.gen(function* () {
    yield* Effect.log(`Attempting to process item ${id}...`);

    // Item 2 fails on first attempt but succeeds on retry
    if (id === 2) {
      const random = Math.random();
      if (random < 0.5) {
        // 50% chance of failure for demonstration
        yield* Effect.log(`Item ${id} failed, will retry...`);
        return yield* Effect.fail(new Error("API is temporarily down"));
      }
    }

    yield* Effect.log(`✅ Successfully processed item ${id}`);
    return `Processed item ${id}`;
  });

const ids = [1, 2, 3];

// Define a retry policy: 3 attempts with a fixed 100ms delay
const retryPolicy = Schedule.recurs(3).pipe(
  Schedule.addDelay(() => "100 millis")
);

const program = Effect.gen(function* () {
  yield* Effect.log("=== Stream Retry on Failure Demo ===");
  yield* Effect.log(
    "Processing items with retry policy (3 attempts, 100ms delay)"
  );

  // Process each item individually with retry
  const results = yield* Effect.forEach(
    ids,
    (id) =>
      processItem(id).pipe(
        Effect.retry(retryPolicy),
        Effect.catchAll((error) =>
          Effect.gen(function* () {
            yield* Effect.log(
              `❌ Item ${id} failed after all retries: ${error.message}`
            );
            return `Failed: item ${id}`;
          })
        )
      ),
    { concurrency: 1 }
  );

  yield* Effect.log("=== Results ===");
  for (let index = 0; index < results.length; index++) {
    yield* Effect.log(`Item ${ids[index]}: ${results[index]}`);
  }

  yield* Effect.log("✅ Stream processing completed");
});

Effect.runPromise(program).catch((error) => {
  Effect.runSync(Effect.logError("Unexpected error: " + error));
});
/*
Output:
... level=INFO msg="Attempting to process item 1..."
... level=INFO msg="Attempting to process item 2..."
... level=INFO msg="Item 2 failed, attempt 1."
... level=INFO msg="Attempting to process item 2..."
... level=INFO msg="Item 2 failed, attempt 2."
... level=INFO msg="Attempting to process item 2..."
... level=INFO msg="Attempting to process item 3..."
*/

Read the full file on GitHub · 98 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. 3mo ago First seen · 98 lines · 949 tokens per session scan A ef64b811a466

Subscribe to this mod's changes

automatically-retry-failed-operations is a cursor rule published in the GitHub repository PaulJPhilp/EffectPatterns (807 stars, last pushed 5mo ago), licensed MIT. It adds 949 tokens to every session, about $0.0038 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.

Related

automatically-retry-failed-operations compared with cursor rules from other repositories

automatically-retry-failed-operations next to 6 cursor rules from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
automatically-retry-failed-operationsPaulJPhilp/EffectPatternsCursor rule8075mo agoMITA949Cursor
error-handling-prioritiesWebDevPeterGriffin/The-VibeCode-BibleCursor rule4226d agononeA133Cursor
conditional-encapsulationWebDevPeterGriffin/The-VibeCode-BibleCursor rule4226d agononeA71Cursor
bug-handling-with-todo-commentsWebDevPeterGriffin/The-VibeCode-BibleCursor rule4226d agononeA66Cursor
dragonruby-error-handlingWebDevPeterGriffin/The-VibeCode-BibleCursor rule4226d agononeA47Cursor
testing-and-debugging-rulesWebDevPeterGriffin/The-VibeCode-BibleCursor rule4226d agononeA29Cursor
ponytailDietrichGebert/ponytailCursor rule201k8d agoMITA604Cursor