fix(claude.sh): anchor the workspace argument by position #26
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/argument-parsing"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The problem
The wrapper multiplexes two argv namespaces — its own flags and everything
forwarded to the
claudeCLI — without knowing the arity of Claude's flags.Phase 1 resolved that with a filesystem test: any bare argument naming an
existing directory became the workspace.
The value of a Claude option is a bare argument, so:
claude . -p docsmounted./docsinstead of., and-preached Claudewith its value consumed.
claude . -p /etcbind-mounted/etcinto the container.Nothing warned, because
claude . -p docsandclaude . -p "fix it"arestructurally identical — only the state of the filesystem distinguishes them.
That defeats the single guarantee the wrapper makes about what the container
can see.
The fix
The workspace is now position-anchored. A bare word can claim it only while the
wrapper is still parsing its own arguments; anything bound for Claude locks the
slot. Since a flag always precedes its value, an option value can no longer be
read as a mount.
---*)Two bare directories now produce an error naming both ways to disambiguate,
rather than a silent choice between them. The resolved workspace is printed to
stderr next to the session line — a wrong mount was previously invisible until
something misbehaved inside the container.
claude . -p docs./docs,-plost its value., forwards-p docsclaude . -p /etc/etc., forwards-p /etcclaude . docsdocsWhat does not change
Every invocation in
README.mdand--helpparses identically — each placesthe directory first or after a known wrapper flag, which does not lock. All
nine were verified end-to-end against the real script, not just in tests.
Breaking change
claude "fix it" .no longer mounts.; it forwards both arguments and fallsback to cwd, because the prompt locks the slot. This ordering is undocumented,
but it is a real break for anyone who types prompts that way. It follows
necessarily from position-anchoring and was accepted deliberately during design.
Testing
Adds
tests/test_arg_parsing.sh— 7 tests for the new behaviour, 10 pinning thedocumented invocations. 43 tests green on this branch.
All 7 were watched failing before the fix. One had its assertions edited
afterwards, which destroys that proof, so the suite was additionally verified
against two mutations of the parser (removing the
--case; dropping the lockon unknown flags) to confirm it catches both. Flake-checked with 30 full-suite
runs and 15 shuffled-order runs.
Review notes
Design rationale, including the two rejected alternatives (
--requiredeverywhere, and an explicit
--workspaceflag), is indocs/superpowers/specs/2026-07-28-argument-parsing-design.md, added by thefirst commit on this branch.
This branch forked from
mainand does not includeperf/claudeignore-pruning.The two touch different phases of
claude.shand should merge cleanly, but norun has exercised them together — worth a suite run on
mainafter the secondmerge.
dd9fc8295dtoc0c8d876b8