Getting Started with Pi
BeginnerLast updated: Nov 2, 2026
$ pi –getting-started
Pi is an open-source terminal coding agent from earendil-works (originally created by Mario Zechner as pi-mono). It runs in your project directory, reads and edits files, executes shell commands, and streams everything through a fast TUI. This guide takes you from zero to a working first session.
Prerequisites
- Node.js with npm — Pi is distributed as an npm package. (Pi can also build standalone Bun-based binaries for releases, but the normal install path is npm.)
- A terminal that supports modern TUIs. See the official terminal setup notes if you use Windows Terminal, tmux, or an unusual emulator.
- An LLM account: either a supported subscription (Claude Pro/Max, ChatGPT Plus/Pro, GitHub Copilot, xAI, OpenRouter) or an API key for any supported provider.
Install
npm install -g --ignore-scripts @earendil-works/pi-coding-agent
The --ignore-scripts flag disables dependency lifecycle scripts during install; Pi does not need install scripts for normal npm installs. This is part of the project’s supply-chain hardening: direct dependencies are pinned and the published package ships a shrinkwrap file.
There is also a curl installer (which itself uses npm under the hood):
curl -fsSL https://pi.dev/install.sh | sh
Verify the install:
pi --version
If the install fails, three causes cover most first-time reports:
EACCESpermission errors writing to the global node_modules. Do not fix this withsudo— install a Node version manager (nvm, mise, fnm) sonpm install -gwrites inside your home directory, then reinstall.pi: command not foundafter a successful install. The global npmbindirectory is not on yourPATH(common with nvm after opening a new shell, or with a custom Node prefix) — add it, or reopen the shell.- Windows reports it cannot run
pi. npm installs api.cmdshim, not a bare binary; launchpi(the shim resolves it) rather than pointing scripts at the underlying file. The Windows setup guide covers the details.
First launch
Start Pi in the directory you want it to work on:
cd /path/to/project
pi
Pi operates on your current working directory and can modify files in it. There is no built-in permission popup system — Pi runs with your user’s permissions — so work on a git-tracked tree (or use a checkpointing extension) if you want easy rollback.
On startup, the TUI shows a header listing loaded context files, prompt templates, skills (the official pi-skills collection is a good first install), and extensions, then the message area and the editor where you type.
Authenticate
Pi supports two authentication styles.
Option 1: subscription login (OAuth)
Run /login inside Pi and pick a provider. Built-in subscription logins include:
- Claude Pro/Max
- ChatGPT Plus/Pro (Codex)
- GitHub Copilot
- xAI (Grok/X subscription)
- OpenRouter (mints an API key billed from your OpenRouter credits)
- Radius
Tokens are stored in ~/.pi/agent/auth.json and auto-refresh when expired. Use /logout to clear credentials.
Option 2: API key
Export an environment variable before launching, for example:
export ANTHROPIC_API_KEY=sk-ant-...
pi
Or run /login and choose an API-key provider to store the key in ~/.pi/agent/auth.json. Other common variables include OPENAI_API_KEY, GEMINI_API_KEY, DEEPSEEK_API_KEY, GROQ_API_KEY, XAI_API_KEY, and OPENROUTER_API_KEY. The full table — over 30 providers — is in the providers doc.
Your first session
Type a request and press Enter:
Summarize this repository and tell me how to run its checks.
By default Pi gives the model four tools: read, write, edit, and bash. Read-only tools grep, find, and ls can be enabled via tool options. The agent loops — model responds, calls tools, reads results, responds again — until the task is done; Core Concepts walks the loop and the four built-in tools in detail.
Things worth trying immediately:
- Reference files: type
@in the editor to fuzzy-search project files, or pass files on the command line:pi @README.md "Summarize this". - Run shell commands:
!npm run lintruns a command and sends its output to the model;!!commandruns it without feeding output back into context. - Paste images: Ctrl+V (Alt+V on Windows), or drag an image into a supported terminal.
- Switch models:
/modelor Ctrl+L; Shift+Tab cycles the thinking level; Ctrl+P cycles through your scoped models. - Queue messages while it works: Enter queues a steering message, Alt+Enter queues a follow-up, Escape aborts.
Non-interactive mode
For one-shot prompts and scripting:
pi -p "Summarize this codebase"
cat README.md | pi -p "Summarize this text"
pi -p @screenshot.png "What's in this image?"
--mode json emits JSON event lines; --mode rpc speaks an RPC protocol over stdin/stdout for process integration.
Where things live
All user state is under ~/.pi/agent/:
settings.json— global settings (project-level overrides go in.pi/settings.jsonin the repo)auth.json— OAuth tokens and API keyssessions/— saved sessions, organized by working directoryAGENTS.md— global instructions loaded into every sessionextensions/,skills/,themes/— auto-discovered resourcestrust.json— saved per-project trust decisionsmodels-store.json— cached provider model catalogs
When a project contains .pi/settings.json or project extensions, Pi asks whether to trust the folder before loading them. Save the decision with /trust.
Sessions under sessions/ are plain JSONL organized by working directory — resuming, forking, branching, and searching them is its own topic, covered in Sessions and history.
Updating
Pi can update itself:
pi update --self # update the pi CLI only
pi update --all # update pi and installed packages
The full upgrade-versus-update matrix — --extensions, --self --force reinstalls, rolling back to an older version, and what to do when a stale npm cache hides a newer release — lives in Installing and Updating Pi.
If you installed via npm, plain npm update -g @earendil-works/pi-coding-agent also works. To uninstall: npm uninstall -g @earendil-works/pi-coding-agent — note this leaves ~/.pi/agent/ (settings, credentials, sessions) intact.
Further reading
- Official quickstart — the source for this guide
- Using Pi — full slash-command and CLI reference
- Providers — every supported provider, env var, and auth key
- Settings — all
settings.jsonoptions - earendil-works/pi on GitHub