control-repetition-with-schedule

control-repetition-with-schedule is a cursor rule for Cursor from PaulJPhilp/EffectPatterns. It costs 520 tokens per session, scanned A, original, MIT.

A TypeScript pattern for defining reusable schedules that control repetition and retries of Effect computations.

In plain words
What is it for?
Use it to retry temporary failures with exponential backoff, random delay, and a maximum number of attempts.
Why use it?
It prevents retry logic from being scattered through application code and can space repeated attempts over time.

Cursor rule for Cursor

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

Good fit Use it to retry temporary failures with exponential backoff, random delay, and a maximum number of attempts.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/pauljphilp/effectpatterns/control-repetition-with-schedule
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 control-repetition-with-schedule

README.md
[![agentmods](https://agentmods.dev/badge/rules/pauljphilp/effectpatterns/control-repetition-with-schedule.svg)](https://agentmods.dev/rules/pauljphilp/effectpatterns/control-repetition-with-schedule)
Your own site
<a href="https://agentmods.dev/rules/pauljphilp/effectpatterns/control-repetition-with-schedule"><img src="https://agentmods.dev/badge/rules/pauljphilp/effectpatterns/control-repetition-with-schedule.svg" alt="Measured on agentmods" height="20"></a>
Per session 520 This file is loaded in full into every session.
When invoked 520 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.00520 $0.00520
Opus 5 $0.00260 $0.00260
Sonnet 5 $0.00104 $0.00104
Haiku 4.5 $0.00052 $0.00052

Measured 4d ago against content hash 1801b4e4f250, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-07, from the pricing page.

Security

Grade A, and why

control-repetition-with-schedule 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.

content/published/rules/cursor/control-repetition-with-schedule.mdc · 60 lines

How it starts

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

description: Use Schedule to create composable policies for controlling the repetition and retrying of effects. globs: "**/*.ts" alwaysApply: true

Control Repetition with Schedule

Rule: Use Schedule to create composable policies for controlling the repetition and retrying of effects.

Example

This example demonstrates composition by creating a common, robust retry policy: exponential backoff with jitter, limited to 5 attempts.

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

// A simple effect that can fail
const flakyEffect = Effect.try({
  try: () => {
    if (Math.random() > 0.2) {
      throw new Error("Transient error");
    }
    return "Operation succeeded!";
  },
  catch: (error: unknown) => {
    Effect.logInfo("Operation failed, retrying...");
    return error;
  },
});

// --- Building a Composable Schedule ---

// 1. Start with a base exponential backoff (100ms, 200ms, 400ms...)
const exponentialBackoff = Schedule.exponential("100 millis");

// 2. Add random jitter to avoid thundering herd problems
const withJitter = Schedule.jittered(exponentialBackoff);

// 3. Limit the schedule to a maximum of 5 repetitions
const limitedWithJitter = Schedule.compose(withJitter, Schedule.recurs(5));

// --- Using the Schedule ---
const program = Effect.gen(function* () {
  yield* Effect.logInfo("Starting operation...");
  const result = yield* Effect.retry(flakyEffect, limitedWithJitter);
  yield* Effect.logInfo(`Final result: ${result}`);
});

// Run the program
Effect.runPromise(program);

Explanation:
While you could write manual loops or recursive functions, Schedule provides a much more powerful, declarative, and composable way to manage repetition. The key benefits are:

  • Declarative: You separate the what (the effect to run) from the how and when (the schedule it runs on).
  • Composable: You can build complex schedules from simple, primitive ones. For example, you can create a schedule that runs "up to 5 times, with an exponential backoff, plus some random jitter" by composing Schedule.recurs, Schedule.exponential, and Schedule.jittered.
  • Stateful: A Schedule keeps track of its own state (like the number of repetitions), making it easy to create policies that depend on the execution history.

Read the full file on GitHub · 60 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 · 60 lines · 520 tokens per session scan A 1801b4e4f250

Subscribe to this mod's changes

control-repetition-with-schedule is a cursor rule published in the GitHub repository PaulJPhilp/EffectPatterns (796 stars, last pushed 2mo ago), licensed MIT. It adds 520 tokens to every session, about $0.0026 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-03.