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
Summarize a file from the command line
copilot -p "Summarize what this file does: ./README.md"

# Run Copilot non-interactively with a prompt.

Explain a source file
copilot -p "Explain this file: ./complex.ts"

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

Pipe a prompt to Copilot
echo "Explain this file: ./complex.ts" | copilot

# Send prompt text over stdin.

Ask a CLI how-to question
copilot -p "In Git, how can I apply a commit from another branch"

# Get a concise terminal answer about a shell task.

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

# Use Copilot to plan work before making changes.

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

# Use Git context from the repo in a direct prompt.

## Context-rich prompting inside a session
Inject a file into the prompt context
@ README.md

# Reference a file inline inside the interactive UI.

Run a shell command without leaving Copilot
! git status

# Execute a local shell command directly from the session.

Edit the prompt in an external editor
Ctrl+G

# Open the current prompt in your configured editor.

Clear the screen
Ctrl+L

# Reset visual clutter during long sessions.

Cancel the current operation
Esc

# Stop the current task or prompt execution.

Exit the CLI
Ctrl+D

# Shut down the session from the keyboard.

## High-value workflows
Ask Copilot to fix a failing test
copilot -p "A test is failing after the last merge. Inspect the codebase, identify the likely cause, and propose the smallest safe fix."

# Describe the failure and let Copilot inspect the repo.

Scaffold a feature from the terminal
copilot -p "Add a health check endpoint to this app and explain which files need to change."

# Ask for a small feature implementation plan and changes.

Generate docs for a module
copilot -p "Document the public API and side effects of this module in concise Markdown."

# Ask Copilot to document unfamiliar code.

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

# Ask for a human-readable review of local modifications.

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

# Ask Copilot for an architecture tour.

Recommended next

No recommendations yet.