The bridged Claude Code told its model "Primary working directory:
<tmp>/magpie-claude-work-501", against the folder the client's own prompt
names. Under a real Claude Code client the model wrote pelican.html into
magpie's temp folder, through the client's tools, which run in the
client's folder.
startRun now runs Claude Code in the folder the caller names
(clientWorkDir): the last one in the system prompt or a non-assistant
message, as Claude Code ("Primary working directory:"), Codex (<cwd>),
OpenCode ("Working directory:") and pi ("Current working directory:")
write it, when it is an absolute path to a folder here. Otherwise (a caller
elsewhere, a WSL Claude Code, no folder named) the shared folder as before.
The caller's project's sessions are never swept; a run's session is still
removed by its id. CLAUDE_CODE_DISABLE_GIT_INSTRUCTIONS=1 keeps the
repository's status out of the prompt (setting sources and auto memory
were off already). The text sent upstream is unchanged apart from the
folder Claude Code reports itself.
Run:
- TestClaudeRunsInTheCallersWorkDir (Claude Code, Codex, OpenCode, pi,
named twice) and TestClaudeCallersWorkDirElsewhereIsNotUsed (missing,
relative, Windows path, none): red on the old code (the runs used the
shared folder). Broken by hand: sweeping the caller's folder goes red
("were swept"); dropping the env var goes red ("repository's status").
- Real run: sandbox HOME, dev build of this tree serving 127.0.0.1:3741 on
the owner's Claude Max sign-in (keychain linked in, login copies deleted
after), a client Claude Code 2.1.310 with its own CLAUDE_CONFIG_DIR,
ANTHROPIC_BASE_URL at the sandbox, run in $SB/wm and asked to write
pelican.html: it landed in $SB/wm; nothing new in magpie-claude-work-501
(its only pelican.html is the capture's, from before).
- go test ./internal/gateway at the staged tree (checkout-index), gofmt,
go vet; the full suite run is recorded in the next commit, at the pushed
head.
Not tried: a Windows client (a Windows path falls back, by the test), a
Claude Code in WSL (falls back by code).