Skip to content

Scripting & CI

polyglot -p (or --print) runs a single prompt, prints the answer to stdout, and exits - no TUI.

Terminal window
polyglot -p "explain what src/agent/loop.ts does"
echo "summarize the README" | polyglot -p # prompt from stdin
polyglot -p --output-format json "list the tools" # machine-readable
  • --output-format text (default) streams the assistant’s reply to stdout. Tool activity goes to stderr, so a piped stdout stays clean.

  • --output-format json emits 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:

Terminal window
sid=$(polyglot -p --output-format json "start the analysis" | jq -r .session_id)
polyglot --resume "$sid" -p "now write it up as a report"

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.mode to auto (in settings.json or POLYGLOT_PERMISSION_MODE),
  • pass --permission-mode auto,
  • add allow rules for the specific tools/commands you trust,
  • or pass --allow-all to run every tool without prompting.
- 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-5

Consider --no-persist in CI so nothing is written to ~/.polyglot/ on the runner - see Running offline and Data handling.