AI / GitHub Copilot CLI Fundamentals Interview Questions
How do you start an interactive Copilot CLI session and what are the two main usage modes?
Copilot CLI has two usage modes: an interactive session (the default) and a non-interactive / programmatic mode using the -p flag.
# Mode 1: Interactive session cd my-project copilot # → trust prompt → REPL-style interface opens # Type prompts, use slash commands, use keyboard shortcuts # Mode 2: Non-interactive / single prompt copilot -p "How do I undo a git commit without losing changes?" # → prints the answer and exits # Mode 2 with silent output (response only, no extra info) copilot -p "Explain git rebase" -s # Use -p in scripts for AI-powered automation SUMMARY=$(copilot -p "Summarise the changes in git diff HEAD~1" -s) echo "$SUMMARY"
| Mode | Command | Use case |
|---|---|---|
| Interactive | copilot | Ongoing coding sessions, multi-turn conversations, task execution |
| Non-interactive | copilot -p "prompt" | Scripts, automation, one-off questions, CI/CD integration |
| Silent non-interactive | copilot -p "prompt" -s | Capture only the AI response in a shell variable |
Inside an interactive session: you can type natural language prompts, use slash commands (e.g. /help, /model, /pr), use keyboard shortcuts (e.g. Shift+Tab to cycle between modes), and browse GitHub tabs - all without leaving the terminal.
More Related questions...