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/manage-hierarchical-resources)<a href="https://agentmods.dev/rules/pauljphilp/effectpatterns/manage-hierarchical-resources"><img src="https://agentmods.dev/badge/rules/pauljphilp/effectpatterns/manage-hierarchical-resources/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/rules/pauljphilp/effectpatterns/manage-hierarchical-resources"><img src="https://agentmods.dev/badge/rules/pauljphilp/effectpatterns/manage-hierarchical-resources.svg" alt="Reviewed on agentmods" width="80" 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.00968 | $0.00968 |
| Opus 5.5 | $0.00387 | $0.00387 |
| Sonnet 5.5 | $0.00194 | $0.00194 |
| Haiku 4.5 | $0.00097 | $0.00097 |
Grade A, and why
manage-hierarchical-resources 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 1mo 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 — 155 lines — stays where its author put it; the contents beside it link to each section on GitHub.
description: Use nested Scopes to manage resources with parent-child dependencies. globs: "**/*.ts" alwaysApply: true
Manage Hierarchical Resources
Rule: Use nested Scopes to manage resources with parent-child dependencies.
Example
import { Effect, Scope, Exit } from "effect"
// ============================================
// 1. Define hierarchical resources
// ============================================
interface Database {
readonly name: string
readonly createConnection: () => Effect.Effect<Connection, never, Scope.Scope>
}
interface Connection {
readonly id: string
readonly database: string
readonly beginTransaction: () => Effect.Effect<Transaction, never, Scope.Scope>
}
interface Transaction {
readonly id: string
readonly connectionId: string
readonly execute: (sql: string) => Effect.Effect<void>
}
// ============================================
// 2. Create resources with proper lifecycle
// ============================================
const makeDatabase = (name: string): Effect.Effect<Database, never, Scope.Scope> =>
Effect.acquireRelease(
Effect.gen(function* () {
yield* Effect.log(`Opening database: ${name}`)
const db: Database = {
name,
createConnection: () => makeConnection(name),
}
return db
}),
(db) => Effect.log(`Closing database: ${db.name}`)
)
const makeConnection = (dbName: string): Effect.Effect<Connection, never, Scope.Scope> =>
Effect.acquireRelease(
Effect.gen(function* () {
const id = `conn-${crypto.randomUUID().slice(0, 8)}`
yield* Effect.log(` Opening connection: ${id} to ${dbName}`)
const conn: Connection = {
id,
database: dbName,
beginTransaction: () => makeTransaction(id),
}
return conn
}),
(conn) => Effect.log(` Closing connection: ${conn.id}`)
)
const makeTransaction = (connId: string): Effect.Effect<Transaction, never, Scope.Scope> =>
Effect.acquireRelease(
Effect.gen(function* () {
const id = `tx-${crypto.randomUUID().slice(0, 8)}`
yield* Effect.log(` Beginning transaction: ${id}`)
const tx: Transaction = {
id,
connectionId: connId,
execute: (sql) => Effect.log(` [${id}] ${sql}`),
}
return tx
}),
(tx) => Effect.log(` Committing transaction: ${tx.id}`)
)
// ============================================
// 3. Use hierarchical resources
// ============================================
const program = Effect.scoped(
Effect.gen(function* () {
yield* Effect.log("=== Starting hierarchical resource demo ===\n")
// Level 1: Database
const db = yield* makeDatabase("myapp")
// Level 2: Connection (child of database)
const conn = yield* db.createConnection()
// Level 3: Transaction (child of connection)
const tx = yield* conn.beginTransaction()
// Use the transaction
yield* tx.execute("INSERT INTO users (name) VALUES ('Alice')")
yield* tx.execute("INSERT INTO users (name) VALUES ('Bob')")
yield* Effect.log("\n=== Work complete, releasing resources ===\n")
// Resources released in reverse order:
// 1. Transaction committed
// 2. Connection closed
// 3. Database closed
})
)
Effect.runPromise(program)
// ============================================
// 4. Multiple children at same level
// ============================================
const multipleConnections = Effect.scoped(
Effect.gen(function* () {
const db = yield* makeDatabase("myapp")
// Create multiple connections
const conn1 = yield* db.createConnection()
const conn2 = yield* db.createConnection()
// Each connection can have transactions
const tx1 = yield* conn1.beginTransaction()
const tx2 = yield* conn2.beginTransaction()
// Use both transactions
yield* Effect.all([
tx1.execute("UPDATE table1 SET x = 1"),
tx2.execute("UPDATE table2 SET y = 2"),
])
// All released in proper order
})
)
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.
- 1mo ago First seen · 155 lines · 968 tokens per session scan A 44b25e2658c5
manage-hierarchical-resources is a cursor rule published in the GitHub repository PaulJPhilp/EffectPatterns (807 stars, last pushed 4mo ago), licensed MIT. It adds 968 tokens to every session, about $0.0039 per session on Opus 5.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
no-bare-casts
No bare as casts in production TypeScript. Use blindCast (value) from @internal/utils/casts as the auditable escape hatch, castAs (value) for declarative-only assertions, or rewrite to eliminate the cast. as const is exempt. Test files are exempt.
sql-types-imports
Canonical import paths for SQL types.
use-ast-factories
Use factory functions for creating AST nodes instead of manual object creation.
type-extraction-from-contract
Extract TypeScript types from contract.d.ts and helpers.
required-key-undefined-fields
Internal input types use required keys typed | undefined, not optional keys.
type-predicates
Replace blind casts with type predicates (type guards).