[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M71H8577SX8Z9BJDQW21SDYY":3,"skill-same:01M71H8577SX8Z9BJDQW21SDYY":54},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":29,"linkOnly":30,"markdownContent":31,"markdownBody":32,"frontMatter":33,"refName":34,"commitSha":35,"skillDirectory":36,"forksCount":13,"repositoryHtmlUrl":37,"repositoryHomepageUrl":6,"ownerHtmlUrl":38,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":39,"install":40,"resources":53},"01M71H8577SX8Z9BJDQW21SDYY","04-resources",null,"Effect-TS 4 resource management — Scope, acquireRelease, Layer.scoped, and safe resource lifecycle","lambda-solver\u002Flambdabench-pro","lambda-solver","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F279071046?v=4","01M71H55W2WK3PM6RRAY9JZWAJ","01M71H55WRT9XAFDAVACTCC2XP",0,"MIT","https:\u002F\u002Fgithub.com\u002Flambda-solver\u002Flambdabench-pro\u002Fblob\u002Fmain\u002Freference\u002Fghui\u002F.opencode\u002Fskills\u002Feffect-ts\u002Fcore\u002F04-resources\u002FSKILL.md",[],[18,19,20,21,22,23,24,25,26,27,28],"resources","04 resources","effect","opencode","resource management","scope","lifecycle","safe","scoped","layer","management","2026-11-10 10:12:30",false,"---\nname: 04-resources\ndescription: Effect-TS 4 resource management — Scope, acquireRelease, Layer.scoped, and safe resource lifecycle\nlicense: MIT\ncompatibility: opencode\n---\n\n# Resource Management\n\n## acquireRelease — safe open\u002Fclose pair\n\nThe release is guaranteed to run even on interruption or failure.\n\n```typescript\nimport { Effect } from \"effect\";\n\nconst connection =\n  yield *\n  Effect.acquireRelease(\n    Effect.sync(() => db.connect()), \u002F\u002F acquire\n    (conn) => Effect.sync(() => conn.close()), \u002F\u002F release — always runs\n  );\n```\n\n## Layer.scoped — resource tied to layer lifetime\n\nUse when the resource should live as long as the layer's scope.\n\n```typescript\nimport { Context, Effect, Layer } from \"effect\";\n\nexport class DbPool extends Context.Service\u003C\n  DbPool,\n  {\n    query(sql: string): Effect.Effect\u003CArray\u003Cunknown>>;\n  }\n>()(\"myapp\u002FDbPool\") {\n  static readonly layer = Layer.scoped(\n    DbPool,\n    Effect.gen(function* () {\n      const pool = yield* Effect.acquireRelease(\n        Effect.promise(() => createPool(config)),\n        (p) => Effect.promise(() => p.end()),\n      );\n      return DbPool.of({\n        query: Effect.fn(\"DbPool.query\")(function* (sql) {\n          return yield* Effect.promise(() => pool.query(sql));\n        }),\n      });\n    }),\n  );\n}\n```\n\n## Effect.addFinalizer — finalizer in current scope\n\n```typescript\nyield * Effect.addFinalizer(() => Effect.sync(() => console.log(\"scope closing\")));\n```\n\n## Scope — explicit lifetime management\n\n```typescript\nimport { Scope } from \"effect\";\n\nconst program = Effect.gen(function* () {\n  const scope = yield* Scope.make();\n\n  const conn = yield* Effect.acquireRelease(\n    Effect.sync(() => db.connect()),\n    (c) => Effect.sync(() => c.close()),\n  ).pipe(Effect.provideService(Scope.Scope, scope));\n\n  \u002F\u002F ... use conn ...\n\n  \u002F\u002F Close explicitly when done\n  yield* Scope.close(scope, Exit.void);\n});\n```\n\n## Effect.using — acquire + use + release in one expression\n\n```typescript\nconst result =\n  yield *\n  Effect.using(\n    Effect.acquireRelease(\n      Effect.sync(() => openFile(path)),\n      (f) => Effect.sync(() => f.close()),\n    ),\n    (file) => readLines(file),\n  );\n```\n\n## forkScoped — fiber tied to scope\n\nThe fiber is interrupted when the enclosing scope closes.\n\n```typescript\nyield *\n  Effect.forkScoped(\n    Effect.gen(function* () {\n      while (true) {\n        yield* Effect.sleep(\"5 seconds\");\n        yield* Effect.log(\"heartbeat\");\n      }\n    }),\n  );\n```\n\n## Key rules\n\n- Never manage resources with `try\u002Ffinally` inside `Effect.gen` — use `acquireRelease`.\n- `Layer.scoped` > `Layer.effect` when the service wraps a resource.\n- `Effect.forkScoped` > `Effect.fork` for long-running background tasks.\n","# Resource Management\n\n## acquireRelease — safe open\u002Fclose pair\n\nThe release is guaranteed to run even on interruption or failure.\n\n```typescript\nimport { Effect } from \"effect\";\n\nconst connection =\n  yield *\n  Effect.acquireRelease(\n    Effect.sync(() => db.connect()), \u002F\u002F acquire\n    (conn) => Effect.sync(() => conn.close()), \u002F\u002F release — always runs\n  );\n```\n\n## Layer.scoped — resource tied to layer lifetime\n\nUse when the resource should live as long as the layer's scope.\n\n```typescript\nimport { Context, Effect, Layer } from \"effect\";\n\nexport class DbPool extends Context.Service\u003C\n  DbPool,\n  {\n    query(sql: string): Effect.Effect\u003CArray\u003Cunknown>>;\n  }\n>()(\"myapp\u002FDbPool\") {\n  static readonly layer = Layer.scoped(\n    DbPool,\n    Effect.gen(function* () {\n      const pool = yield* Effect.acquireRelease(\n        Effect.promise(() => createPool(config)),\n        (p) => Effect.promise(() => p.end()),\n      );\n      return DbPool.of({\n        query: Effect.fn(\"DbPool.query\")(function* (sql) {\n          return yield* Effect.promise(() => pool.query(sql));\n        }),\n      });\n    }),\n  );\n}\n```\n\n## Effect.addFinalizer — finalizer in current scope\n\n```typescript\nyield * Effect.addFinalizer(() => Effect.sync(() => console.log(\"scope closing\")));\n```\n\n## Scope — explicit lifetime management\n\n```typescript\nimport { Scope } from \"effect\";\n\nconst program = Effect.gen(function* () {\n  const scope = yield* Scope.make();\n\n  const conn = yield* Effect.acquireRelease(\n    Effect.sync(() => db.connect()),\n    (c) => Effect.sync(() => c.close()),\n  ).pipe(Effect.provideService(Scope.Scope, scope));\n\n  \u002F\u002F ... use conn ...\n\n  \u002F\u002F Close explicitly when done\n  yield* Scope.close(scope, Exit.void);\n});\n```\n\n## Effect.using — acquire + use + release in one expression\n\n```typescript\nconst result =\n  yield *\n  Effect.using(\n    Effect.acquireRelease(\n      Effect.sync(() => openFile(path)),\n      (f) => Effect.sync(() => f.close()),\n    ),\n    (file) => readLines(file),\n  );\n```\n\n## forkScoped — fiber tied to scope\n\nThe fiber is interrupted when the enclosing scope closes.\n\n```typescript\nyield *\n  Effect.forkScoped(\n    Effect.gen(function* () {\n      while (true) {\n        yield* Effect.sleep(\"5 seconds\");\n        yield* Effect.log(\"heartbeat\");\n      }\n    }),\n  );\n```\n\n## Key rules\n\n- Never manage resources with `try\u002Ffinally` inside `Effect.gen` — use `acquireRelease`.\n- `Layer.scoped` > `Layer.effect` when the service wraps a resource.\n- `Effect.forkScoped` > `Effect.fork` for long-running background tasks.\n",{"name":5,"license":14,"description":7,"compatibility":21},"main","816c073aaf171300af3605b06f7ec5aa7370ef0b","reference\u002Fghui\u002F.opencode\u002Fskills\u002Feffect-ts\u002Fcore\u002F04-resources","https:\u002F\u002Fgithub.com\u002Flambda-solver\u002Flambdabench-pro","https:\u002F\u002Fgithub.com\u002Flambda-solver","2026-05-31 17:08:46",{"source":8,"skillName":5,"commands":41,"prompt":51,"zipAvailable":52},[42,45,48],{"tool":43,"command":44},"npx","npx skills add lambda-solver\u002Flambdabench-pro --skill 04-resources",{"tool":46,"command":47},"bunx","bunx skills add lambda-solver\u002Flambdabench-pro --skill 04-resources",{"tool":49,"command":50},"pnpm","pnpm dlx skills add lambda-solver\u002Flambdabench-pro --skill 04-resources","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Flambda-solver\u002Flambdabench-pro\u002Fblob\u002Fmain\u002Freference\u002Fghui\u002F.opencode\u002Fskills\u002Feffect-ts\u002Fcore\u002F04-resources\u002FSKILL.md",true,[],[55,81,100,117,137,154],{"skillNo":56,"name":57,"nameZh":6,"description":58,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":59,"categories":60,"keywords":61,"publishedAt":29},"01M71H9FNA5D6Y4ANXD18Z1Z3X","tmux-workflow","Development workflow with tmux — run dev servers, Storybook, and background processes in persistent sessions with live logs, while keeping OpenCode free for chat","https:\u002F\u002Fgithub.com\u002Flambda-solver\u002Flambdabench-pro\u002Fblob\u002Fmain\u002Freference\u002Fghui\u002F.opencode\u002Fskills\u002Ftmux\u002FSKILL.md",[],[62,63,64,65,66,67,68,69,70,71,72,21,73,74,75,76,77,78,79,80],"tmux","workflow","tmux workflow","chat","dev servers","background","processes","storybook","live","servers","run","with","logs","development workflow","free","dev","sessions","for","development",{"skillNo":82,"name":83,"nameZh":6,"description":84,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":85,"categories":86,"keywords":87,"publishedAt":29},"01M71H9DQJDAJVZX37NDN99D3P","04-anti-patterns","React anti-patterns to avoid — manual JSX repetition, useEffect misuse, reference instability, prop drilling, conditional hooks, and common performance traps","https:\u002F\u002Fgithub.com\u002Flambda-solver\u002Flambdabench-pro\u002Fblob\u002Fmain\u002Freference\u002Fghui\u002F.opencode\u002Fskills\u002Freact\u002Fpatterns\u002F04-anti-patterns\u002FSKILL.md",[],[88,89,90,91,92,93,94,95,96,97,98,21,99],"patterns","anti patterns","04 anti patterns","common","jsx","reference","conditional","hooks","manual","performance","anti-patterns","react",{"skillNo":101,"name":102,"nameZh":6,"description":103,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":104,"categories":105,"keywords":106,"publishedAt":29},"01M71H9BXF511W2R3B73S5P9ZN","03-state-management","React state management patterns — lifting state, colocation, URL state, server state with TanStack Query, local state with useState\u002FuseReducer","https:\u002F\u002Fgithub.com\u002Flambda-solver\u002Flambdabench-pro\u002Fblob\u002Fmain\u002Freference\u002Fghui\u002F.opencode\u002Fskills\u002Freact\u002Fpatterns\u002F03-state-management\u002FSKILL.md",[],[28,107,108,109,99,110,88,111,112,113,114,21,115,73,116],"state management","state","03 state management","query","URL","tanstack","react state management","local","server","tanstack query",{"skillNo":118,"name":119,"nameZh":6,"description":120,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":121,"categories":122,"keywords":123,"publishedAt":29},"01M71H9AAGVWMYQ4NG82QPYCTE","02-component-composition","React component composition patterns — render props, compound components, list rendering with map, slot patterns, and layout primitives","https:\u002F\u002Fgithub.com\u002Flambda-solver\u002Flambdabench-pro\u002Fblob\u002Fmain\u002Freference\u002Fghui\u002F.opencode\u002Fskills\u002Freact\u002Fpatterns\u002F02-component-composition\u002FSKILL.md",[],[124,125,126,21,73,127,128,99,129,88,130,131,132,133,134,135,136],"02 component composition","component","Composition","compound","components","primitives","composition patterns","list","map","rendering","render","react component","layout",{"skillNo":138,"name":139,"nameZh":6,"description":140,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":141,"categories":142,"keywords":143,"publishedAt":29},"01M71H98RDXRQZDR496SRD906M","01-fp-style","React functional programming style — pure components, hooks conventions, Effect Atom integration, and Tailwind patterns","https:\u002F\u002Fgithub.com\u002Flambda-solver\u002Flambdabench-pro\u002Fblob\u002Fmain\u002Freference\u002Fghui\u002F.opencode\u002Fskills\u002Freact\u002Fpatterns\u002F01-fp-style\u002FSKILL.md",[],[144,145,146,88,147,148,21,149,99,150,128,95,151,152,153,20],"01 fp style","style","atom","conventions","integration","functional","programming","Tailwind","tailwind patterns","functional programming",{"skillNo":155,"name":156,"nameZh":6,"description":157,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":158,"categories":159,"keywords":160,"publishedAt":29},"01M71H95PYGAWBS5C8KN0C4WGT","react-animation","React animation with react\u002Fmotion (Framer Motion) — declarative animations, gestures, layout animations, and performance best practices","https:\u002F\u002Fgithub.com\u002Flambda-solver\u002Flambdabench-pro\u002Fblob\u002Fmain\u002Freference\u002Fghui\u002F.opencode\u002Fskills\u002Freact\u002Fanimation\u002FSKILL.md",[],[99,161,162,97,163,21,136,164,165,73,166,167,168,169],"react animation","Animation","framer motion","motion","best practices","framer","gestures","animations","declarative"]