@fleetagent/pi-coding-agent
v0.2.14
Published
Coding agent CLI with read, bash, edit, write tools and session management
Downloads
2,239
Readme
New issues and PRs from new contributors are auto-closed by default. Maintainers review auto-closed issues daily. See CONTRIBUTING.md.
Pi is a minimal terminal coding harness. Adapt pi to your workflows, not the other way around, without having to fork and modify pi internals. Extend it with TypeScript Extensions, Skills, Rules, Prompt Templates, and Themes. Put your extensions, skills, rules, prompt templates, and themes in Pi Packages and share them with others via npm or git.
Pi ships with powerful defaults and optional isolated subagent delegation, while leaving broader workflows such as plan mode to extensions and packages.
Pi runs in four modes: interactive, print or JSON, RPC for process integration, and an SDK for embedding in your own apps. See openclaw/openclaw for a real-world SDK integration.
Share your OSS coding agent sessions
If you use pi for open source work, please share your coding agent sessions.
Public OSS session data helps improve models, prompts, tools, and evaluations using real development workflows.
For the full explanation, see this post on X.
To publish sessions, use badlogic/pi-share-hf. Read its README.md for setup instructions. All you need is a Hugging Face account, the Hugging Face CLI, and pi-share-hf.
You can also watch this video, where I show how I publish my pi-mono sessions.
I regularly publish my own pi-mono work sessions here:
Table of Contents
- Quick Start
- Providers & Models
- Interactive Mode
- Sessions
- Settings
- Language Servers
- Remote Daemon
- Docker Sandbox
- Customization
- Programmatic Usage
- Philosophy
- CLI Reference
Quick Start
npm install -g --ignore-scripts @fleetagent/pi-coding-agent--ignore-scripts disables dependency lifecycle scripts during install. Pi does not require install scripts for normal npm installs.
Installer alternative:
curl -fsSL https://pi.dev/install.sh | shAuthenticate with an API key:
export ANTHROPIC_API_KEY=sk-ant-...
piOr use your existing subscription:
pi
/login # Then select providerThen just talk to pi. By default, pi gives the model file and shell tools. Enable the built-in subagent tool family through /settings or enableSubagents in settings.json. LSP tools require both an external language server configuration and --enable-lsp-tools (or enableLspTools in settings.json); they are off by default. The model uses enabled tools to fulfill your requests. Add capabilities via skills, prompt templates, extensions, or pi packages.
Platform notes: Windows | Termux (Android) | tmux | Terminal setup | Shell aliases
Providers & Models
For each built-in provider, pi maintains a list of tool-capable models, updated with every release. Authenticate via subscription (/login) or API key, then select any model from that provider via /model (or Ctrl+L).
Subscriptions:
- Anthropic Claude Pro/Max
- OpenAI ChatGPT Plus/Pro (Codex)
- GitHub Copilot
API keys:
- Anthropic
- OpenAI
- Azure OpenAI
- DeepSeek
- Google Gemini
- Google Vertex
- Amazon Bedrock
- Mistral
- Groq
- Cerebras
- Cloudflare AI Gateway
- Cloudflare Workers AI
- xAI
- OpenRouter
- Vercel AI Gateway
- ZAI
- OpenCode Zen
- OpenCode Go
- Hugging Face
- Fireworks
- Together AI
- Kimi For Coding
- MiniMax
- Xiaomi MiMo
- Xiaomi MiMo Token Plan (China)
- Xiaomi MiMo Token Plan (Amsterdam)
- Xiaomi MiMo Token Plan (Singapore)
See docs/providers.md for detailed setup instructions.
Custom providers & models: Add providers via ~/.pi/agent/models.json if they speak a supported API (OpenAI, Anthropic, Google). For custom APIs or OAuth, use extensions. See docs/models.md and docs/custom-provider.md.
Interactive Mode
The interface from top to bottom:
- Startup header - Shows shortcuts (
/hotkeysfor all), loaded AGENTS.md files, prompt templates, skills, and extensions - Messages - Your messages, assistant responses, tool calls and results, notifications, errors, and extension UI
- Editor - Where you type; border color indicates thinking level
- Footer - Working directory, session name, total token/cache usage, cost, context usage, current model
The editor can be temporarily replaced by other UI, like built-in /settings or custom UI from extensions (e.g., a Q&A tool that lets the user answer model questions in a structured format). Extensions can also replace the editor, add widgets above/below it, a status line, custom footer, or overlays.
Editor
| Feature | How |
|---------|-----|
| File reference | Type @ to fuzzy-search project files |
| Path completion | Tab to complete paths |
| Multi-line | Shift+Enter (or Ctrl+Enter on Windows Terminal) |
| Clipboard | Ctrl+V to paste an image or text (Alt+V on Windows), or drag images onto terminal |
| Bash commands | !command runs and sends output to LLM, !!command runs without sending |
Standard editing keybindings for delete word, undo, etc. See docs/keybindings.md.
Commands
Type / in the editor to trigger commands. Extensions can register custom commands, skills are available as /skill:name, and prompt templates expand via /templatename.
| Command | Description |
|---------|-------------|
| /login, /logout | OAuth authentication |
| /model | Switch models |
| /scoped-models | Enable/disable models for Ctrl+P cycling |
| /settings | Thinking level, theme, message delivery, transport |
| /resume | Pick from previous sessions |
| /new | Start a new session |
| /name <name> | Set session display name |
| /session | Show session info (file, ID, messages, tokens, cost) |
| /tree | Jump to any point in the session and continue from there |
| /fork | Create a new session from a previous user message |
| /clone | Duplicate the current active branch into a new session |
| /compact [prompt] | Manually compact context, optional custom instructions |
| /context-compression [on\|off] | Show or change agent-initiated compression for this session (default: off) |
| /compress-detection [on\|off] | Show or change background detection for this session (default: off); enabling also enables compression |
| /compress-detection-model [provider/model-id\|clear] | Choose a detector model and enable detection for this session, or clear it |
| /copy | Copy last assistant message to clipboard |
| /export [file] | Export session to HTML file |
| /share | Upload as private GitHub gist with shareable HTML link |
| /reload | Reload keybindings, hooks, extensions, skills, rules, prompts, and context files (themes hot-reload automatically) |
| /hotkeys | Show all keyboard shortcuts |
| /changelog | Display version history |
| /quit | Quit pi |
Keyboard Shortcuts
See /hotkeys for the full list. Customize via ~/.pi/agent/keybindings.json. See docs/keybindings.md.
Commonly used:
| Key | Action |
|-----|--------|
| Ctrl+C | Clear editor |
| Ctrl+C twice | Quit |
| Escape | Cancel/abort |
| Escape twice | Open /tree |
| Ctrl+L | Open model selector |
| Ctrl+P / Shift+Ctrl+P | Cycle scoped models forward/backward |
| Shift+Tab | Cycle thinking level |
| Ctrl+O | Collapse/expand tool output |
| Ctrl+T | Collapse/expand thinking blocks |
| Ctrl+X | Copy the last assistant message |
Message Queue
Submit messages while the agent is working:
- Enter queues a steering message, delivered after the current assistant turn finishes executing its tool calls
- Alt+Enter queues a follow-up message, delivered only after the agent finishes all work
- Escape aborts and restores queued messages to editor
- Alt+Up retrieves queued messages back to editor
On Windows Terminal, Alt+Enter is fullscreen by default. Remap it in docs/terminal-setup.md so pi can receive the follow-up shortcut.
Configure delivery in settings: steeringMode and followUpMode can be "one-at-a-time" (default, waits for response) or "all" (delivers all queued at once). transport selects provider transport preference ("sse", "websocket", or "auto") for providers that support multiple transports.
Sessions
Sessions are stored as JSONL files with a tree structure. Each entry has an id and parentId, enabling in-place branching without creating new files. See docs/session-format.md for file format.
Management
Sessions auto-save to ~/.pi/agent/sessions/ organized by working directory.
pi -c # Continue most recent session
pi -r # Browse and select from past sessions
pi --no-session # Ephemeral mode (don't save)
pi --session <path|id> # Use specific session file or ID
pi --fork <path|id> # Fork specific session file or ID into a new sessionUse /session in interactive mode to see the current session ID before reusing it with --session <id> or --fork <id>.
Branching
/tree - Navigate the session tree in-place. Select any previous point, continue from there, and switch between branches. All history preserved in a single file.
- Search by typing, fold/unfold and jump between branches with Ctrl+←/Ctrl+→ or Alt+←/Alt+→, page with ←/→
- Filter modes (Ctrl+O): default → no-tools → user-only → labeled-only → all
- Press Ctrl+X to copy the selected entry
- Press Shift+L to label entries as bookmarks and Shift+T to toggle label timestamps
/fork - Create a new session file from a previous user message on the active branch. Opens a selector, copies the active path up to that point, and places the selected prompt in the editor for modification.
/clone - Duplicate the current active branch into a new session file at the current position. The new session keeps the full active-path history and opens with an empty editor.
--fork <path|id> - Fork an existing session file or partial session UUID directly from the CLI. This copies the full source session into a new session file in the current project.
Compaction
Long sessions can exhaust context windows. Compaction summarizes older messages while keeping recent ones.
Manual: /compact or /compact <custom instructions>
Automatic: Enabled by default. Triggers on context overflow (recovers and retries) or when approaching the limit (proactive). Configure via /settings or settings.json.
Compaction is lossy, but the full history remains in the JSONL file. The model can use session_search to locate finalized entries omitted from context and session_entry_get to retrieve one exact model-visible entry; /tree remains available for interactive navigation. The compress_context tool uses context metadata entry IDs to replace a tail—or an earlier bounded range via endEntryId—with a summary while retaining later messages and archiving the originals on another branch. Customize compaction behavior via extensions. See docs/compaction.md for internals.
Settings
Use /settings to modify common options, or edit JSON files directly:
| Location | Scope |
|----------|-------|
| ~/.pi/agent/settings.json | Global (all projects) |
| .pi/settings.json | Project (overrides global) |
See docs/settings.md for all options.
Telemetry and update checks
Pi has two separate startup features:
- Update check: fetches npm metadata for
@fleetagent/pi-coding-agentto check whether a newer Pi version exists. Disable it withPI_SKIP_VERSION_CHECK=1. Disabling update checks only turns off this check. - Install/update telemetry: after first install or a changelog-detected update, sends an anonymous version ping to
https://pi.dev/api/report-install. Opt out by settingenableInstallTelemetrytofalseinsettings.json, or by settingPI_TELEMETRY=0. This does not disable update checks; Pi may still contact the npm registry for the latest version unless update checks are disabled or offline mode is enabled.
Use --offline or PI_OFFLINE=1 to disable all startup network operations described here, including update checks, package update checks, and install/update telemetry.
Language Servers
Pi supports explicitly configured managed stdio servers, attached TCP/Unix socket/named-pipe endpoints, and host-provided connections with managed or attached semantics. It does not bundle or automatically select a language server. Untrusted project settings cannot add or positively activate transports; malformed or unreadable LSP sources fail closed without terminating Pi, and --no-lsp is the per-invocation recovery path. See docs/lsp.md for copyable configurations, remote path mapping, project trust, workspace roots, lifecycle ownership, SDK/extension APIs, migration, and troubleshooting.
Remote Daemon
pi --daemon starts an integrated remote workspace daemon from the @fleetagent/pi-coding-agent package. The local Pi process remains the orchestrator for model calls, credentials, sessions, prompts, extensions, subagents, RPC, and UI; the daemon owns one confined workspace for canonical tools, project resources, file transfer, optional process execution, and optional colocated LSP.
Start a daemon:
PI_DAEMON_TOKEN='long-random-token' pi --daemon --daemon-cwd /workspace --daemon-port 8787Connect from a local Pi process:
PI_REMOTE_TOKEN='long-random-token' pi --remote ws://127.0.0.1:8787/pi/workspaceThe retired @fleetagent/pi-daemon package and pi-daemon binary are not supported. See docs/daemon.md for topology, security, configuration, Docker, LSP/resources/extensions behavior, troubleshooting, and migration.
Docker Sandbox
Interactive /sandbox is the sole command for inspecting, connecting, clearing, starting, listing, and stopping workspace tool backends. It supports existing sandbox daemons and Pi-owned Docker containers. The command is user-only and appears in slash-command completion, but is hidden from model-visible command catalogs, tools, prompts, skills, and rules. Local Pi keeps model/session/UI orchestration while workspace tools/resources use the selected backend. See docs/sandbox.md for command syntax, image configuration, local base-image builds, troubleshooting, and security limits.
Context Files
Pi loads AGENTS.md (or CLAUDE.md) at startup from:
~/.pi/agent/AGENTS.md(global)- Parent directories (walking up from cwd)
- Current directory
If a directory contains AGENTS.override.md, Pi loads it instead of AGENTS.md or CLAUDE.md from that directory. Context files from other directories still layer normally, including when project instructions come from a daemon tool backend.
Use for project instructions, conventions, common commands. All selected files are concatenated.
Disable context file loading with --no-context-files (or -nc).
System Prompt
Replace the default system prompt with .pi/SYSTEM.md (project) or ~/.pi/agent/SYSTEM.md (global). Append without replacing via APPEND_SYSTEM.md.
Customization
Prompt Templates
Reusable prompts as Markdown files. Type /name to expand.
<!-- ~/.pi/agent/prompts/review.md -->
Review this code for bugs, security issues, and performance problems.
Focus on: {{focus}}Place in ~/.pi/agent/prompts/, .pi/prompts/, or a pi package to share with others. See docs/prompt-templates.md.
Skills
On-demand capability packages following the Agent Skills standard. Invoke via /skill:name or let the agent load them automatically.
<!-- ~/.pi/agent/skills/my-skill/SKILL.md -->
# My Skill
Use this skill when the user asks about X.
## Steps
1. Do this
2. Then thatPlace in ~/.pi/agent/skills/, ~/.agents/skills/, .pi/skills/, or .agents/skills/ (from cwd up through parent directories) or a pi package to share with others. See docs/skills.md.
Rules
On-demand mandatory constraints and policies. Invoke via /rule:name or let the agent load them automatically when the task or files match the rule description.
<!-- ~/.pi/agent/rules/typescript/RULES.md -->
---
name: typescript
description: Mandatory TypeScript rules. Load before editing *.ts or *.tsx files.
---
# TypeScript Rules
- No `any` unless absolutely necessary.
- Use top-level imports only.Place in ~/.pi/agent/rules/, ~/.agents/rules/, .pi/rules/, or .agents/rules/ (from cwd up through parent directories) or a pi package to share with others. See docs/rules.md.
Extensions
TypeScript modules that extend pi with custom tools, commands, keyboard shortcuts, event handlers, and UI components.
export default function (pi: ExtensionAPI) {
pi.registerTool({ name: "deploy", ... });
pi.registerCommand("stats", { ... });
pi.on("tool_call", async (event, ctx) => { ... });
}The default export can also be async. pi waits for async extension factories before startup continues, which is useful for one-time initialization such as fetching remote model lists before calling pi.registerProvider().
What's possible:
- Custom tools (or replace built-in tools entirely)
- Sub-agents and plan mode
- Custom compaction and summarization
- Permission gates and path protection
- Custom editors and UI components
- Status lines, headers, footers
- Git checkpointing and auto-commit
- Remote daemon and sandbox execution
- MCP server integration
- Make pi look like Claude Code
- Games while waiting (yes, Doom runs)
- ...anything you can dream up
Place in ~/.pi/agent/extensions/, .pi/extensions/, or a pi package to share with others. See docs/extensions.md and examples/extensions/.
Themes
Built-in: dark, light. Themes hot-reload: modify the active theme file and pi immediately applies changes.
Place in ~/.pi/agent/themes/, .pi/themes/, or a pi package to share with others. See docs/themes.md.
Pi Packages
Bundle and share extensions, skills, rules, prompts, and themes via npm or git. Find packages on npmjs.com or Discord.
Security: Pi packages run with full system access. Extensions execute arbitrary code, and skills can instruct the model to perform any action including running executables. Review source code before installing third-party packages.
pi install npm:@foo/pi-tools
pi install npm:@foo/[email protected] # pinned version
pi install git:github.com/user/repo
pi install git:github.com/user/repo@v1 # tag or commit
pi install git:[email protected]:user/repo
pi install git:[email protected]:user/repo@v1 # tag or commit
pi install https://github.com/user/repo
pi install https://github.com/user/repo@v1 # tag or commit
pi install ssh://[email protected]/user/repo
pi install ssh://[email protected]/user/repo@v1 # tag or commit
pi remove npm:@foo/pi-tools
pi uninstall npm:@foo/pi-tools # alias for remove
pi list
pi update # update pi and packages (skips pinned packages)
pi update --extensions # update packages only
pi update --self # update pi only
pi update --self --force # reinstall pi even if current
pi update npm:@foo/pi-tools # update one package
pi config # enable/disable extensions, skills, rules, prompts, themesPackages install to ~/.pi/agent/git/ (git) or ~/.pi/agent/npm/ (npm). Use -l for project-local installs (.pi/git/, .pi/npm/). Git @ref values are pinned tags or commits; pinned packages are skipped by pi update, so use pi install git:host/user/repo@new-ref to move an existing package to a new ref. Git packages install dependencies with npm install --omit=dev by default, so runtime deps must be listed under dependencies; when npmCommand is configured, git packages use plain install for compatibility with wrappers. If you use a Node version manager and want package installs to reuse a stable npm context, set npmCommand in settings.json, for example ["mise", "exec", "node@20", "--", "npm"].
Create a package by adding a pi key to package.json:
{
"name": "my-pi-package",
"keywords": ["pi-package"],
"pi": {
"extensions": ["./extensions"],
"skills": ["./skills"],
"rules": ["./rules"],
"prompts": ["./prompts"],
"themes": ["./themes"]
}
}Without a pi manifest, pi auto-discovers from conventional directories (extensions/, skills/, rules/, prompts/, themes/).
See docs/packages.md.
Programmatic Usage
SDK
import { AuthStorage, InMemorySessionManager, ModelRegistry, PiAgent } from "@fleetagent/pi-coding-agent";
const authStorage = AuthStorage.create();
const modelRegistry = ModelRegistry.create(authStorage);
const pi = await PiAgent.create({
sessionManager: new InMemorySessionManager(),
authStorage,
modelRegistry,
});
const session = await pi.createAgentSession();
await session.prompt("What files are in the current directory?");
await pi.dispose();For advanced multi-session flows, use PiAgent methods such as newSession(), switchSession(), fork(), and importFromJsonl().
See docs/sdk.md, docs/lsp.md, and examples/sdk/.
RPC Mode
For non-Node.js integrations, use RPC mode over stdin/stdout:
pi --mode rpcRPC mode uses strict LF-delimited JSONL framing. Clients must split records on \n only. Do not use generic line readers like Node readline, which also split on Unicode separators inside JSON payloads.
See docs/rpc.md for the protocol.
Philosophy
Pi is aggressively extensible so it doesn't have to dictate your workflow. Features that other tools bake in can be built with extensions, skills, or installed from third-party pi packages. This keeps the core minimal while letting you shape pi to fit how you work.
No MCP. Build CLI tools with READMEs (see Skills), or build an extension that adds MCP support. Why?
Focused sub-agents. Enable the built-in subagent tool family through /settings or enableSubagents in settings.json to delegate single, parallel, or chained tasks to fresh in-memory agent sessions with isolated conversations and shared authentication/model services. The parent can define each task's persona, response format, model, and tools dynamically or use bundled and user-defined presets. Extensions and packages can still provide alternative orchestration models.
No permission popups. Run in a container, or build your own confirmation flow with extensions inline with your environment and security requirements.
No plan mode. Write plans to files, or build it with extensions, or install a package.
No built-in to-dos. They confuse models. Use a TODO.md file, or build your own with extensions.
No background bash. Use tmux. Full observability, direct interaction.
Read the blog post for the full rationale.
CLI Reference
pi [options] [@files...] [messages...]Package Commands
pi install <source> [-l] # Install package, -l for project-local
pi remove <source> [-l] # Remove package
pi uninstall <source> [-l] # Alias for remove
pi update [source|self|pi] # Update pi and packages (skips pinned packages)
pi update --extensions # Update packages only
pi update --self # Update pi only
pi update --self --force # Reinstall pi even if current
pi update --extension <src> # Update one package
pi list # List installed packages
pi config # Enable/disable package resourcesModes
| Flag | Description |
|------|-------------|
| (default) | Interactive mode |
| -p, --print | Print response and exit |
| --mode json | Output all events as JSON lines (see docs/json.md) |
| --mode rpc | RPC mode for process integration (see docs/rpc.md) |
| --export <in> [out] | Export session to HTML |
In print mode, pi also reads piped stdin and merges it into the initial prompt:
cat README.md | pi -p "Summarize this text"Model Options
| Option | Description |
|--------|-------------|
| --provider <name> | Provider (anthropic, openai, google, etc.) |
| --model <pattern> | Model pattern or ID (supports provider/id and optional :<thinking>) |
| --api-key <key> | API key (overrides env vars) |
| --thinking <level> | off, minimal, low, medium, high, xhigh |
| --models <patterns> | Comma-separated patterns for Ctrl+P cycling |
| --list-models [search] | List available models |
Session Options
| Option | Description |
|--------|-------------|
| -c, --continue | Continue most recent session |
| -r, --resume | Browse and select session |
| --session <path\|id> | Use specific session file or partial UUID |
| --fork <path\|id> | Fork specific session file or partial UUID into a new session |
| --session-dir <dir> | Custom session storage directory |
| --no-session | Ephemeral mode (don't save) |
| --lsp-config <file> | Load an external LSP layer; the file argument is startup-cwd-relative, while paths declared inside use the file's directory |
| --no-lsp | Disable LSP for this invocation, including recovery from malformed lower-precedence LSP sources |
Tool Options
| Option | Description |
|--------|-------------|
| --tools <list>, -t <list> | Allowlist specific tool names across built-in, extension, and custom tools |
| --no-builtin-tools, -nbt | Disable built-in tools by default but keep extension/custom tools enabled |
| --no-tools, -nt | Disable all tools by default |
| --enable-lsp-tools | Expose configured lsp_* tools by default |
| --remote <url> | Run built-in workspace tools through a pi --daemon WebSocket backend |
| --remote-deferred | Start with a deferred daemon backend and connect later with /sandbox --attach <ws://url> |
| --remote-cwd <path> | Stable daemon workspace cwd for deferred remote mode |
| --daemon | Start the integrated remote workspace daemon instead of a normal Pi session |
Available built-in tools: read, bash, edit, write, grep, find, ls, websearch, session_search, session_entry_get, compress_context, subagent, subagent_runs, create_subagent, and—when externally configured—lsp_diagnostics, lsp_hover, lsp_definition, lsp_references, lsp_rename, and lsp_code_actions. By default read, bash, edit, write, websearch, session_search, and session_entry_get are active. Context compression is opt-in via /context-compression on, PI_CONTEXT_COMPRESSION=1, or an explicit --tools allowlist. Background detection is separately opt-in via /compress-detection on or PI_CONTEXT_COMPRESSION_DETECTION=1 and requires a configured detector model. Subagent and LSP tools require separate opt-ins (enableSubagents and enableLspTools/--enable-lsp-tools respectively), or an explicit --tools allowlist. Explicit allowlists may select any subset, while --no-tools and --no-builtin-tools remain authoritative.
Resource Options
| Option | Description |
|--------|-------------|
| -e, --extension <source> | Load extension from path, npm, or git (repeatable) |
| --no-extensions | Disable extension discovery |
| --skill <path> | Load skill (repeatable) |
| --no-skills | Disable skill discovery |
| --rule <path> | Load rule (repeatable) |
| --no-rules | Disable rule discovery |
| --prompt-template <path> | Load prompt template (repeatable) |
| --no-prompt-templates | Disable prompt template discovery |
| --theme <path> | Load theme (repeatable) |
| --no-themes | Disable theme discovery |
| --no-context-files, -nc | Disable AGENTS.override.md, AGENTS.md, and CLAUDE.md context file discovery |
Combine --no-* with explicit flags to load exactly what you need, ignoring settings.json (e.g., --no-extensions -e ./my-ext.ts).
Other Options
| Option | Description |
|--------|-------------|
| --system-prompt <text> | Replace default prompt (context files and skills still appended) |
| --append-system-prompt <text> | Append to system prompt |
| --tui-mode <mode> | TUI mode: regular (default) or experimental fullscreen |
| --verbose | Force verbose startup |
| -h, --help | Show help |
| -v, --version | Show version |
fullscreen keeps the transcript in an application-owned viewport above a fixed status/editor/footer dock. regular retains the main screen and terminal-owned scrollback. Set TUI mode in /settings for future sessions or use --tui-mode for one startup.
File Arguments
Prefix files with @ to include in the message:
pi @prompt.md "Answer this"
pi -p @screenshot.png "What's in this image?"
pi @code.ts @test.ts "Review these files"Examples
# Interactive with initial prompt
pi "List all .ts files in src/"
# Non-interactive
pi -p "Summarize this codebase"
# Non-interactive with piped stdin
cat README.md | pi -p "Summarize this text"
# Different model
pi --provider openai --model gpt-4o "Help me refactor"
# Model with provider prefix (no --provider needed)
pi --model openai/gpt-4o "Help me refactor"
# Model with thinking level shorthand
pi --model sonnet:high "Solve this complex problem"
# Limit model cycling
pi --models "claude-*,gpt-4o"
# Read-only mode
pi --tools read,grep,find,ls -p "Review the code"
# Start an integrated remote workspace daemon
PI_DAEMON_TOKEN='long-random-token' pi --daemon --daemon-cwd /workspace --daemon-port 8787
# Connect to that daemon from the orchestrating Pi
PI_REMOTE_TOKEN='long-random-token' pi --remote ws://127.0.0.1:8787/pi/workspace
# Start with a deferred daemon backend for later RPC or /sandbox attachment
pi --remote-deferred --remote-cwd /workspace --mode rpc
# High thinking level
pi --thinking high "Solve this complex problem"Environment Variables
| Variable | Description |
|----------|-------------|
| PI_CODING_AGENT_DIR | Override config directory (default: ~/.pi/agent) |
| PI_CODING_AGENT_SESSION_DIR | Override session storage directory (overridden by --session-dir) |
| PI_REMOTE_TOKEN | Bearer token sent by the Pi remote-workspace client to pi --daemon |
| PI_REMOTE_SESSION_BASE_URL | Remote session service URL (overridden by --remote-session-base-url) |
| PI_REMOTE_SESSION_TOKEN | Bearer token for remote session service (overridden by --remote-session-token) |
| PI_REMOTE_PROJECT_ID | Project id sent to remote session service (overridden by --remote-project-id) |
| PI_PACKAGE_DIR | Override package directory (useful for Nix/Guix where store paths tokenize poorly) |
| PI_OFFLINE | Disable startup network operations, including update checks, package update checks, and install/update telemetry |
| PI_SKIP_VERSION_CHECK | Skip the Pi version update check at startup. This prevents the npm metadata request |
| PI_TELEMETRY | Override install/update telemetry. Use 1/true/yes to enable or 0/false/no to disable. This does not disable update checks |
| PI_CONTEXT_COMPRESSION | Set to 1 to enable compress_context by default for all agents. Detection remains off |
| PI_CONTEXT_COMPRESSION_DETECTION | Set to 1 to enable background detection and compress_context for all agents. Requires a configured compressionDetectionModel |
| PI_CACHE_RETENTION | Set to long for extended prompt cache (Anthropic: 1h, OpenAI: 24h) |
| VISUAL, EDITOR | External editor for Ctrl+G |
| PI_DAEMON_HOST, PI_DAEMON_PORT, PI_DAEMON_CWD, PI_DAEMON_TOKEN | Integrated daemon bind address, port, workspace root, and bearer token |
| PI_DAEMON_TEMP_ROOT | Optional additional confined daemon temporary root; the default sandbox image uses /tmp |
Contributing & Development
See CONTRIBUTING.md for guidelines and docs/development.md for setup, forking, and debugging.
License
MIT
See Also
- @fleetagent/pi-ai: Core LLM toolkit
- @fleetagent/pi-agent-core: Agent framework
- @fleetagent/pi-tui: Terminal UI components
