#Passing env variables
1 messages · Page 1 of 1 (latest)
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>.envis 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; configureagents.defaults.sandbox.docker.env/ per-agent sandbox env instead.