127 words
1 minutes
How to Run GitHub Copilot CLI with a Direct Prompt【-p Flag】

Overview#

Opening Copilot CLI, waiting for the interactive prompt, typing your question, getting the answer, then exiting — feels like a lot of steps for a quick one-off task, doesn’t it?

The -p flag lets you pass a prompt directly from your terminal for one-shot execution.


Usage#

Run from your terminal:

copilot -p "translate this README.md to Japanese"

The prompt is processed without entering interactive mode. --prompt works too:

copilot --prompt "find and fix the failing tests"

When to Use It#

ScenarioExample
Quick one-off questioncopilot -p "explain this function"
Script automationEmbed in CI/CD or shell scripts
Shell aliasesRegister frequently used prompts as aliases

Interactive vs. -p#

MethodBest for
copilot (interactive)Multi-turn conversations
copilot -p "..."Single-shot tasks

For quick questions or one-time file edits, -p keeps things snappy.


How to Run GitHub Copilot CLI with a Direct Prompt【-p Flag】
https://naonao-na.com/en/posts/github-copilot-cli-prompt-flag/
Author
[object Object]
Published at
2026-03-28