Pass prompt via stdin in /codex skill to fix Windows argv limit (also closes #971, #1034)

Open Beginner friendly
#1,674 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
82/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
markdown, shell
Domain
cli, tooling

Research direction

Read codex/SKILL.md, focusing on the Challenge mode Step 2B and Consult mode Step 2C codex exec invocations, including new-session and resumed-session forms. Reproduce the long-prompt behavior with the supplied stdin and argv commands, then verify that all affected invocations accept prompts through stdin and still produce the expected Codex output.

Written by the indexing model from the issue text.

Description

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 exec hangs in skill bash blocks because stdin isn't closed (missing </dev/null).
  • #1034 --- same hang in scripts/resolvers/review.ts and scripts/resolvers/design.ts, same proposed </dev/null patch.

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):

  1. Have ~/.claude/plans/<project>-*.md exist with a long plan (40-80KB is enough).
  2. In a Claude Code session inside the project, run /codex with no arguments.
  3. The skill auto-detects Consult mode and prepends the plan content to the prompt (Step 2C).
  4. 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:

  1. Sidesteps the Win32 CreateProcess argv limit entirely - stdin has no such ceiling on any platform.
  2. Naturally closes stdin (pipe reaches EOF after the prompt streams in), which also resolves #971 and #1034 without needing </dev/null patches.
  3. Follows OpenAI's documented pattern for large prompts in Codex CLI.
  4. 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 in codex/SKILL.md Step 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)
Dominant language
TypeScript
Stars
134k
Forks
19.9k
Avg merge
20h 59m
Merged PRs (30d)
21

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from garrytan/gstack

All issues in garrytan/gstack

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.