Scripting & CI
polyglot -p (or --print) runs a single prompt, prints the answer to stdout, and
exits - no TUI.
polyglot -p "explain what src/agent/loop.ts does"echo "summarize the README" | polyglot -p # prompt from stdinpolyglot -p --output-format json "list the tools" # machine-readableOutput
Section titled “Output”-
--output-format text(default) streams the assistant’s reply to stdout. Tool activity goes to stderr, so a piped stdout stays clean. -
--output-format jsonemits a single object instead:{ "result": "...", "session_id": "...", "is_error": false, "stop_reason": "done", "persisted": true }
The session id is also written to stderr as session: <id>, so runs can be chained:
sid=$(polyglot -p --output-format json "start the analysis" | jq -r .session_id)polyglot --resume "$sid" -p "now write it up as a report"Permissions in -p mode
Section titled “Permissions in -p mode”There’s no TTY to show approval prompts, so any write / execute / network tool that would need approval is denied, and the model is told so. For automation, choose one:
- set
permissions.modetoauto(insettings.jsonorPOLYGLOT_PERMISSION_MODE), - pass
--permission-mode auto, - add
allowrules for the specific tools/commands you trust, - or pass
--allow-allto run every tool without prompting.
CI example
Section titled “CI example”- run: npm install -g @usepolyglot/cli- run: polyglot -p --allow-all --output-format json "review the diff in this PR for obvious bugs" > review.json env: POLYGLOT_PROVIDER: anthropic ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} POLYGLOT_MODEL: claude-sonnet-4-5Consider --no-persist in CI so nothing is written to ~/.polyglot/ on the runner -
see Running offline and
Data handling.