# apply_stdin_pipe

> **Function** in `deepagents_cli`

📖 [View in docs](https://reference.langchain.com/python/deepagents-cli/main/apply_stdin_pipe)

Read piped stdin and merge it into the parsed CLI arguments.

When stdin is not a TTY (i.e. input is piped), reads all available text
and applies it to the argument namespace. If stdin is a TTY or the piped
input is empty/whitespace-only, the function returns without modifying
`args`. Leading and trailing whitespace is stripped from piped input.

- If `non_interactive_message` is already set (`-n`), prepends the
    piped text to it (the CLI still runs non-interactively):

    ```bash
    cat context.txt | deepagents -n "summarize this"
    # non_interactive_message = "{contents of context.txt}\n\nsummarize this"
    ```

- If `initial_prompt` is already set (`-m`, but not `-n`), prepends
    the piped text to it (the CLI still runs interactively):

    ```bash
    cat error.log | deepagents -m "explain this"
    # initial_prompt = "{contents of error.log}\n\nexplain this"
    ```

- If `initial_skill` is already set (`--skill`, but not `-n`), stores the
    piped text in `initial_prompt` so the skill receives it as the
    startup request:

    ```bash
    cat diff.txt | deepagents --skill code-review
    # initial_prompt = "{contents of diff.txt}"
    ```

- Otherwise, sets `non_interactive_message` to the piped text, causing
    the CLI to run non-interactively with it as the prompt:

    ```bash
    echo "fix the typo in README.md" | deepagents
    # non_interactive_message = "fix the typo in README.md"
    ```

## Signature

```python
apply_stdin_pipe(
    args: argparse.Namespace,
) -> None
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `args` | `argparse.Namespace` | Yes | The parsed argument namespace (mutated in place). |

---

[View source on GitHub](https://github.com/langchain-ai/deepagents/blob/0b13f3e0e2726fdb7bbe1e0cf88dac76dbd43b01/libs/cli/deepagents_cli/main.py#L1128)