Copilot CLI: Prompting, Interactive Use, and Core Workflows

Commands and prompt patterns for interactive use, one-shot prompts, file-aware context, and common terminal Copilot workflows.

View
StandardDetailedCompact
Export
Copy the compact sheet, download it, or print it.
Download
`D` dense toggle · `C` copy all

Interactive and one-shot prompts

Use Copilot as a terminal chat or as a single-command assistant.

Summarize a file from the command line

Run Copilot non-interactively with a prompt.

bashANYcopilotpromptnon-interactive
bash
copilot -p "Summarize what this file does: ./README.md"

The `-p` flag lets you run one prompt and exit without opening the full interface.

Explain a source file

Ask Copilot to explain a code file directly from the terminal.

bashANYcopilotexplaincode
bash
copilot -p "Explain this file: ./complex.ts"

A strong workflow for quick code comprehension.

Pipe a prompt to Copilot

Send prompt text over stdin.

bashANYcopilotstdinautomation
bash
echo "Explain this file: ./complex.ts" | copilot

Useful in scripts or shell pipelines. If you also pass `-p`, the piped input is ignored.

Ask a CLI how-to question

Get a concise terminal answer about a shell task.

bashANYcopilotgitexamples
bash
copilot -p "In Git, how can I apply a commit from another branch"

This is a high-traffic style query for a cheatsheet audience.

Ask for a refactor plan

Use Copilot to plan work before making changes.

bashANYcopilotplanningrefactor
bash
copilot -p "Plan a safe refactor of this module and list the files you would inspect first."

Works well before delegating edits in a larger repository.

Summarize recent commits

Use Git context from the repo in a direct prompt.

bashANYcopilotgitsummary
bash
copilot -p "Summarize the intent of the last 10 commits in this repository."

Helpful for release notes, standups, and onboarding.

Context-rich prompting inside a session

Use file injection and local shell escapes to work faster in interactive mode.

Inject a file into the prompt context

Reference a file inline inside the interactive UI.

textANYcopilotcontextfile
text
@ README.md

Type `@` followed by a file name to include that file's contents in the current prompt context.

Run a shell command without leaving Copilot

Execute a local shell command directly from the session.

textANYcopilotshellshortcut
text
! git status

Useful for checking repo state while staying inside the interactive workflow.

Edit the prompt in an external editor

Open the current prompt in your configured editor.

textANYcopilotshortcuteditor
text
Ctrl+G

Great for long prompts, multi-step instructions, or reusable templates.

Clear the screen

Reset visual clutter during long sessions.

textANYcopilotshortcutscreen
text
Ctrl+L

Handy when a session has accumulated a lot of scrollback.

Cancel the current operation

Stop the current task or prompt execution.

textANYcopilotshortcutcancel
text
Esc

A fast way to back out when Copilot starts the wrong action.

Exit the CLI

Shut down the session from the keyboard.

textANYcopilotshortcutexit
text
Ctrl+D

Use twice-pressed `Ctrl+C` or `Ctrl+D` depending on the situation and shell.

High-value workflows

Practical prompt patterns for code understanding, debugging, and repo work.

Ask Copilot to fix a failing test

Describe the failure and let Copilot inspect the repo.

bashANYcopilotdebuggingtests
bash
copilot -p "A test is failing after the last merge. Inspect the codebase, identify the likely cause, and propose the smallest safe fix."

A practical starting point for debugging flows.

Scaffold a feature from the terminal

Ask for a small feature implementation plan and changes.

bashANYcopilotfeaturescaffold
bash
copilot -p "Add a health check endpoint to this app and explain which files need to change."

Useful before moving into a longer interactive session.

Generate docs for a module

Ask Copilot to document unfamiliar code.

bashANYcopilotdocsapi
bash
copilot -p "Document the public API and side effects of this module in concise Markdown."

Strong for maintainability and SEO-oriented docs generation.

Review current repository changes

Ask for a human-readable review of local modifications.

bashANYcopilotreviewdiff
bash
copilot -p "Review the changes in this working tree and flag risky edits or missing tests."

Good before committing or opening a pull request.

Onboard to an unfamiliar repository

Ask Copilot for an architecture tour.

bashANYcopilotonboardingarchitecture
bash
copilot -p "Give me a quick onboarding guide to this repository: main entry points, architecture, setup commands, and important directories."

A high-value workflow for new team members.

Recommended next

No recommendations yet.