Best AI Tools

Troubleshooting guide · GitHub Docs checked Nov 3, 2026

Capture Copilot CLI output without brittle text filters

For scripted Copilot CLI prompts, use the documented silent flag for plain response text, or JSONL output when a parser needs structured events. Keep stdout, stderr, and the command exit status separate; do not strip terminal glyphs with guessed patterns.

How do I save only a Copilot CLI response to a file?

For a noninteractive prompt, use the documented `-s` / `--silent` flag: `copilot -p 'Summarize this change' -s > review.txt 2>copilot.stderr.log`. GitHub describes `-s` as suppressing stats and decoration so stdout contains only the agent response. Redirect stderr separately when you want diagnostics outside the saved answer. Check `copilot help` if the installed CLI version differs from the current documentation.

Why does `--no-color` still leave spinner or tool text in my output?

Color control and quiet output are different. Issue #3397 reported spinner glyphs and tool annotations even with `--no-color` in Copilot CLI 1.0.49. A maintainer pointed to `--silent`, and the reporter confirmed it fixed their CI capture. For a current scripted `-p` run, use the documented silent option instead of filtering guessed glyphs or line prefixes; do not assume every output format or CLI release behaves identically.

Should I use silent text or JSON output for a pipeline?

Use `-s` when the next step expects ordinary response text. Use `--output-format=json` when the script needs structured events: GitHub documents this format as JSONL, with one JSON object per line, rather than one JSON document for the entire run. Test the fields your parser needs against the installed CLI and keep parser errors separate from Copilot's exit status.

How do I preserve the Copilot exit status when piping to `tee`?

In Bash, enable `pipefail` and read Copilot's pipeline status immediately, before another command replaces the `PIPESTATUS` array: `set -o pipefail copilot -p 'Summarize this change' -s 2>copilot.stderr.log | tee review.txt status=${PIPESTATUS[0]} if [ "$status" -ne 0 ]; then exit "$status"; fi` GitHub documents that a programmatic prompt exits with a nonzero status if interrupted. `pipefail` also makes a failed pipeline visible to the shell; if you need to distinguish a failing `tee` or parser from Copilot itself, capture and check each pipeline status separately. This is Bash syntax, not a portable POSIX-shell recipe.

Does a successful exit status mean the response passed my review?

No. The exit status is process-level information, not a quality check for generated text. Treat the response as untrusted input, validate it against the task's criteria, and keep any review or approval step your workflow requires. Do not infer success by searching stdout for a phrase when the CLI exposes a process status.

Does issue #3397 show that current Copilot CLI output is broken?

No. The issue was opened against version 1.0.49 in May 2026. A maintainer pointed the author to `--silent` and JSON output options; the author confirmed `--silent` resolved that CI capture problem and closed the report. It is useful evidence for the flag's purpose in that reported setup, not evidence of a current general defect or a stable contract for every version.

What should I check if the capture is still noisy or the job reports success incorrectly?

Record `copilot --version`, the exact command, shell and operating system, whether input comes from `-p` or stdin, and which stream is redirected. Try the documented `-s` option on a minimal prompt, capture stderr to its own file, and inspect the shell's actual command status. For a parser, test a small JSONL sample and validate each line rather than applying text substitutions to terminal output. Avoid publishing session logs or transcripts before removing sensitive repository details and tokens.

Sources

Methodology and limitations

This guide follows GitHub's current programmatic-use and CLI reference documentation, checked November 3, 2026. Copilot CLI issue #3397 describes a May 2026 report from version 1.0.49; a maintainer pointed to --silent and --output-format json, and the reporter confirmed --silent fixed their CI capture. That confirms the reported setup at that time, not every shell, CLI release, or downstream parser. Examples below use documented flags and common Bash behavior; inspect `copilot help` on the installed version before relying on an automation contract.

Affiliate placeholder {{AFF_TOOLNAME}} — referral link not configured.