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/compose-resource-lifecycles-with-layermergegit 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/compose-resource-lifecycles-with-layermerge)<a href="https://agentmods.dev/rules/pauljphilp/effectpatterns/compose-resource-lifecycles-with-layermerge"><img src="https://agentmods.dev/badge/rules/pauljphilp/effectpatterns/compose-resource-lifecycles-with-layermerge.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.00698 | $0.00698 |
| Opus 5 | $0.00349 | $0.00349 |
| Sonnet 5 | $0.00140 | $0.00140 |
| Haiku 4.5 | $0.00070 | $0.00070 |
Grade A, and why
compose-resource-lifecycles-with-layermerge 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 5d 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 — 78 lines — stays where its author put it; the contents beside it link to each section on GitHub.
description: Compose multiple scoped layers using Layer.merge or by providing one layer to another.
globs: "**/*.ts"
alwaysApply: true
Compose Resource Lifecycles with Layer.merge
Rule: Compose multiple scoped layers using Layer.merge or by providing one layer to another.
Example
import { Effect, Layer, Console } from "effect";
// --- Service 1: Database ---
interface DatabaseOps {
query: (sql: string) => Effect.Effect<string, never, never>;
}
class Database extends Effect.Service<DatabaseOps>()("Database", {
sync: () => ({
query: (sql: string): Effect.Effect<string, never, never> =>
Effect.sync(() => `db says: ${sql}`),
}),
}) {}
// --- Service 2: API Client ---
interface ApiClientOps {
fetch: (path: string) => Effect.Effect<string, never, never>;
}
class ApiClient extends Effect.Service<ApiClientOps>()("ApiClient", {
sync: () => ({
fetch: (path: string): Effect.Effect<string, never, never> =>
Effect.sync(() => `api says: ${path}`),
}),
}) {}
// --- Application Layer ---
// We merge the two independent layers into one.
const AppLayer = Layer.merge(Database.Default, ApiClient.Default);
// This program uses both services, unaware of their implementation details.
const program = Effect.gen(function* () {
const db = yield* Database;
const api = yield* ApiClient;
const dbResult = yield* db.query("SELECT *");
const apiResult = yield* api.fetch("/users");
yield* Effect.log(dbResult);
yield* Effect.log(apiResult);
});
// Provide the combined layer to the program.
Effect.runPromise(Effect.provide(program, AppLayer));
/*
Output (note the LIFO release order):
Database pool opened
API client session started
db says: SELECT *
api says: /users
API client session ended
Database pool closed
*/
Explanation:
We define two completely independent services, Database and ApiClient, each with its own resource lifecycle. By combining them with Layer.merge, we create a single AppLayer. When program runs, Effect acquires the resources for both layers. When program finishes, Effect closes the application's scope, releasing the resources in the reverse order they were acquired (ApiClient then Database), ensuring a clean and predictable shutdown.
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.
- 5d ago First seen · 78 lines · 698 tokens per session scan A cda0a149e5f9
compose-resource-lifecycles-with-layermerge is a cursor rule published in the GitHub repository PaulJPhilp/EffectPatterns (796 stars, last pushed 2mo ago), licensed MIT. It adds 698 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-08-30.
Other cursor rules, from other repositories
flutter-core-rules
Applies Flutter best practices and coding guidelines to the core directory, focusing on constants, themes, utilities, and widgets.
astro-project-structure
Enforce the recommended Astro project structure.
django-url-routing
Ensures Django's URL routing system is used in URL configuration files. This promotes consistent and maintainable URL management across Django projects.
no-summaries-rule
This rule instructs the AI not to summarize changes made.
hub-spoke-graph
Hub-and-spoke (MOC) linking for Obsidian vault notes — no peer mesh, leaves up-link only.
langgraph-best-practices
Comprehensive reference for building LangGraph agent workflows including core concepts, graph construction patterns, state management, advanced patterns like Send API and Command, and production-ready code examples.