copilot-cli icon indicating copy to clipboard operation
copilot-cli copied to clipboard

Allow prompts to be passed via stdin for advanced scripting and usability

Open waldekmastykarz opened this issue 10 months ago • 2 comments

Describe the feature or problem you'd like to solve

It's currently inconvenient to pass complex, multiline prompts with code samples and quotes to copilot-cli through the -p argument, as the CLI requires escaping quotes and line breaks, making scripting and interactive use cumbersome.

Proposed solution

Support passing the prompt to copilot-cli via standard input (stdin), enabling users to pipe in content directly or redirect from files. This would streamline interactive use and scripting, reducing the need for cumbersome escaping and making it easier to work with prompts that include code and formatting.

Example prompts or workflows

  • echo "Suggest a git alias for rebasing." | copilot <command> --stdin
  • cat elaborate_prompt.txt | copilot <command> --stdin

Additional context

  • This feature is particularly useful when prompts are generated programmatically or authored in external editors.
  • It would maintain parity with other CLI tools that support stdin (such as git, jq, etc).
  • Could help standardize CI/CD and scripting scenarios.

waldekmastykarz avatar Jan 21 '26 13:01 waldekmastykarz

I just checked and these variants work for me echo "1+1" | copilot --model gpt-4.1 echo "1+1" | copilot --model gpt-4.1 -p ""

echo "1+1" > prompt.txt
cat prompt.txt | copilot --model gpt-4.1

Ubuntu 24.04

MLgentDev avatar Jan 22 '26 22:01 MLgentDev

Confirmed it's working

waldekmastykarz avatar Jan 27 '26 09:01 waldekmastykarz