Cats Effect Resource (Scala)
SkillAI & modelsHelps agents write and review Scala Cats Effect Resource code. Use for preventing resource leaks and use-after-release bugs, modeling disposable values with Resource, designing Resource-returning factories and constructor-injected services, wrapping Java AutoCloseable values, composing resources, and handling cancellation-safe release.
Available today. Use it from your connected AI after setup.
No other account needed.
Add ahel to your AI once: Claude, ChatGPT, Cursor, Claude Code or Codex. Then ask it to use this.
Then ask your AI: use the Cats Effect Resource (Scala) skill
What this skill tells your AI
The instructions your AI receives, as published by alexandru/skills in skills/cats-effect-resource/SKILL.md and read by ahel’s review.
Quick start
- Model every owned disposable value with
Resource.make,Resource.makeCase, orResource.fromAutoCloseable. - Never return an acquired handle from
.use; it is released when.usecompletes. Return only values computed inside the scope. - Classes must not allocate owned resources in constructors, fields, or top-level vals. Use companion/factory methods returning
Resource[F, Service], then pass acquired private dependencies into constructors. - Wrap Java
AutoCloseablevalues withResource.fromAutoCloseable(Sync[F].blocking(...))orIO.blocking(...). - Compose resources with
flatMap,mapN,parMapN, or helper constructors; exposeResource[F, A]from lifecycle-owning APIs. - Read
references/resource.mdfor patterns, best practices, and type-checked samples.
Workflow
- Identify every value that needs disposal or lifecycle shutdown.
- Move acquisition and release into a
Resource[F, A]; suspend side effects inF(Sync[F].delay/blocking,IO.blocking, etc.). - Build classes from already-acquired constructor parameters; put construction in
resource/createfactories that returnResource. - Compose lower-level resources into higher-level resources before
.use. - Run with
.useat the lifecycle boundary (IOApp, server startup, test fixture), and keep raw handles inside the use scope. - Use
allocatedonly for interop that truly needs separate acquire/release, and guarantee the finalizer is called exactly once.
Usage guidance
- Prefer
Resourceovertry/finallyorbracketwhen composition and cancelation safety matter. - Use
IO.blocking(orSync[F].blocking) for acquisition and release when calling blocking JVM APIs. - Prefer
IO.interruptible/Sync[F].interruptiblefor blocking use-phase operations inside.use. - Use
Resource.evalonly for effects that do not own a finalizer; it is not a substitute for resource acquisition. useacquires a fresh resource each time. If the same handle must be shared for multiple operations, do those operations inside one.use.- For background fibers, use
Resource,.background, orSupervisorto ensure cleanup on cancelation. - When adding or changing Scala examples, update and compile the bundled
scripts/verify-examples.scalascript.
References
- Load
references/resource.mdfor API details, patterns, and examples; the representative check isscripts/verify-examples.scala. - For Kotlin/Arrow parallels, see the
arrow-resourceskill. - Install this skill with
npx skills add https://github.com/alexandru/skills --skill cats-effect-resource.
Signals
- GitHub stars
- 53
- Forks
- 3
- Last commit
- Sep 2026
Advanced
- Item type
- skill
- Key
cats-effect-resource- Source
- github.com/alexandru/skills