From 7a8978c6a4b6c90a43e47f70254a4d19a3792905 Mon Sep 17 00:00:00 2001 From: huntharo Date: Tue, 24 Mar 2026 14:48:33 -0400 Subject: [PATCH 1/3] fix(ce-work-beta): add explicit stdin piping guidance for Codex delegation Codex CLI rejects shell redirects (`< file`) with "stdin is not a terminal". The delegation step said "pipe via stdin" but gave no concrete example, so the agent used a redirect instead. Add a concrete `cat file | codex exec ...` example and an explicit warning against `< file`. Co-Authored-By: Claude Opus 4.6 (1M context) --- ...-001-fix-codex-stdin-pipe-guidance-plan.md | 43 +++++++++++++++++++ .../skills/ce-work-beta/SKILL.md | 12 +++++- 2 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 docs/plans/2026-03-24-001-fix-codex-stdin-pipe-guidance-plan.md diff --git a/docs/plans/2026-03-24-001-fix-codex-stdin-pipe-guidance-plan.md b/docs/plans/2026-03-24-001-fix-codex-stdin-pipe-guidance-plan.md new file mode 100644 index 000000000..4ed5111b4 --- /dev/null +++ b/docs/plans/2026-03-24-001-fix-codex-stdin-pipe-guidance-plan.md @@ -0,0 +1,43 @@ +--- +title: "fix: add explicit stdin piping guidance for Codex delegation" +type: fix +status: active +date: 2026-03-24 +--- + +# fix: add explicit stdin piping guidance for Codex delegation + +## Problem + +When ce:work-beta delegates to Codex CLI, the skill says "piping the prompt file via stdin" but provides no concrete command example. The agent interprets this as a shell redirect: + +```bash +codex --dangerously-bypass-approvals-and-sandbox < /tmp/codex_task_20980.txt 2>&1 +``` + +This fails with: + +``` +Error: Exit code 1 +Error: stdin is not a terminal +``` + +Codex CLI checks whether stdin is a terminal (likely `isatty()`) and rejects shell redirects (`< file`). A pipe (`cat file | codex`) works because it presents data differently to the process. + +## Approach + +In step 5 ("Delegate") of the External Delegate Mode section in `ce-work-beta/SKILL.md`, add: + +1. A concrete command example using `cat file | codex ...` +2. An explicit warning that `< file` (shell redirect) does NOT work -- Codex rejects it with "stdin is not a terminal" +3. Keep the existing note about avoiding argv expansion for large prompts + +## Files + +- `plugins/compound-engineering/skills/ce-work-beta/SKILL.md` -- step 5 of External Delegate Mode + +## Acceptance Criteria + +- [ ] Step 5 contains a concrete `cat ... | codex exec ...` command example with placeholder flags from step 2 +- [ ] Explicit warning: shell redirects (`< file`) fail with "stdin is not a terminal" +- [ ] Existing guidance about avoiding argv expansion is preserved diff --git a/plugins/compound-engineering/skills/ce-work-beta/SKILL.md b/plugins/compound-engineering/skills/ce-work-beta/SKILL.md index 1265ac9eb..301446609 100644 --- a/plugins/compound-engineering/skills/ce-work-beta/SKILL.md +++ b/plugins/compound-engineering/skills/ce-work-beta/SKILL.md @@ -472,7 +472,17 @@ When external delegation is active, follow this workflow for each tagged task. D 3. **Write prompt to file** — Save the assembled prompt to a unique temporary file to avoid shell quoting issues and cross-task races. Use a unique filename per task. -4. **Delegate** — Run the delegate CLI, piping the prompt file via stdin (not argv expansion, which hits `ARG_MAX` on large prompts). Omit the model flag to use the delegate's default model, which stays current without manual updates. +4. **Delegate** — Run the delegate CLI, piping the prompt file via stdin. Omit the model flag to use the delegate's default model, which stays current without manual updates. + + **Use `cat ... | codex`, not shell redirects.** Codex CLI rejects `< file` with "stdin is not a terminal". Always pipe: + + ```bash + cat /tmp/codex-task-XXXXX.txt | codex exec --approval-mode full-auto --quiet 2>&1 + ``` + + Do not use: `codex exec ... < /tmp/codex-task-XXXXX.txt` (fails immediately). + + Piping also avoids `ARG_MAX` limits that would occur if passing the prompt as a CLI argument. 5. **Review diff** — After the delegate finishes, verify the diff is non-empty and in-scope. Run the project's test/lint commands. If the diff is empty or out-of-scope, fall back to standard mode for that task. From fc42fcb7654faf7387526c7ed2854d5be651c412 Mon Sep 17 00:00:00 2001 From: huntharo Date: Tue, 24 Mar 2026 14:55:41 -0400 Subject: [PATCH 2/3] fix(ce-work-beta): use `codex` not `codex exec` for piped stdin delegation `codex exec` does not accept `--approval-mode` flag. When piping a prompt via stdin, use `codex --approval-mode full-auto --quiet` directly (no `exec` subcommand). Co-Authored-By: Claude Opus 4.6 (1M context) --- plugins/compound-engineering/skills/ce-work-beta/SKILL.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/compound-engineering/skills/ce-work-beta/SKILL.md b/plugins/compound-engineering/skills/ce-work-beta/SKILL.md index 301446609..ab789c6b3 100644 --- a/plugins/compound-engineering/skills/ce-work-beta/SKILL.md +++ b/plugins/compound-engineering/skills/ce-work-beta/SKILL.md @@ -477,10 +477,11 @@ When external delegation is active, follow this workflow for each tagged task. D **Use `cat ... | codex`, not shell redirects.** Codex CLI rejects `< file` with "stdin is not a terminal". Always pipe: ```bash - cat /tmp/codex-task-XXXXX.txt | codex exec --approval-mode full-auto --quiet 2>&1 + cat /tmp/codex-task-XXXXX.txt | codex --approval-mode full-auto --quiet 2>&1 ``` - Do not use: `codex exec ... < /tmp/codex-task-XXXXX.txt` (fails immediately). + Do not use `exec` subcommand with piped stdin — `codex exec` does not accept `--approval-mode`. + Do not use shell redirects (`< file`) — Codex rejects them with "stdin is not a terminal". Piping also avoids `ARG_MAX` limits that would occur if passing the prompt as a CLI argument. From eaeaa0e4bef87f926ae30eb6eca64473ce6e35ac Mon Sep 17 00:00:00 2001 From: huntharo Date: Tue, 24 Mar 2026 14:57:49 -0400 Subject: [PATCH 3/3] fix(ce-work-beta): correct Codex delegation command and document pitfalls Replace incorrect `codex --approval-mode` example with the tested working invocation: `cat file | codex exec --skip-git-repo-check - `. Add a pitfalls table documenting all five failure modes discovered during testing: shell redirects, bare codex vs exec, wrong flags, missing git repo check skip, and missing trailing dash for stdin. Co-Authored-By: Claude Opus 4.6 (1M context) --- .../skills/ce-work-beta/SKILL.md | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/plugins/compound-engineering/skills/ce-work-beta/SKILL.md b/plugins/compound-engineering/skills/ce-work-beta/SKILL.md index ab789c6b3..af27bb881 100644 --- a/plugins/compound-engineering/skills/ce-work-beta/SKILL.md +++ b/plugins/compound-engineering/skills/ce-work-beta/SKILL.md @@ -472,16 +472,21 @@ When external delegation is active, follow this workflow for each tagged task. D 3. **Write prompt to file** — Save the assembled prompt to a unique temporary file to avoid shell quoting issues and cross-task races. Use a unique filename per task. -4. **Delegate** — Run the delegate CLI, piping the prompt file via stdin. Omit the model flag to use the delegate's default model, which stays current without manual updates. - - **Use `cat ... | codex`, not shell redirects.** Codex CLI rejects `< file` with "stdin is not a terminal". Always pipe: +4. **Delegate** — Run `codex exec` with the prompt piped via stdin. Use `exec` (not bare `codex`) for non-interactive delegation. Omit the model flag to use the delegate's default model, which stays current without manual updates. ```bash - cat /tmp/codex-task-XXXXX.txt | codex --approval-mode full-auto --quiet 2>&1 + cat /tmp/codex-task-XXXXX.txt | codex exec --skip-git-repo-check - 2>&1 ``` - Do not use `exec` subcommand with piped stdin — `codex exec` does not accept `--approval-mode`. - Do not use shell redirects (`< file`) — Codex rejects them with "stdin is not a terminal". + **Codex exec pitfalls (all discovered during testing):** + + | Pitfall | Error you get | Fix | + |---------|--------------|-----| + | Shell redirect `< file` instead of pipe | "stdin is not a terminal" | Use `cat file \| codex exec ...` | + | Bare `codex` instead of `codex exec` | Enters interactive mode, hangs | Use `codex exec` for non-interactive delegation | + | `--approval-mode` flag on `exec` | "unexpected argument" | `exec` has its own flags; `--approval-mode` is for bare `codex` only | + | Running outside a git repo | "Not inside a trusted directory" | Add `--skip-git-repo-check` flag | + | Forgetting `-` at end | Prompt not read from stdin | Trailing `-` tells `codex exec` to read the prompt from stdin | Piping also avoids `ARG_MAX` limits that would occur if passing the prompt as a CLI argument.