Pi CLI Cheatsheet - earendil Terminal Multi-Model Coding Agent

Pi is the earendil-works multi-model terminal coding agent, for developers who want to switch between several models quickly in the terminal, reference files with @file, and run prompts headlessly in bulk. It is lightweight and script friendly, made for embedding coding/QA tasks in workflows. This sheet covers install/login, interactive and headless modes, session management, and switching models mid-session.

AI CLI·23 commands·Last updated 2026-08-26
pipi-coding-agentearendilaicliagentCoding Agent

Install & Auth 5

npm install -g @earendil-works/pi-coding-agent
Install the Pi coding agent globally
pi
Start an interactive session in the project dir
export ANTHROPIC_API_KEY=sk-ant-...
Authenticate with an API key before launch
/login
Interactive OAuth login (Claude Pro/Max, ChatGPT Plus, Copilot)
/logout
Clear OAuth credentials

Interactive Sessions 4

pi @README.md "Summarize this"
Reference a file as context with @
pi @src/app.ts @src/app.test.ts "Review these together"
Reference multiple files at once
!npm run lint
Prefix with ! to run a shell command in-session
/new
Start a new session and clear context

Headless Mode & Scripts 7

pi -p "Summarize this codebase"
Run once non-interactively then exit
cat README.md | pi -p "Summarize this text"
Pipe content into Pi
pi -p @screenshot.png "What is in this image?"
Process an image in headless mode
pi --mode json
Emit JSON event stream for parsing
pi --mode rpc
Use stdin/stdout for process integration
pi --name "my task"
Set a session display name at launch
pi --session <id>
Open a specific session

Sessions & Models 7

pi -c
Continue the most recent session
pi -r
Browse and select a previous session
/model
Switch the model
/compact [prompt]
Manually compact context to free tokens
/fork
Fork a new session branch from a message
/clone
Duplicate the current session to a new file
/reload
Reload context files and extensions

Tips

  • Pi is multi-model: switch anytime with `/model` or Ctrl+L — use a cheap fast model for exploration and a stronger one for final implementation without losing session context.
  • `pi -p` headless mode with `--mode json` emits 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 `/compact` before 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