windows-bash-backslash-halving
Skill4 starsChanged 2 days agoMITView on GitHub
Fix for backslash-containing values (Windows named-pipe paths like \\.\pipe\x, UNC paths, regexes) getting corrupted when an agent writes them in a Bash-tool command on Windows (Claude Code's Bash tool running Git Bash). Use when: (1) a value you wrote with `\\` arrives downstream with `\`, (2) connecting to \\.\pipe\... fails with ENOENT although the pipe server is listening, (3) an env var exported in Bash differs from what a spawned node or python process reports, (4) a client silently falls back to a local or default path, so remote wiring looks "ignored". Not MSYS path conversion: MSYS2_ENV_CONV_EXCL and MSYS_NO_PATHCONV do not help.
- Reads credentials
In this repository50 other files it gives its agents.
- agent-writingSkill
- arenaSkill
- blast-radiusSkill
- bun-playwright-runner-selectionSkill
- cinematic-shotSkill
- clean-ui-shotSkill
- codebase-designSkill
- debug-loopSkill
- dep-upgradeSkill
- diagnosing-bugsSkill
- discoverSkill
- domain-modelingSkill
- earshotSkill
- eval-judgeSkill
- flaky-testSkill
- grillingSkill
- grillSkill
- idea-scoutSkill
- improve-codebase-architectureSkill
- interrogateSkill
- make-mediaSkill
- migrate-to-rustSkill
- migration-planSkill
- multi-agent-windows-hazardsSkill
- perf-loopSkill
- postmortemSkill
- prototypeSkill
- prSkill
- real-soundSkill
- recallSkill
- release-notesSkill
- repo-mapSkill
- researchSkill
- retroSkill
- secure-diffSkill
- sellSkill
- subagent-report-recoverySkill
- tasteSkill
- taste-skillSkill
- tddSkill
- teachSkill
- to-questionnaireSkill
- to-specSkill
- to-ticketsSkill
- wayfinderSkill
- weeklySkill
- wizardSkill
- writing-for-agentsSkill
- ycSkill
- ystack-upgradeSkill
The file
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 38
Verify at the consumer, not the producer: node -e "console.log(JSON.stringify(process.env.MYVAR))".
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Windows Bash-tool backslash halving
Problem
On Windows, command text sent through Claude Code's Bash tool (Git Bash) has \\ collapsed to \
before the shell runs it, even inside single quotes, where POSIX forbids any escape processing. Values
that need exact doubled backslashes (named-pipe paths \\.\pipe\x, UNC paths \\server\share, regex
escapes) arrive corrupted, with no error.
Trigger conditions
- The definitive probe:
printf '%s\n' 'a\\b'in the Bash tool printsa\b. A real POSIX shell printsa\\b. net.createConnection({ path: "\.\pipe\x" })(mangled from\\.\pipe\x) fails with ENOENT.- The symptom can be indirect. Software with a local fallback quietly runs locally when its
pipe:endpoint env var is mangled, which masks the failure. Check the receiving process's environment, not the command you wrote.
Solution
- Use a PowerShell tool for setting or testing exact-backslash values, if your harness has one.
'pipe:\\.\pipe\x'in a PowerShell-tool command arrives intact. - Or write the value to a file with the file-write or edit tool; no shell layer touches it. JSON
files still need normal JSON escaping (
"pipe:\\\\.\\pipe\\x"decodes topipe:\\.\pipe\x). - Or double every backslash in Bash-tool text: write
\\\\to deliver\\. - Verify at the consumer, not the producer:
node -e "console.log(JSON.stringify(process.env.MYVAR))".
Verification
The JSON.stringify probe shows the exact characters the child process received. For pipe endpoints,
also check the pipe server's log for a connection attempt: zero attempts means the client never had a
valid path.
Why it happens, and where it doesn't
- The halving happens in the tool layer that delivers command text to
bash.exe, not in bash and not in MSYS environment conversion. That is whyMSYS2_ENV_CONV_EXCLandMSYS_NO_PATHCONVhave no effect. - Environment inheritance is faithful. Bash passes values to child processes unchanged. Only the literal command text you write is affected, so a value set once through PowerShell, the registry or a settings file flows through correctly afterwards.
- It does not apply to a PowerShell tool, to file contents written with the file tools, or to values a
Windows process injects itself (for example the harness's own
envsettings).
Example
A plugin client reads its server endpoint from an env var. Exported in a Bash-tool smoke test as
MY_ENDPOINT=pipe:\\.\pipe\my-app-server, it arrived as pipe:\.\pipe\my-app-server. The client got
ENOENT and fell back to spawning a local server, so the remote bridge looked dead. The identical test
run through the PowerShell tool connected to the remote server.
Notes
- Seen on Windows 11 with Claude Code's Bash tool (Git Bash). Re-run the
printfprobe after a harness upgrade: if it printsa\\b, the bug is fixed in your version.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

