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/mocking-dependencies-in-tests)<a href="https://agentmods.dev/rules/pauljphilp/effectpatterns/mocking-dependencies-in-tests"><img src="https://agentmods.dev/badge/rules/pauljphilp/effectpatterns/mocking-dependencies-in-tests.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.00707 | $0.00707 |
| Opus 5 | $0.00353 | $0.00353 |
| Sonnet 5 | $0.00141 | $0.00141 |
| Haiku 4.5 | $0.00071 | $0.00071 |
Grade A, and why
mocking-dependencies-in-tests 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 — 79 lines — stays where its author put it; the contents beside it link to each section on GitHub.
description: Provide mock service implementations via a test-specific Layer to isolate the unit under test. globs: "**/*.ts" alwaysApply: true
Mocking Dependencies in Tests
Rule: Provide mock service implementations via a test-specific Layer to isolate the unit under test.
Example
We want to test a Notifier service that uses an EmailClient to send emails. In our test, we provide a mock EmailClient that doesn't actually send emails but just returns a success value.
import { Effect, Layer } from "effect";
// --- The Services ---
interface EmailClientService {
send: (address: string, body: string) => Effect.Effect<void>;
}
class EmailClient extends Effect.Service<EmailClientService>()("EmailClient", {
sync: () => ({
send: (address: string, body: string) =>
Effect.sync(() => Effect.log(`Sending email to ${address}: ${body}`)),
}),
}) {}
interface NotifierService {
notifyUser: (userId: number, message: string) => Effect.Effect<void>;
}
class Notifier extends Effect.Service<NotifierService>()("Notifier", {
effect: Effect.gen(function* () {
const emailClient = yield* EmailClient;
return {
notifyUser: (userId: number, message: string) =>
emailClient.send(`user-${userId}@example.com`, message),
};
}),
dependencies: [EmailClient.Default],
}) {}
// Create a program that uses the Notifier service
const program = Effect.gen(function* () {
yield* Effect.log("Using default EmailClient implementation...");
const notifier = yield* Notifier;
yield* notifier.notifyUser(123, "Your invoice is ready.");
// Create mock EmailClient that logs differently
yield* Effect.log("\nUsing mock EmailClient implementation...");
const mockEmailClient = Layer.succeed(EmailClient, {
send: (address: string, body: string) =>
// Directly return the Effect.log without nesting it in Effect.sync
Effect.log(`MOCK: Would send to ${address} with body: ${body}`),
} as EmailClientService);
// Run the same notification with mock client
yield* Effect.gen(function* () {
const notifier = yield* Notifier;
yield* notifier.notifyUser(123, "Your invoice is ready.");
}).pipe(Effect.provide(mockEmailClient));
});
// Run the program
Effect.runPromise(Effect.provide(program, Notifier.Default));
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 · 79 lines · 707 tokens per session scan A 24e7080d569a
mocking-dependencies-in-tests is a cursor rule published in the GitHub repository PaulJPhilp/EffectPatterns (796 stars, last pushed 2mo ago), licensed MIT. It adds 707 tokens to every session, about $0.0035 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
use-ast-factories
Use factory functions for creating AST nodes instead of manual object creation.
test-mocking-patterns
Test-only type assertions and mocking patterns (avoid brittle mocks).
tsdown-dist-layout-in-tests
Use tsdown dist root paths in TS test mappings.
jest-unit-testing-cursorrules-prompt-file
Cursor rules for Jest development with unit testing.
jest
Definitive guidelines for writing robust, maintainable, and performant Jest tests in JavaScript and TypeScript projects.
rule-01
This is test rule number in the large package scalability test.