Golem add npm package effect

From golemcloud/golem · View interactive version

Golem add npm package effect is an AI agent skill from the GitHub repository golemcloud/golem. Adds npm package dependencies to Effect-based Golem projects. Use when the user asks to add a library, package, or dependency to an @golemcloud/effect-golem application.

How to use this skill

Skill file

Adding an NPM Package Dependency to an Effect Golem Application

Effect Golem applications use normal npm dependencies, but application code is bundled into a

single ESM module and runs in a QuickJS-based WebAssembly component rather than Node.js. A runtime

dependency must therefore be compatible with both the Rollup build and the QuickJS/Wasm runtime.

Steps

  1. From the application root containing package.json, install the package:

```shell

npm install <package-name>

```

Root-level dependencies are shared by every Effect component in a multi-component application.

Keep the resulting package.json and package-lock.json changes.

For a build tool or type package that is not imported by component code, use a development

dependency:

```shell

npm install --save-dev <package-name>

```

  1. Import the package from component source with its documented ESM or runtime-compatible entry

point. Use a bare package specifier for npm packages; the emitted .js suffix is required for

local source imports, not package imports.

  1. Preserve the generated versions of effect and @golemcloud/effect-golem. The base Wasm

supplies the embedded Effect runtime; the component builder bundles and tree-shakes the Golem

SDK source. Upgrading independently can create a runtime mismatch.

  1. Build through Golem:

```shell

golem build

```

Do not run Rollup or TypeScript directly and do not edit generated files under golem-temp/.

After a successful build, exercise the code in a deployed component because Node-based tests do

not detect QuickJS-only runtime failures.

Using a Package from an Effect Method

Agent handlers must still return an Effect. Wrap a synchronous package call in Effect.sync so

the package's result is the method's success value:

import { Effect } from "effect";
import { camelCase } from "change-case";

format: ({ value }) => Effect.sync(() => camelCase(value)),

When adding the call to an existing Effect pipeline, return it from Effect.map (or replace the

pipeline's success value with Effect.as). For example, this preserves the state update and returns

the package result:

increment: () =>
  Ref.updateAndGet(state, ({ count }) => ({ count: count + 1 })).pipe(
    Effect.map(() => camelCase("hello world")),
  ),

Keep the method contract aligned with the value returned by the handler; the example requires

success: Schema.String. Calling the package only inside Effect.tap, or using a block-bodied

Effect.map callback without return, does not make its value the method result.

Runtime Compatibility Checklist

generated Rollup pipeline.

platform-specific processes. Those binaries cannot load inside the Wasm component.

does not provide. The presence of @types/node only supplies types; it does not make every Node

API available at runtime.

and type compatibility, while deployment and invocation verify runtime compatibility.

current runtime API and package compatibility information.

Build-only development dependencies run in the local Node toolchain and do not need QuickJS

compatibility unless application source imports them into the component bundle.

Bundling Behavior

The generated build uses Rollup to resolve npm modules, convert CommonJS dependencies, support JSON

imports, inline dynamic imports, and emit one ESM module. Ordinary third-party dependencies are

bundled into that module, including @golemcloud/effect-golem and its database adapters. The

template externalizes effect, effect/http, agent-guest, node:sqlite, and host modules with

golem:, wasi:, or wasm-rquickjs: prefixes. The SDK component builder resolves other Effect

subpaths against the embedded runtime while bundling and tree-shaking the SDK source. Do not

externalize all SDK imports or add a second Effect runtime to the component.

If the build fails, check the package's exports and prefer its ESM or runtime-compatible entry

point. If the component fails only when invoked, look for a native addon, an unresolved Node

built-in, an unsupported Web API, or dynamic module loading that Rollup could not inline. Replace

the package with a pure-JavaScript, Wasm-compatible alternative when necessary.

Already Available Packages

Generated Effect applications already include these dependencies; do not add them again:

For database access, do not install native Node drivers such as pg, mysql2, or

better-sqlite3. Use the host-backed adapters from @golemcloud/effect-golem/sqlite,

@golemcloud/effect-golem/postgres, @golemcloud/effect-golem/mysql, or

@golemcloud/effect-golem/ignite2 as appropriate.

AI and LLM npm clients are subject to the same rules: verify that the selected package and all of

its transitive dependencies can be bundled and use only APIs available in the QuickJS/Wasm

runtime.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.