docs: explain Cowork bootstrap for SKILL_ROOT and env vars

This commit is contained in:
Séb
2026-05-26 10:53:57 -04:00
parent a37c19bb87
commit 602092142d

View File

@@ -23,18 +23,20 @@ These must be set in the user's shell before any operation that needs them. Fail
Treat all of these as sensitive in the sense that the token must never be echoed back in chat. The paths and domain are not secrets, but still read them from the environment rather than hard-coding so the skill stays portable across user setups.
### Loading the variables (Cowork sessions)
### Cowork session bootstrap
The Cowork bash sandbox does **not** inherit the user's host `.bashrc`/`.profile` — each bash call starts fresh and only sees env vars injected by the harness. The user keeps a shared env file at `~/.config/cowork/env.sh` on the host (also sourced by their host `.bashrc`, so it's a single source of truth). In Cowork, that path appears under the session's mount as `/sessions/<session-id>/mnt/cowork/env.sh`.
At the start of any bash call that needs these variables, source the file if it exists. Resolve the session mount path dynamically rather than hard-coding a session ID:
The Cowork bash sandbox does **not** inherit the user's host `.bashrc`/`.profile`, and the skill's own discovery directory (`~/.config/Claude/.../skills/websimple-devops`) is a symlink whose target (`~/Projects/AI/claude-websimple-devops`) lives outside the sandbox — bash can't follow it. So at the start of any bash call that runs skill scripts or needs the env vars, resolve both via the session's mount paths:
```bash
# Env vars (shared with the host shell via ~/.config/cowork/env.sh)
COWORK_ENV="$(ls /sessions/*/mnt/cowork/env.sh 2>/dev/null | head -1)"
[ -n "$COWORK_ENV" ] && . "$COWORK_ENV"
# Skill root — canonical home of this skill, mounted into the sandbox
SKILL_ROOT="$(ls -d /sessions/*/mnt/claude-websimple-devops 2>/dev/null | head -1)"
```
If `env.sh` isn't found, fall back to normal behavior: check each variable and, when something's missing, ask the user either to export it or to approve mounting `~/.config/cowork/` (whichever is the actual gap).
If either lookup comes up empty, the corresponding host folder isn't mounted into this Cowork session. Ask the user to approve mounting `~/.config/cowork/` (for env vars) or `~/Projects/AI/claude-websimple-devops` (for the skill itself). Then invoke scripts via `"$SKILL_ROOT/scripts/..."` — never via the symlinked discovery path, which is dangling from inside the sandbox.
## Reference index — read the file that matches the task