Feature Request: Allow piping input to pre-populate the interactive session prompt
Feature Request: Allow piping input to pre-populate the interactive session prompt
Labels: enhancement, feature-request, cli, usability
Is your feature request related to a problem? Please describe.
Currently, piping input to Claude Code is handled by the --print (-p) flag (e.g., cat file.txt | claude -p "summarize this"). This is extremely powerful for scripting and one-shot tasks. However, it's strictly non-interactive; the command executes, prints the output, and exits.
If a user wants to pipe in a large piece of context (like a log file, a git diff, or source code) and then have an interactive, multi-turn conversation about it, the current workflow is cumbersome. The user must either manually copy-paste the content into the interactive prompt or save it to a temporary file and then reference it with @. This breaks the natural, fluid workflow of the command line.
Describe the solution you'd like
I propose a new mode of operation where piping stdin to claude without the -p flag launches a new interactive session (the TUI) and pre-populates the prompt buffer with the piped content.
Proposed User Experience:
- A user runs a command like
git diff main | claudeorcat src/main.go | claude. - The Claude Code interactive TUI starts up as usual.
- The content from
stdin(the git diff or file content) is already present in the multiline input prompt. - The cursor is placed at the end of the pre-populated content, ready for the user to type.
- The user can now add their instructions (e.g., "Please review these changes for potential issues and suggest improvements."), edit the content, or simply press Enter to submit the context as is.
This would create a seamless bridge between standard command-line utilities and the rich conversational interface of Claude Code.
Describe alternatives you've considered
- Using
claude -p: As mentioned, this is the current method. It's great for automation but doesn't allow for the follow-up questions and iterative refinement that make the interactive mode so valuable. - Manual Copy & Paste: This is the most common workaround. It's inefficient, error-prone for large content, and disrupts the terminal-native workflow.
- Temporary Files: A user can redirect output to a file (
git diff > changes.txt) and then use@changes.txtin an interactive session. This works but adds extra steps and creates temporary file clutter.
Use Cases & Benefits
This feature would enable powerful, interactive workflows directly from the shell:
- Interactive Code Review:
``bash``
git diff main | claude
# User then types: "Review these changes. Are there any potential race conditions?"
- Log Analysis:
``bash``
tail -n 200 server.log | claude
# User then types: "What is the root cause of the NullPointerException in these logs?"
- Code Comprehension:
``bash``
cat ./scripts/deploy.sh | claude
# User then types: "Explain this deployment script to me step-by-step."
Core Benefit: This feature strongly aligns with the Unix philosophy of small, composable tools. It allows claude to become a natural endpoint in a command pipeline for interactive analysis, combining the power of the shell with the intelligence of an AI agent.
This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗