Pass prompt via stdin in /codex skill to fix Windows argv limit (also closes #971, #1034)
Summary
The /codex skill in codex/SKILL.md invokes codex exec with the prompt as a positional argv argument in both Challenge mode (Step 2B) and Consult mode (Step 2C). When the constructed prompt exceeds roughly 32KB - which happens easily in Consult mode because Step 2C prepends the entire plan-file content to the prompt, and in Challenge mode when Claude packs a large git diff into the prompt - the invocation fails on Windows before the Codex binary ever starts.
Observed failure on gstack v0.16+ / codex-cli 0.128.0 / Windows 10 / Git Bash (msys2) / Node v22.22.1, with a ~57KB prompt:
/c/Users/<user>/AppData/Roaming/npm/codex: line 15: /c/Program Files/nodejs/node: Argument list too long
/c/Users/<user>/AppData/Roaming/npm/codex: line 15: /c/Program Files/nodejs/node: No error
Root cause is the Win32 CreateProcess ~32,767-character command-line limit (KB830473). The npm-installed codex shim launches node via Git Bash / cmd.exe and inherits that limit, so any argv larger than ~32KB never reaches the Codex Rust binary. The skill silently breaks for Windows users above that threshold, with a cryptic error from the npm shim that doesn't mention gstack, Codex, or the skill at all.
Why this is worth fixing now (and why it's not a duplicate)
This is closely related to two existing issues that complain about the same codex exec "<prompt>" pattern in skill bash blocks, from different angles:
- #971 ---
codex exechangs in skill bash blocks because stdin isn't closed (missing</dev/null). - #1034 --- same hang in
scripts/resolvers/review.tsandscripts/resolvers/design.ts, same proposed</dev/nullpatch.
Both of those propose adding </dev/null to keep stdin closed while still passing the prompt as argv. That fixes the hang but doesn't fix this Windows argv-limit case - the prompt still has to fit in CreateProcess.
There is a single change that resolves all three (#971, #1034, and this one) cleanly and follows OpenAI's documented pattern for large prompts: pipe the prompt through stdin instead of passing it as argv, using codex exec -. From the Codex CLI reference (https://developers.openai.com/codex/cli/reference): "Initial instruction for the task. Use - to pipe the prompt from stdin."
Steps to reproduce
On Windows in Git Bash, against any repo with a moderately large plan file (say >40KB):
- Have
~/.claude/plans/<project>-*.mdexist with a long plan (40-80KB is enough). - In a Claude Code session inside the project, run
/codexwith no arguments. - The skill auto-detects Consult mode and prepends the plan content to the prompt (Step 2C).
- When the assembled prompt exceeds ~32KB, the Bash invocation fails:
Bash(... PROMPT=$(cat /tmp/codex/prompt.txt); codex exec "$PROMPT" -C "$_REPO" -s read-only ...)
⤷ ---STDERR---
/c/Users/<user>/AppData/Roaming/npm/codex: line 15: /c/Program Files/nodejs/node: Argument list too long
/c/Users/<user>/AppData/Roaming/npm/codex: line 15: /c/Program Files/nodejs/node: No error
A minimal manual repro (no skill involved):
python -c "print('x' * 50000)" > /tmp/prompt.txt
PROMPT="$(cat /tmp/prompt.txt)"
codex exec "$PROMPT" -s read-only # fails with Argument list too long on Windows
codex exec - -s read-only < /tmp/prompt.txt # works on Windows
Proposed fix
In codex/SKILL.md, switch both codex exec invocations from argv to stdin:
Step 2B (Challenge mode) - current:
codex exec "<prompt>" -s read-only -c 'model_reasoning_effort="xhigh"' --enable web_search_cached --json 2>/dev/null | python3 -c "..."
Step 2B - proposed:
printf '%s' "<prompt>" \
| codex exec - -s read-only -c 'model_reasoning_effort="xhigh"' --enable web_search_cached --json 2>/dev/null \
| python3 -c "..."
Step 2C (Consult mode) - same transformation, both for the new-session and resumed-session forms. The <<< "<prompt>" here-string is an alternative but is bash-specific; printf '%s' "$PROMPT" | codex exec - works in any POSIX shell.
This change:
- Sidesteps the Win32
CreateProcessargv limit entirely - stdin has no such ceiling on any platform. - Naturally closes stdin (pipe reaches EOF after the prompt streams in), which also resolves #971 and #1034 without needing
</dev/nullpatches. - Follows OpenAI's documented pattern for large prompts in Codex CLI.
- Is a pure markdown / skill-template change - no binary or installer changes.
Happy to open a PR with the change if maintainers agree on the approach. I'd also suggest a follow-up audit of any other gstack skill that shells out to codex exec or similar long-prompt CLIs (autoplan, plan-eng-review, plan-ceo-review, design-review were mentioned in #1034) for the same pattern.
Environment
- gstack: latest from
main(verified pattern still present incodex/SKILL.mdStep 2B / 2C) - codex-cli: 0.128.0
- OS: Windows 10 x64
- Shell: Git Bash (msys2)
- Node: v22.22.1
- Claude Code: latest
Related
- #971 --- codex exec stdin hang (same skill bash pattern, different symptom)
- #1034 --- codex exec stdin hang in review/design resolvers (proposes
</dev/null; this issue argues the stronger fix is stdin-as-prompt)
Source: garrytan/gstack