Pi CLI Cheatsheet - earendil Terminal Multi-Model Coding Agent
Pi is a multi-model coding agent for the terminal. What separates it from single-model CLIs is that you can change model mid-session without losing context: explore cheaply and quickly, then switch to a stronger model for the step that actually ships, which saves waiting time more than tokens. This sheet is organised into install and authentication, interactive sessions, headless mode and scripting, and session and model management. Reach for it when you want to wire coding tasks into CI or a shell pipeline, in which case the headless group is the one to read - -p with --mode json emitting structured events is the script-friendly shape. If you only want to wander through files in the terminal while it explains things, the @ references and slash commands in the interactive group are enough. One judgement matters more than the rest: context cost. Every turn after that is billed on the full conversation, so compacting before a large change is far cheaper than recovering afterwards.
Install & Auth 5
npm install -g @earendil-works/pi-coding-agentpiexport ANTHROPIC_API_KEY=sk-ant-.../login/logoutInteractive Sessions 4
pi @README.md "Summarize this"pi @src/app.ts @src/app.test.ts "Review these together"!npm run lint/newHeadless Mode & Scripts 7
pi -p "Summarize this codebase"cat README.md | pi -p "Summarize this text"pi -p @screenshot.png "What is in this image?"pi --mode jsonpi --mode rpcpi --name "my task"pi --session <id>Sessions & Models 7
pi -cpi -r/model/compact [prompt]/fork/clone/reloadTips
- Pi is multi-model: switch anytime with
/modelor Ctrl+L — use a cheap fast model for exploration and a stronger one for final implementation without losing session context. pi -pheadless mode with--mode jsonemits structured events, the de-facto standard for wiring into scripts and CI.@-referencing files is more accurate and cheaper than pasting contents into the prompt; run/compactbefore big changes to free tokens.
FAQ
Which model providers does Pi support?
Pi normalizes OpenAI, Anthropic, and Google behind one API layer. It supports subscription login for Claude Pro/Max, ChatGPT Plus/Pro (Codex), and GitHub Copilot, and also connects directly via ANTHROPIC_API_KEY, OPENAI_API_KEY, GEMINI_API_KEY, and similar keys.
What is the difference between pi -p and the interactive session?
-p is a non-interactive one-shot run: it executes once, prints the result, and exits — ideal for scripts and pipelines. The interactive pi suits exploratory development with multi-turn conversation and file edits.
Official References
Each command links to its official documentation below, so you can verify the latest usage and read deeper.
Maintained by LaoHand
Publicly updated on Aug 26, 2026, continuously proofread against official docs.
Contact Us
Wrong command or description? Send us corrections, business inquiries or product feedback by email.
Contact Us