Skip to content

Piped stdin never reaches Claude (docker exec/run missing -i) #68

Description

@alanbem

Problem

The non-interactive / print-mode paths run Claude without attaching stdin:

  • Persistent container, existing: exec docker exec -u claude -w "$HOST_PATH" "$container_name" claude ... (dclaude:1820)
  • Persistent container, fresh: same pattern (dclaude:2043)
  • Ephemeral: TTY flags are derived from [[ -t 0 ]], so piped stdin (not a TTY) yields no -i either

So the canonical scripting integration silently gets empty stdin:

git diff | dclaude -p "review this diff"     # Claude sees no input
cat error.log | dclaude -p "explain"          # same

The TTY-detection table in CLAUDE.md describes exactly these scenarios, but the implementation conflates "stdin is not a TTY" (skip -t, skip tmux) with "don't attach stdin at all" (skip -i).

Fix

-i (attach stdin) and -t (allocate TTY) are independent. Stdin should be attached whenever it's a TTY or a pipe/redirect — effectively always for docker exec/docker run in these paths. Only -t should depend on TTY detection:

docker exec -i $([[ "$STDOUT_IS_TTY" == "true" ]] && echo -t) ...

(Only fully detached/background use would want to drop -i, which dclaude doesn't have.)


Found during a full-project code review.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions