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/fan-out-to-multiple-consumers)<a href="https://agentmods.dev/rules/pauljphilp/effectpatterns/fan-out-to-multiple-consumers"><img src="https://agentmods.dev/badge/rules/pauljphilp/effectpatterns/fan-out-to-multiple-consumers.svg" alt="Measured on agentmods" 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.01229 | $0.01229 |
| Opus 5 | $0.00615 | $0.00615 |
| Sonnet 5 | $0.00246 | $0.00246 |
| Haiku 4.5 | $0.00123 | $0.00123 |
Grade A, and why
fan-out-to-multiple-consumers 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.
How it starts
The opening of the file, as written. The whole thing — 178 lines — stays where its author put it; the contents beside it link to each section on GitHub.
description: Use broadcast or partition to send stream data to multiple consumers. globs: "**/*.ts" alwaysApply: true
Fan Out to Multiple Consumers
Rule: Use broadcast or partition to send stream data to multiple consumers.
Example
import { Effect, Stream, Queue, Fiber, Chunk } from "effect"
// ============================================
// 1. Broadcast to all consumers
// ============================================
const broadcastExample = Effect.scoped(
Effect.gen(function* () {
const source = Stream.fromIterable([1, 2, 3, 4, 5])
// Broadcast to 3 consumers - each gets all items
const [stream1, stream2, stream3] = yield* Stream.broadcast(source, 3)
// Consumer 1: Log items
const consumer1 = stream1.pipe(
Stream.tap((n) => Effect.log(`Consumer 1: ${n}`)),
Stream.runDrain
)
// Consumer 2: Sum items
const consumer2 = stream2.pipe(
Stream.runFold(0, (acc, n) => acc + n),
Effect.tap((sum) => Effect.log(`Consumer 2 sum: ${sum}`))
)
// Consumer 3: Collect to array
const consumer3 = stream3.pipe(
Stream.runCollect,
Effect.tap((items) => Effect.log(`Consumer 3 collected: ${Chunk.toReadonlyArray(items)}`))
)
// Run all consumers in parallel
yield* Effect.all([consumer1, consumer2, consumer3], { concurrency: 3 })
})
)
// ============================================
// 2. Partition by predicate
// ============================================
const partitionExample = Effect.gen(function* () {
const numbers = Stream.fromIterable([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
// Partition into even and odd
const [evens, odds] = yield* Stream.partition(
numbers,
(n) => n % 2 === 0
)
const processEvens = evens.pipe(
Stream.tap((n) => Effect.log(`Even: ${n}`)),
Stream.runDrain
)
const processOdds = odds.pipe(
Stream.tap((n) => Effect.log(`Odd: ${n}`)),
Stream.runDrain
)
yield* Effect.all([processEvens, processOdds], { concurrency: 2 })
})
// ============================================
// 3. Partition into multiple buckets
// ============================================
interface Event {
type: "click" | "scroll" | "submit"
data: unknown
}
const multiPartitionExample = Effect.gen(function* () {
const events: Event[] = [
{ type: "click", data: { x: 100 } },
{ type: "scroll", data: { y: 200 } },
{ type: "submit", data: { form: "login" } },
{ type: "click", data: { x: 150 } },
{ type: "scroll", data: { y: 300 } },
]
const source = Stream.fromIterable(events)
// Group by type using groupByKey
const grouped = source.pipe(
Stream.groupByKey((event) => event.type, {
bufferSize: 16,
})
)
// Process each group
yield* grouped.pipe(
Stream.flatMap(([key, stream]) =>
stream.pipe(
Stream.tap((event) => Effect.log(`[${key}] Processing: ${JSON.stringify(event.data)}`)),
Stream.runDrain,
Stream.fromEffect
)
),
Stream.runDrain
)
})
// ============================================
// 4. Fan-out with queues (manual control)
// ============================================
const queueFanOut = Effect.gen(function* () {
const source = Stream.fromIterable([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
// Create queues for each consumer
const queue1 = yield* Queue.unbounded<number>()
const queue2 = yield* Queue.unbounded<number>()
const queue3 = yield* Queue.unbounded<number>()
// Distribute items round-robin
const distributor = source.pipe(
Stream.zipWithIndex,
Stream.tap(([item, index]) => {
const queue = index % 3 === 0 ? queue1 : index % 3 === 1 ? queue2 : queue3
return Queue.offer(queue, item)
}),
Stream.runDrain,
Effect.tap(() => Effect.all([
Queue.shutdown(queue1),
Queue.shutdown(queue2),
Queue.shutdown(queue3),
]))
)
// Consumers
const makeConsumer = (name: string, queue: Queue.Queue<number>) =>
Stream.fromQueue(queue).pipe(
Stream.tap((n) => Effect.log(`${name}: ${n}`)),
Stream.runDrain
)
yield* Effect.all([
distributor,
makeConsumer("Worker 1", queue1),
makeConsumer("Worker 2", queue2),
makeConsumer("Worker 3", queue3),
], { concurrency: 4 })
})
// ============================================
// 5. Run examples
// ============================================
const program = Effect.gen(function* () {
yield* Effect.log("=== Broadcast Example ===")
yield* broadcastExample
yield* Effect.log("\n=== Partition Example ===")
yield* partitionExample
})
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.
- 4d ago First seen · 178 lines · 1,229 tokens per session scan A 0fb5eac109b5
fan-out-to-multiple-consumers is a cursor rule published in the GitHub repository PaulJPhilp/EffectPatterns (796 stars, last pushed 2mo ago), licensed MIT. It adds 1,229 tokens to every session, about $0.0061 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.
Other cursor rules, from other repositories
workflow
This file provides rules and context for generating or understanding Go code related to a custom Domain Specific Language (DSL) for defining Temporal workflows within this project.
activities
This file provides rules and context for generating or understanding Go code related to Temporal activities within this project with the specific purpose of using a simple DSL to specify workflows.
go-api-development-general-rules
General rules for Go API development using the net/http package, focusing on code quality, security, and best practices.
backend-general-expert
General rule for backend development expertise across the project.
service-class-conventions
Defines the structure and implementation of service classes, enforcing the use of interfaces, ServiceImpl classes, DTOs for data transfer, and transactional management.
go-grpc-service-rule
Specific guidelines for implementing gRPC services in Go.