Repository navigation
fix(dev): the environment's agent ignores the developer's PATCHY_* variables and parent CLAUDE.md files - #701
Merged
Conversation
Owner
Author
|
Dismissing Sol's round 2 low finding (a literal backslash in a POSIX folder name above the workspace can't be excluded): by Sol's own analysis Claude Code turns |
…riables and parent CLAUDE.md files The `agent` launcher that `pnpm dev up` writes passed the developer's shell straight through. An exported `PATCHY_API_URL` and `PATCHY_API_TOKEN` sent the agent's publishes to that instance, as that key, instead of to the environment as the scenario's publisher. And Claude Code loaded instruction files from every folder above the workspace, the developer's own `~/.claude/CLAUDE.md` among them. The launcher now unsets both variables, as `up`'s own child commands already do, and passes `claudeMdExcludes` through `--settings` for every folder above the workspace: its `*.md`, `.claude/*.md` and `.claude/rules/**`. The workspace's own files and Patchy skill still load. Closes #619 Closes #620 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…r names still exclude Review fixes. `pnpm dev up` on a finished environment returned before writing the `agent` launcher, so an environment made before this change kept the old one; it now rewrites it every time. Claude Code's `claudeMdExcludes` patterns take no escapes, and a folder named with `(` or `[` matched nothing, so glob characters in a folder's name become `?`. The dev-loop skill now says what the environment's agent ignores. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude Code walks up from its resolved working directory, so an `XDG_DATA_HOME` behind a symlink left the real folders above the workspace unexcluded. The launcher now walks up from the environment folder's real path. Co-Authored-By: Claude Opus 5.5 <[email protected]>
allisonmahmood
force-pushed
the
fix/619-environment-agent-isolation
branch
from
October 15, 2026 21:43
0bc6e9f to
e55d4a8
Compare
allisonmahmood
added a commit
that referenced
this pull request
Oct 15, 2026
…ng checks use a throwaway machine (#702) Stacked on #701. The `agent` launcher that `pnpm dev up` writes runs Claude Code's commands with the developer's own HOME and npm prefix. Given the portal's setup line, the environment's agent replaced the developer's global `patchy` and the Patchy skill their own agents load (`~/.patchy/skills`, `~/.agents/skills`, `~/.claude/skills`), and `pnpm dev down` undid none of it. The development guide described the agent as starting "with only the Patchy skill" and warned against nothing. ## The fix Triage chose docs over containment: giving the agent its own HOME would move where pnpm, mise, Playwright and git find their files, and the environment's agent is the wrong place to test onboarding anyway. - The guide's Environments section, the `patchy-dev-loop` skill and the launcher's comments now say the agent is a Patchy user who has already set up, its commands run as the developer, and it must never be given the setup line or run `patchy setup`. - "What to exercise for a change" gains a **Front door and onboarding** entry with a copyable throwaway machine. It is a folder under `/tmp` (outside HOME, so no parent `CLAUDE.md` loads) with its own HOME, npm prefix and cache, no `PATCHY_*`, and a `PATH` of its npm `bin`, Node's real directory and the system tools. `CLAUDE_ENV_FILE` applies it to the agent's commands, so Claude Code keeps the developer's login. A one-line check confirms no other `patchy` is visible first. ## Tested by hand I extracted the recipe's code block from the doc verbatim and ran it against a live `pnpm dev up` environment, with `PATCHY_API_URL` and `PATCHY_API_TOKEN` exported in the outer shell: - **The install line.** In the documented subshell form it exited 0, printed the executable, skill and link paths all inside the throwaway folder, and reached the login handoff. - **Through an agent.** The doc's `claude` command did the same, run headlessly with `-p` and pre-approvals. `echo $HOME` showed the throwaway HOME. An agent started with the recipe's two flags listed only Claude Code's built-in skills and loaded no instruction files. - **The `patchy` check.** With a Node whose folder holds my global `patchy` (mise, Node 26), it prints that path. With the worktree's Node 24 it prints nothing. - **My own install.** Before and after every run, my `~/.claude/skills/patchy`, `~/.agents/skills/patchy`, `~/.patchy/skills/patchy` and every global `patchy` were unchanged (`ls -la`, `readlink`, version and a hash of `dist/index.js`). ## Review GPT 6.1 Sol (xhigh) found one low issue: under nvm or mise, Node's folder can hold the developer's global `patchy`, so the agent could see it before installing. I tried linking just `node` and `npm` into the machine instead, but mise's `npm` is a launcher that locates itself by its own folder and broke. So the recipe keeps Node's real folder and adds the check Sol suggested. Sol found no other correctness, surface or scope problems. ## Surfaces From "Hit every surface", the dev loop entry applied: `docs/DEVELOPMENT.md`, the `patchy-dev-loop` skill and the runner's launcher comments. Nothing else describes the environment's agent. Closes #592 Made by Claude Opus 5.5 in Claude Code, running in T3 Code.
allisonmahmood
added a commit
that referenced
this pull request
Oct 16, 2026
…u when they fail (#720) Release 13's What's new entry, written from `c9b8fc4`, ahead of deploying it. `patchy` and `CURRENT_RELEASE` move to `0.13.0`, so CLIs and patch repos installed before this deploy are told to upgrade. | Change | PRs | | --- | --- | | New: Home puts the patches you use first | #713, #716, #719 | | New: Every patch in one list | #715 | | Improved: Each patch's page leads with Open | #717 | | New: See when your tools are failing | #718 | | Fixed: Everyone has a name | #687 | | Improved: Your company's look is easier to get right | #697, #696, #703, #688 | | Improved: Forms follow your look's error states | #691, #692 | | Improved: Clearer answers when a publish goes wrong | #686, #685, #689 | | Fixed: Your agent's Patchy commands are steadier | #695, #704, #680, #681 | | Behind the scenes: stricter checks on static pages and tools' database requests; malformed requests are logged | #682, #693, #683 | | Behind the scenes: usage numbers count every publish, sharing change and restore | #698, #699, #700, #690 | | Test and tooling only, no line | #705, #702, #701, #694, #684, #607 | Made by Claude Opus 5.5 in Claude Code, running in T3 Code. Co-authored-by: Claude Opus 5.5 <[email protected]>
1 of 2 tasks
allisonmahmood
added a commit
that referenced
this pull request
Oct 19, 2026
…er (#806) ## What changed People's agents use the CLI and the Patchy skill, and when something is awkward they fumble: they guess flags, retry, read help or give up. Until now we only saw that when someone's agent hit it. Now `pnpm dev trial "<task>"` gives a task to a fresh agent on both evidence instances (#725), the base and the head, and puts how each attempt went in the PR. The agent is each side's own `agent` launcher: Claude Code as the scenario's publisher, with the release's Patchy skill and no personal instructions or settings. It runs without a person, within 30 turns and 10 minutes by default. Only a filtered log is kept: whether it finished, its answer in a sentence or two, its commands with exit codes, one line per failure, and the counts. #792's sanitizer reads each side's CLI state after every tool call and redacts everything before it's written. Closes #793 ## Look at **1. This PR's own trial, published with `--pr`.** This branch changes no CLI command, so the trial uses `--base 6900c71~1`, the commit before #786 added `patchy logs`, with the task "Show me the last few lines of the new-business patch's log." On this PR's head, after's agent found `patchy logs` through `--help` and read the log. Before's had no `patchy logs`, tried `pnpm patchy dev logs` and reported "No dev log yet." One run is a smell test, not a measurement. Over seven `brightline` runs of this task, after's agent found `patchy logs` five times and before's never did. In the other two, both agents took "log lines" to mean a log file and gave up. <!-- patchy-dev:trial:show-me-the-last-few-lines --> #### Trial `show-me-the-last-few-lines` > Show me the last few lines of the new-business patch's log. Before is `03891e4` (--base 6900c71~1) and after is `ebe3966` (dev/793-trial), both on the `brightline` scenario, from `pnpm dev trial`. Each side gave the task to a fresh agent: the environment's `agent` launcher, Claude Code on `claude-sonnet-5-5` as the scenario's publisher, with the release's Patchy skill and no personal instructions or settings, run without a person within 30 turns and 10 minutes. The log keeps each tool call, commands with their exit codes, and one line per failure; not the agent's reasoning or what its commands printed. Nothing in it matched a collected secret (each side's CLI state, machine-token and login-code shapes, email addresses outside the scenarios' example domains, secret-named variables, and any accounts the run acts as). One run is a smell test, not a measurement. | | Before | After | | --- | --- | --- | | Finished | Yes | Yes | | Commands | 9 | 10 | | Failures | 3 | 2 | | Help lookups | 1 | 4 | | Minutes | 0.4 | 0.3 | **Before** answered: “The new-business patch has no log yet. `pnpm patchy dev logs` returned "No dev log yet." The log only exists once the local dev session has run.” **After** answered: “The new-business patch's log has only one entry. It's the newest, and I asked for 5.” <details><summary>Before's log: 9 commands, 3 failures</summary> ```console denied $ cd <env> && ls -la workspace trial-tmp; find . -iname '*new-business*' -o -iname '*new_business*' -o -iname '*.log' 2>/dev/null | head -50 This Bash command contains multiple operations. The following part requires approval: cd <env> && ls -la workspace trial-tmp; find . -iname '*new-business*' -o -iname '*new_business*' -o -iname '*.log… denied $ find <env> -iname '*new-business*' -o -iname '*new_business*' -o -iname '*.log' find in '<env>' was blocked. For security, Claude Code may only search files in the allowed working directories for this session: '<env>/workspace', '<env>/trial-tmp'. exit 0 $ find <env>/workspace <env>/trial-tmp exit 0 $ find <env>/workspace/new-business -path '*/node_modules' -prune -o \( -iname '*.log' -o -iname '*log*' \) -print exit 0 $ ls -la <env>/workspace/new-business <env>/workspace/new-business/patchy exit 0 $ cd <env>/workspace/new-business && ls -laR .patchy server | head -40; cat package.json patchy.json exit 0 $ grep -n -i -B1 -A3 'log' AGENTS.md; ls node_modules/.bin | grep -i patchy denied $ node_modules/.bin/patchy --help This command requires approval skill patchy exit 0 $ pnpm patchy dev logs 2>&1 | tail -n 15 ``` </details> <details><summary>After's log: 10 commands, 2 failures</summary> ```console exit 0 $ ls -la && find . <env>/trial-tmp -maxdepth 3 -ipath '*new-business*' 2>/dev/null | head -50 exit 0 $ cd <env>/workspace/new-business && ls -la .patchy; find . -path ./node_modules -prune -o \( -iname '*.log' -o -iname '*log*' \) -print | head exit 0 $ ls -la .patchy/publish; grep -n -i 'log' AGENTS.md patchy.json package.json | head -20 exit 0 $ ls -laR .patchy/publish; cat patchy.json; grep -n -i -B1 -A3 'log\|history' AGENTS.md | head -30 denied $ grep -n '"scripts"' -A12 package.json; npx --no-install patchy --help 2>&1 | head -30 This Bash command contains multiple operations. The following part requires approval: grep -n '"scripts"' -A12 package.json; npx --no-install patchy --help 2>&1 exit 0 $ grep -n '"scripts"' -A12 package.json denied $ ./node_modules/.bin/patchy --help 2>&1 | head -30 This Bash command contains multiple operations. The following part requires approval: ./node_modules/.bin/patchy --help 2>&1 exit 0 $ pnpm patchy --help exit 0 $ pnpm patchy logs --help exit 0 $ pnpm patchy logs --limit 5 ``` </details> <!-- /patchy-dev:trial:show-me-the-last-few-lines --> **2. What leaves the machine.** The log keeps each tool call and nothing else the stream carries: not the agent's text or thinking, and not what its commands printed. No session is saved (`--no-session-persistence`), and auto memory is off, so one trial can't carry memories into the next. Each string is redacted, then normalized, and only then cut, so a cut can't split a secret or a path where redaction can't find it. The tests that cover this: - `reads the CLI state after each tool call, before a later one clears it`, against a stand-in launcher that writes a token to the CLI state and deletes it; - `redacts and normalizes a long line before cutting it`; - `redacts the section's key before slugging it`, since the key is public in the markers (Sol's round-1 blocker). A real run turned up one more thing. Claude Code tells its agent which account it is signed in as, and on a `whoami` task the agent named the developer's real email in its answer. That run wasn't published. The shared sanitizer now also redacts any email address outside the reserved domains the scenarios and the seed use (`.example`, `patchy.local`), and that covers `transcript` too. Sol's round 3 then showed the shape alone misses encoded and unusual forms. So a trial now also collects who its agents act as: the Claude account's email (`claude auth status --json`) and git's `user.email`. These reach the sanitizer as known values, so every form of them is redacted. Asked for its account email outright, plain and URL-encoded, the agent's answer read `[redacted]` in both forms, Ada's scenario address stayed readable, and the address appeared nowhere in `--json` or stderr. ## How it was verified - **Focused tests**, `pnpm exec vitest run scripts/dev` (13 files, 77 tests). The new ones cover: - folding a stream-json fixture into the log: exit codes from `Exit code N`, a denial from `permission_denied`, a tool error, a call that never returned, and thinking, text and unknown lines dropped; - how a run ended: out of turns, timed out, a failed result with `errors`, no result; - an answer cut to its gist, help lookups, refused tasks, and the section's table, folded logs and after-only layout; - a real stand-in launcher: the task on stdin, the time budget killing it, and the sanitizer seam above; - collecting identities from a stand-in `claude` and a temporary git config, and redacting every form of one; - the email shape in Sol's forms (Unicode, `%40`, quoted, apostrophe, a `.local` host), with `[email protected]`, `@effect/[email protected]` and the scenarios' addresses left alone. - **Claude Code 2.1.303 probes**, on Haiku in a scratch folder, before writing the parser: - the stream-json shapes; - sign-in with only `HOME` and `PATH`; - `--max-turns` ending as `error_max_turns`; - `--disallowedTools` beating `--allowedTools`; - the prompt on stdin; - `CLAUDE_CODE_DISABLE_AUTO_MEMORY=1` dropping `memory_paths`, with nothing written under `~/.claude/projects`. - **Real trials** on a shared Linux machine, Sonnet. The costs are what Claude Code reported, at API prices: | Run | Took | Cost | What it showed | | --- | --- | --- | --- | | `brightline`, `--base 6900c71~1`, 15 turns / 5 min, the task naming "brightline" | about 3 min from cold | $0.11 + $0.09 | works end to end. The word "brightline" sent both agents searching the file system, and a cut before redaction left part of a home path, so cuts now come after redaction | | the same at 30 turns / 10 min, `--pr 806` | about 2½ min | $0.09 + $0.07 | published. An agent wrote the environment folder as `~/…`, so that form is now normalized too | | again on `ea261bb`, `--pr 806` | about 2½ min | $0.03 + $0.09 | both sides reported the Patchy skill loaded | | `team`, `--base c7a6d08~1` (before #701), 3 turns | about 1½ min | $0.02 | before was "unavailable" for its launcher and never ran; after's answer named the account email (not published), so the email shape was added | | the same, asking for the account email | about 1½ min | $0.02 | `[redacted]`, from the email shape; the scenario address kept | | `brightline`, `--pr 806` on `3258425` | about 2½ min | $0.04 + $0.06 | after found `patchy logs` again | | `team`, asking for the account email URL-encoded, on `5869ee9` | about 1½ min | $0.02 | both forms `[redacted]`, with `identity` and `email` matched | | `brightline`, `--pr 806` on `5869ee9` | about 2½ min | $0.11 + $0.11 | after's agent missed `patchy logs` | | `brightline`, `--pr 806` on `712bec8` | about 2½ min | $0.04 + $0.05 | after missed it again. An earlier log showed an agent reading another session's file in the machine's `/tmp`, so each agent now gets a temp folder of its own (below) | | `team`, `--base 6900c71~1`, asking each agent to use its temp folder and then list `/tmp` | about 1½ min | $0.03 + $0.03 | both wrote and read back a file in their own `<env>/trial-tmp`; `ls /tmp` was blocked on both sides, the old launcher's copy included | | `brightline`, `--pr 806` on `ebe3966` (above) | about 2½ min | $0.13 + $0.08 | the section above: no `/tmp` in either log | The trials came to about $1.20 at API prices, plus the interrupted Ctrl-C run, which reported no cost; the Haiku probes were under a cent. - **The temp folder.** The launcher adds `"${TMPDIR:-/tmp}"`, so interactive use is unchanged. A trial sets `TMPDIR` to a scratch folder in each side's environment folder and deletes it when the run ends. A base whose launcher still adds `/tmp` runs as a copy with only that flag swapped, so both sides have the same limits. Tested with a stub `claude` and a test of the swap; the `team` run above shows it for real. The launcher isn't a sandbox: `node`, which it pre-approves, can still read whatever you can, and the docs say so. - **Ctrl-C mid-run**, while both agents were working: both instances were taken down, both agents ended, both environment folders were deleted and the lock folder was empty. Only the reusable checkouts stayed. - **Leak check** of each published section and its `--json`: the home path, the username, the developer's email, `pp_…`, the login-code shape and local origins matched nowhere. Since the temp-folder fix, the published logs name no path outside each side's environment folder (`<env>`). - **`pnpm verify --changed`** on `ebe3966`, the head: format, lint, typecheck, synth and 2,004 tests passed. It skipped the acceptance suites, since only the runner and docs changed. - **Hit every surface:** - **The dev loop:** `docs/DEVELOPMENT.md` (the command table, "Showing a change in a PR" and "What to exercise") and the `patchy-dev-loop` skill. The seed and the vitest template are unchanged. - **The evidence skill:** `pr-evidence` gains a `trial` entry in its Shows, Make, Costs and Gotchas shape, and "Not built yet" is gone. - **The shared sanitizer:** the email shape applies to `transcript` as well, and DEVELOPMENT's sanitizer paragraph says so. - **Reverse states:** `trial` uses the evidence checkouts that `pnpm dev down` deletes, and leaves no session or memory behind. - **Doesn't apply:** the wire contract, the CLI in `packages/patchy`, migrations, company resources, served pages, the repo layout and vocabulary. - **Reviewed by GPT 6.1 Sol** over eight rounds; the summaries are in the comments. - round 1: 1 blocking (the section key) and 2 should-fix, all fixed; - round 2: no findings; - round 3: 1 blocking (encoded and unusual email forms) and 2 should-fix (a quadratic regex, machine identities), all fixed; - round 4: no blocking findings, and 2 should-fix (stderr from the identity reads, an apostrophe run still quadratic) and 1 nit (`~user` paths), all fixed; - rounds 5 and 6: one regression each from those regex fixes (shell-quoted, then apostrophe-only local parts), both fixed and checked with a differential fuzz against the earlier regexes; - round 7: no blocking findings; one contrived nit, dismissed in writing; - round 8: on the temp-folder fix, no findings. - **Not checked:** macOS, where Claude Code keeps its login in the keychain; signing in with `ANTHROPIC_API_KEY` or `CLAUDE_CODE_OAUTH_TOKEN` (only the login under HOME); a real expired login (a fixture only). - **Done means:** shown above. A trial on #786's CLI change, through `--base`, shows each side's attempt in the PR, and nothing in it matched a secret. ## Release impact Tick exactly one. - [ ] **Breaking** — requires action from anyone already running this - [x] **Not breaking** — dev tooling and docs; nothing ships to production - **What does a revert leave behind?** Trial sections already in PR bodies. The evidence checkouts are #725's, and the older `pnpm dev down` still deletes them. Transcript sections published from here on redact non-example emails; a revert only stops doing that. - **Does the release before it still work with that?** Yes. Nothing here runs in production. Made by Claude Opus 5.5 in Claude Code, running in T3 Code. --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
agentlauncher thatpnpm dev upwrites passed the developer's shell straight through to the environment's agent. If the shell exportedPATCHY_API_URLandPATCHY_API_TOKEN(for production, say), the agent published there, as that key, instead of to the environment as the scenario's publisher. And Claude Code loaded instruction files from every folder above the workspace, the developer's own~/.claude/CLAUDE.mdincluded, so the "fresh Patchy user" followed the developer's personal instructions.The fix
unset PATCHY_API_URL PATCHY_API_TOKEN, asup's own child commands already do.claudeMdExcludessetting through--settings, covering every folder from the environment folder up to/: each folder's*.md(CLAUDE.md,CLAUDE.local.md,AGENTS.md), its.claude/*.mdand its.claude/rules/**. The workspace's own instruction files, its patch repos' files and the Patchy project skill still load.?.pnpm dev upon a finished environment now rewrites the launcher too, so environments made before this change pick up the fix withoutdown.The development guide and the
patchy-dev-loopskill say what the agent ignores. A test runs the generated launcher with a stubclaudeonPATHand both variables exported, and checks the stub sees neither. It fails with theunsetline removed.Tested by hand
On Claude Code 2.1.296:
pnpm dev up(team scenario). Then I planted sentinel words inCLAUDE.mdand.claude/CLAUDE.mdof the environment folder, exported bothPATCHY_*variables, and asked the agent one-pquestion set. With this branch it reported no sentinel, nothing from my personal~/.claude/CLAUDE.md, both variables unset, the Patchy skill present, andpatchy whoamias Ada Park atacme, the scenario's publisher. The same probe through the old launcher (these lines removed) reported both sentinels, my personal instructions, and the exported URL and token./tmp, with and without the setting. Without it, a parent folder'sCLAUDE.md,.claude/CLAUDE.md,.claude/rules/*.mdandAGENTS.mdall load. With it, only the workspace's ownCLAUDE.mddoes. Two cases failed until fixed: a folder namedA (b)/c[1](the plain path didn't match, and neither did a backslash-escaped one;?did), and a data folder behind a symlink (Claude Code walks the resolved path).pnpm dev up. The launcher was rewritten.pnpm exec vitest run scripts/dev: 24 passed.Review
GPT 6.1 Sol (xhigh), two rounds. Round 1 found three issues: the finished-environment early return, unescaped folder names, and a missing dev-loop skill note. All fixed. Round 2 confirmed those and raised two more: the symlinked data folder (fixed, verified above) and a literal backslash in a folder name (dismissed, reason in a comment below).
Surfaces
From "Hit every surface", the dev loop entry applied: the runner (
scripts/dev/src/environment.ts),docs/DEVELOPMENT.mdand thepatchy-dev-loopskill. The vitest Postgres template doesn't apply, since the seed is unchanged. No wire, CLI, vocabulary, migration or served-page change.Closes #619
Closes #620
Made by Claude Opus 5.5 in Claude Code, running in T3 Code.