#Passing env variables

1 messages · Page 1 of 1 (latest)

slim nacelle
#

How do you pass skill env vars (from skills.entries.*.env) to Node.js scripts run via exec? Currently I'm using node -e to read openclaw.json and extract the keys before running my scripts. Is there a cleaner way to make skill env vars available to scripts?

still ravenBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> ✅ Mark Solution

spark steepleBOT
#

Yep — the cleaner path is: don’t read openclaw.json from the script. For a host/gateway exec run, skill env vars are injected into the agent process for the active turn, and exec inherits that environment. So your script should be able to just do:

const key = process.env.MY_SKILL_KEY;

…and run normally:

node ./scripts/my-script.js

A few gotchas:

  • The skill must be eligible/active in that session snapshot. If you changed skill config, start a new session/turn as needed.
  • skills.entries.<skill>.env is scoped to the agent run, not your global shell. So running the script manually in a terminal won’t see it.
  • If you’re using sandboxed exec, the sandbox does not inherit host process.env; configure agents.defaults.sandbox.docker.env / per-agent sandbox env instead.