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.
npx agentmods add rules/pauljphilp/effectpatterns/concurrency-pattern-4-distribute-work-with-queuegit clone --depth 1 https://github.com/PaulJPhilp/EffectPatternsWhat 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 | $0.01208 | $0.01208 |
| Opus 5 | $0.00604 | $0.00604 |
| Sonnet 5 | $0.00242 | $0.00242 |
| Haiku 4.5 | $0.00121 | $0.00121 |
Grade A, and why
concurrency-pattern-4-distribute-work-with-queue 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 3d 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 — 175 lines — stays where its author put it; the contents beside it link to each section on GitHub.
description: Use Queue to distribute work between producers and consumers with built-in backpressure, enabling flexible pipeline coordination. globs: "**/*.ts" alwaysApply: true
Concurrency Pattern 4: Distribute Work with Queue
Rule: Use Queue to distribute work between producers and consumers with built-in backpressure, enabling flexible pipeline coordination.
Example
This example demonstrates a producer-consumer pipeline with a bounded queue for buffering work items.
import { Effect, Queue, Fiber, Ref } from "effect";
interface WorkItem {
readonly id: number;
readonly data: string;
readonly timestamp: number;
}
interface WorkResult {
readonly itemId: number;
readonly processed: string;
readonly duration: number;
}
// Producer: generates work items
const producer = (
queue: Queue.Enqueue<WorkItem>,
count: number
): Effect.Effect<void> =>
Effect.gen(function* () {
yield* Effect.log(`[PRODUCER] Starting, generating ${count} items`);
for (let i = 1; i <= count; i++) {
const item: WorkItem = {
id: i,
data: `Item ${i}`,
timestamp: Date.now(),
};
const start = Date.now();
// Enqueue - will block if queue is full (backpressure)
yield* Queue.offer(queue, item);
const delay = Date.now() - start;
if (delay > 0) {
yield* Effect.log(
`[PRODUCER] Item ${i} enqueued (waited ${delay}ms due to backpressure)`
);
} else {
yield* Effect.log(`[PRODUCER] Item ${i} enqueued`);
}
// Simulate work
yield* Effect.sleep("50 millis");
}
yield* Effect.log(`[PRODUCER] ✓ All items enqueued`);
});
// Consumer: processes work items
const consumer = (
queue: Queue.Dequeue<WorkItem>,
consumerId: number,
results: Ref.Ref<WorkResult[]>
): Effect.Effect<void> =>
Effect.gen(function* () {
yield* Effect.log(`[CONSUMER ${consumerId}] Starting`);
while (true) {
// Dequeue - will block if queue is empty
const item = yield* Queue.take(queue).pipe(Effect.either);
if (item._tag === "Left") {
yield* Effect.log(`[CONSUMER ${consumerId}] Queue closed, stopping`);
return;
}
const workItem = item.right;
const startTime = Date.now();
yield* Effect.log(
`[CONSUMER ${consumerId}] Processing ${workItem.data}`
);
// Simulate processing
yield* Effect.sleep("150 millis");
const duration = Date.now() - startTime;
const result: WorkResult = {
itemId: workItem.id,
processed: `${workItem.data} [processed by consumer ${consumerId}]`,
duration,
};
yield* Ref.update(results, (rs) => [...rs, result]);
yield* Effect.log(
`[CONSUMER ${consumerId}] ✓ Completed ${workItem.data} in ${duration}ms`
);
}
});
// Main: coordinate producer and consumers
const program = Effect.gen(function* () {
// Create bounded queue with capacity 3
const queue = yield* Queue.bounded<WorkItem>(3);
const results = yield* Ref.make<WorkResult[]>([]);
console.log(`\n[MAIN] Starting producer-consumer pipeline with queue size 3\n`);
// Spawn producer
const producerFiber = yield* producer(queue, 10).pipe(Effect.fork);
// Spawn 2 consumers
const consumer1 = yield* consumer(queue, 1, results).pipe(Effect.fork);
const consumer2 = yield* consumer(queue, 2, results).pipe(Effect.fork);
// Wait for producer to finish
yield* Fiber.join(producerFiber);
// Give consumers time to finish
yield* Effect.sleep("3 seconds");
// Close queue and wait for consumers
yield* Queue.shutdown(queue);
yield* Fiber.join(consumer1);
yield* Fiber.join(consumer2);
// Summary
const allResults = yield* Ref.get(results);
const totalDuration = allResults.reduce((sum, r) => sum + r.duration, 0);
console.log(`\n[SUMMARY]`);
console.log(` Items processed: ${allResults.length}`);
console.log(
` Avg processing time: ${Math.round(totalDuration / allResults.length)}ms`
);
});
Effect.runPromise(program);
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.
- 3d ago First seen · 175 lines · 1,208 tokens per session scan A 6c4a3c6015e7
concurrency-pattern-4-distribute-work-with-queue is a cursor rule published in the GitHub repository PaulJPhilp/EffectPatterns (795 stars, last pushed 2mo ago), licensed MIT. It adds 1,208 tokens to every session, about $0.0060 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.
Other cursor rules, from other repositories
typescript-code-generation-rules
Rules for generating TypeScript code in Next.js 14 components, including component definition syntax, props definitions, and named/default exports.
typescript-coding-style
Enforces code style and best practices for TypeScript files.
react-and-typescript-general-rules
General rules for React and TypeScript projects, focusing on code clarity and best practices.
astro-development-guidelines
Enforces specific development guidelines for Astro projects, including TypeScript strictness and TailwindCSS usage.
javascript-typescript-code-style
Rules for JavaScript and TypeScript code style, including modern features, functional patterns, and descriptive naming conventions.
typescript-usage-rules
Specific rules for TypeScript usage, including interfaces, union types, and type guards to enhance type safety.