arrow-resource
Installation
SKILL.md
Arrow Resource (Kotlin)
Quick start
- Treat every disposable handle as scoped: wrap it in
Resourceand acquire it only insideresourceScope,resource {}, orResource.use. - Prefer
arrow.fx.coroutines.resource.contextimports for context-parameter-friendlyresource,resourceScope,bind,install, andautoCloseable. - Never return a disposable value from
resourceScope { ... },resource { ... }, orresource.use { ... }; that returns a closed handle. - Classes must not allocate owned resources in ordinary constructors. Use a companion builder returning
Resource<Class>or requiringcontext(ResourceScope). - If suspend
Resourcecannot be used, usearrow-autoclose/AutoCloseablewith the same no-leak discipline. - Read
references/resource.mdbefore writing examples, reviews, or new APIs.
Workflow
- Identify every owned disposable dependency and its release action.
- Move acquisition into a
Resourcerecipe orcontext(ResourceScope)builder. - Compose resources into higher-level resources with
.bind()or context-parameter builders. - Keep resource handles private to the scoped object; expose operations, not the raw handle.
- Execute at lifecycle boundaries with
resourceScope/.use, and keep finalizers idempotent.