resources
Skill8 starsChanged 9 months agoMITView on GitHub
This skill should be used when the user asks about "Effect resources", "acquireRelease", "Scope", "finalizers", "resource cleanup", "Effect.addFinalizer", "Effect.ensuring", "scoped effects", "resource lifecycle", "bracket pattern", "safe resource handling", "database connections", "file handles", or needs to understand how Effect guarantees resource cleanup.
4 other projects use a version of this.
Adopted by
Most recently taken up by
- bmcszk/agent-skillstheir own version, first seen Sep 23, 2026
- nomograph-ai/runetheir own version, first seen Apr 18, 2026
- kirilxd/claude-tutortheir own version, first seen Apr 12, 2026
- Harmeet10000/skillstheir own version, first seen Mar 15, 2026
Other versions4 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 4
- kirilxd/claude-tutor★ 133same name
- Harmeet10000/skills★ 7same name
- bmcszk/agent-skills★ 1same name
- nomograph-ai/rune★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository23 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- references/llms-full.txtllms.txt
- api-doc-lookupSkill
- batching-cachingSkill
- code-styleSkill
- concurrencySkill
- configurationSkill
- data-typesSkill
- effect-aiSkill
- effect-coreSkill
- error-managementSkill
- ObservabilitySkill
- pattern-matchingSkill
- platformSkill
- requirementsSkill
- runtimeSkill
- schedulingSkill
- schemaSkill
- sinksSkill
- stateSkill
- streamsSkill
- testingSkill
- traitsSkill
The file
We split this skill into the rules it gives an agent
6 rules. 0 are common, 5 are distinctive, and 1 is very specific to this project.
0
Common
Most of the 3 edited versions we read keep these.
5
Distinctive
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 83
Add cleanup logic to the current scope:
- Distinctive: line 97
Run cleanup after effect completes (success or failure):
- Distinctive: line 105
Run different cleanup based on exit status:
- Very specific: line 181
Use Layer.scoped for service-level resources:
- Distinctive: line 225
Use Effect.scoped at appropriate boundaries: - Not too wide, not too narrow
- Distinctive: line 233
Search for these sections:
“Common” is measured: kept by at least 6 in 10 of the 3 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Resource Management in Effect
Overview
Effect provides structured resource management that guarantees cleanup even when errors occur or the effect is interrupted. This is essential for:
- Database connections
- File handles
- Network sockets
- Locks and semaphores
- Any resource requiring cleanup
Core Concept: Scope
A Scope is a context that tracks resources and ensures their cleanup:
Effect<A, E, R | Scope>;
// ^^^^^ Indicates resource needs cleanupBasic Resource Acquisition
Effect.acquireRelease
The fundamental pattern for safe resource management:
import { Effect } from "effect";
const managedFile = Effect.acquireRelease(
Effect.sync(() => fs.openSync("file.txt", "r")),
(fd) => Effect.sync(() => fs.closeSync(fd)),
);Using the Resource
const program = Effect.gen(function* () {
const fd = yield* managedFile;
const content = yield* Effect.sync(() => fs.readFileSync(fd, "utf-8"));
return content;
});
// Run with automatic scope management
const result = yield * Effect.scoped(program);Effect.scoped
Converts a scoped effect into a regular effect by managing the scope:
const runnable = Effect.scoped(program);The scope closes when the scoped block completes, triggering all finalizers.
acquireUseRelease Pattern
For simpler cases, combine acquire/use/release in one call:
const readFile = (path: string) =>
Effect.acquireUseRelease(
Effect.sync(() => fs.openSync(path, "r")),
(fd) => Effect.sync(() => fs.readFileSync(fd, "utf-8")),
(fd) => Effect.sync(() => fs.closeSync(fd)),
);Finalizers
Effect.addFinalizer
Add cleanup logic to the current scope:
const program = Effect.gen(function* () {
yield* Effect.addFinalizer(() => Effect.log("Cleanup running!"));
// ... do work ...
return result;
});Effect.ensuring
Run cleanup after effect completes (success or failure):
const withCleanup = someEffect.pipe(Effect.ensuring(Effect.log("Always runs after effect")));Effect.onExit
Run different cleanup based on exit status:
const withExitHandler = someEffect.pipe(
Effect.onExit((exit) => (Exit.isSuccess(exit) ? Effect.log("Succeeded!") : Effect.log("Failed or interrupted"))),
);Multiple Resources
Sequential Acquisition
const program = Effect.gen(function* () {
const db = yield* acquireDbConnection;
const cache = yield* acquireRedisConnection;
});
const result = yield * Effect.scoped(program);Parallel Acquisition
const program = Effect.gen(function* () {
const [db, cache] = yield* Effect.all([acquireDbConnection, acquireRedisConnection]);
});Resource Patterns
Database Connection Pool
const DbPool = Effect.acquireRelease(
Effect.promise(() =>
createPool({
host: "localhost",
database: "mydb",
max: 10,
}),
),
(pool) => Effect.promise(() => pool.end()),
);
const query = (sql: string) =>
Effect.gen(function* () {
const pool = yield* DbPool;
return yield* Effect.tryPromise(() => pool.query(sql));
});File Handle
const withFile = <A>(path: string, use: (handle: FileHandle) => Effect.Effect<A>) =>
Effect.acquireUseRelease(
Effect.promise(() => fs.promises.open(path)),
use,
(handle) => Effect.promise(() => handle.close()),
);Lock/Mutex
const withLock = <A>(lock: Lock, effect: Effect.Effect<A>) =>
Effect.acquireUseRelease(
lock.acquire,
() => effect,
() => lock.release,
);Layered Resources
Use Layer.scoped for service-level resources:
const DatabaseLive = Layer.scoped(
Database,
Effect.gen(function* () {
const pool = yield* Effect.acquireRelease(createPool(), (pool) => Effect.promise(() => pool.end()));
return {
query: (sql) => Effect.tryPromise(() => pool.query(sql)),
};
}),
);Error Handling in Cleanup
Finalizers should not fail, but if they do:
const safeRelease = (resource: Resource) =>
Effect.sync(() => resource.close()).pipe(Effect.catchAll((error) => Effect.logError("Cleanup failed", error)));
const managed = Effect.acquireRelease(acquire, safeRelease);Interruption Safety
Resources are cleaned up even on interruption:
const program = Effect.gen(function* () {
const resource = yield* acquireResource;
yield* Effect.sleep("1 hour");
});
const result = yield * program.pipe(Effect.scoped, Effect.timeout("1 second"));Best Practices
- Use acquireRelease for paired operations - Guarantees cleanup
- Keep finalizers simple and infallible - Log errors instead of throwing
- Use Effect.scoped at appropriate boundaries - Not too wide, not too narrow
- Clean up in reverse acquisition order - Effect handles this automatically
- Use Layer.scoped for service-level resources - Lifecycle tied to layer
Additional Resources
For comprehensive resource management documentation, consult ${CLAUDE_PLUGIN_ROOT}/references/llms-full.txt.
Search for these sections:
- "Introduction" (Resource Management) for core concepts
- "Scope" for detailed scope mechanics
- "Managing Layers" for Layer.scoped patterns
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

