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/concurrency-pattern-2-rate-limit-concurrent-access-with-semaphore)<a href="https://agentmods.dev/rules/pauljphilp/effectpatterns/concurrency-pattern-2-rate-limit-concurrent-access-with-semaphore"><img src="https://agentmods.dev/badge/rules/pauljphilp/effectpatterns/concurrency-pattern-2-rate-limit-concurrent-access-with-semaphore.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.01020 | $0.01020 |
| Opus 5 | $0.00510 | $0.00510 |
| Sonnet 5 | $0.00204 | $0.00204 |
| Haiku 4.5 | $0.00102 | $0.00102 |
Grade A, and why
concurrency-pattern-2-rate-limit-concurrent-access-with-semaphore 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 7d 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 — 157 lines — stays where its author put it; the contents beside it link to each section on GitHub.
description: Use Semaphore to limit concurrent access to resources, preventing overload and enabling fair resource distribution. globs: "**/*.ts" alwaysApply: true
Concurrency Pattern 2: Rate Limit Concurrent Access with Semaphore
Rule: Use Semaphore to limit concurrent access to resources, preventing overload and enabling fair resource distribution.
Example
This example demonstrates limiting concurrent database connections using a Semaphore, preventing connection pool exhaustion.
import { Effect, Semaphore, Fiber } from "effect";
interface QueryResult {
readonly id: number;
readonly result: string;
readonly duration: number;
}
// Simulate a database query that holds a connection
const executeQuery = (
queryId: number,
connectionId: number,
durationMs: number
): Effect.Effect<QueryResult> =>
Effect.gen(function* () {
const startTime = Date.now();
yield* Effect.log(
`[Query ${queryId}] Using connection ${connectionId}, duration: ${durationMs}ms`
);
// Simulate query execution
yield* Effect.sleep(`${durationMs} millis`);
const duration = Date.now() - startTime;
return {
id: queryId,
result: `Result from query ${queryId}`,
duration,
};
});
// Pool configuration
interface ConnectionPoolConfig {
readonly maxConnections: number;
readonly queryTimeout?: number;
}
// Create a rate-limited query executor
const createRateLimitedQueryExecutor = (
config: ConnectionPoolConfig
): Effect.Effect<
(queryId: number, durationMs: number) => Effect.Effect<QueryResult>
> =>
Effect.gen(function* () {
const semaphore = yield* Semaphore.make(config.maxConnections);
let connectionCounter = 0;
return (queryId: number, durationMs: number) =>
Effect.gen(function* () {
// Acquire a permit (wait if none available)
yield* Semaphore.acquire(semaphore);
const connectionId = ++connectionCounter;
// Use try-finally to ensure permit is released
const result = yield* executeQuery(queryId, connectionId, durationMs).pipe(
Effect.ensuring(
Semaphore.release(semaphore).pipe(
Effect.tap(() =>
Effect.log(`[Query ${queryId}] Released connection ${connectionId}`)
)
)
)
);
return result;
});
});
// Simulate multiple queries arriving
const program = Effect.gen(function* () {
const executor = yield* createRateLimitedQueryExecutor({
maxConnections: 3, // Only 3 concurrent connections
});
// Generate 10 queries with varying durations
const queries = Array.from({ length: 10 }, (_, i) => ({
id: i + 1,
duration: 500 + Math.random() * 1500, // 500-2000ms
}));
console.log(`\n[POOL] Starting with max 3 concurrent connections\n`);
// Execute all queries with concurrency limit
const results = yield* Effect.all(
queries.map((q) =>
executor(q.id, Math.round(q.duration)).pipe(Effect.fork)
)
).pipe(
Effect.andThen((fibers) =>
Effect.all(fibers.map((fiber) => Fiber.join(fiber)))
)
);
console.log(`\n[POOL] All queries completed\n`);
// Summary
const totalDuration = results.reduce((sum, r) => sum + r.duration, 0);
const avgDuration = totalDuration / results.length;
console.log(`[SUMMARY]`);
console.log(` Total queries: ${results.length}`);
console.log(` Avg duration: ${Math.round(avgDuration)}ms`);
console.log(` Total time: ${Math.max(...results.map((r) => r.duration))}ms (parallel)`);
});
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.
- 7d ago First seen · 157 lines · 1,020 tokens per session scan A d112bb19ca99
concurrency-pattern-2-rate-limit-concurrent-access-with-semaphore is a cursor rule published in the GitHub repository PaulJPhilp/EffectPatterns (796 stars, last pushed 2mo ago), licensed MIT. It adds 1,020 tokens to every session, about $0.0051 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.
javascript-typescript-code-style
Rules for JavaScript and TypeScript code style, including modern features, functional patterns, and descriptive naming conventions.
code-style-and-improvements
This rule focuses on code style, refactoring suggestions, and leveraging the latest ES and Node.js features for JavaScript, TypeScript, and Python files.
key-conventions
Key coding conventions for Astro projects including style guide and typescript.