co-mono/packages/coding-agent/README-NEW.md
Mario Zechner 28ab25b07e docs(coding-agent): improve README structure and update session/compaction docs
- README-NEW.md: add Quick Start, Interactive Mode, Sessions sections
- session.md: add Message Types section, complete SessionManager API, fix source links to GitHub URLs
- compaction.md: rename hooks to extensions, fix source links to GitHub URLs
- keybindings.md: new file documenting all keyboard shortcuts
2026-01-26 01:25:15 +01:00

13 KiB

pi logo

Discord npm Build status

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, Prompt Templates, and Themes. Put your extensions, skills, prompt templates, and themes in Pi Packages and share them with others via npm or git.

Pi ships with powerful defaults but skips features like sub agents and plan mode. Instead, you can ask pi to build what you want or install a third party pi package that matches your workflow.

Pi runs in four modes: interactive, print or JSON, RPC for process integration, and an SDK for embedding in your own apps. See clawdbot/clawdbot for a real-world SDK integration.

Table of Contents


Quick Start

npm install -g @mariozechner/pi-coding-agent

Authenticate with an API key:

export ANTHROPIC_API_KEY=sk-ant-...
pi

Or use your existing subscription:

pi
/login  # Then select provider

Then just talk to pi. By default, pi gives the model four tools: read, write, edit, and bash. The model uses these to fulfill your requests. Add capabilities via skills, prompt templates, extensions, or pi packages.

Platform notes: Windows | 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
  • Google Gemini CLI
  • Google Antigravity

API keys:

  • Anthropic
  • OpenAI
  • Azure OpenAI
  • Google Gemini
  • Google Vertex
  • Amazon Bedrock
  • Mistral
  • Groq
  • Cerebras
  • xAI
  • OpenRouter
  • Vercel AI Gateway
  • ZAI
  • OpenCode Zen
  • MiniMax

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

Interactive Mode

The interface from top to bottom:

  • Startup header - Shows shortcuts (/hotkeys for 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)
Images Ctrl+V to paste, or drag 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
/resume Pick from previous sessions
/new Start a new session
/name <name> Set session display name
/session Show session info (path, tokens, cost)
/tree Jump to any point in the session and continue from there
/fork Create a new session from the current branch
/compact [prompt] Manually compact context, optional custom instructions
/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 extensions, skills, prompts, themes
/hotkeys Show all keyboard shortcuts
/changelog Display version history
/quit, /exit 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

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.

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>    # Use specific session file or 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, page with ←/→
  • Filter modes (Ctrl+O): default → no-tools → user-only → labeled-only → all
  • Press l to label entries as bookmarks

/fork - Create a new session file from the current branch. Opens a selector, copies history up to the selected point, and places that message in the editor for modification.

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. The full history remains in the JSONL file; use /tree to revisit. Customize compaction behavior via extensions.

See docs/session.md for file format and docs/compaction.md for internals.


Configuration

Context Files

Pi loads AGENTS.md files at startup (global ~/.pi/agent/AGENTS.md, parent directories, current directory). Use for project instructions, conventions, common commands.

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.

Custom Models

Add Ollama, vLLM, LM Studio, or proxy endpoints via ~/.pi/agent/models.json:

{
  "providers": {
    "ollama": {
      "baseUrl": "http://localhost:11434/v1",
      "api": "openai-completions",
      "models": [{ "id": "llama-3.1-8b", "name": "Llama 3.1 8B", ... }]
    }
  }
}

See docs/models.md for full schema and examples.

Settings

Global settings in ~/.pi/agent/settings.json, project overrides in .pi/settings.json.

See docs/settings.md for all options.


Customization

Themes

Built-in: dark, light. Create custom themes in ~/.pi/agent/themes/*.json with live reload.

See docs/themes.md.

Prompt Templates

Reusable prompts as Markdown files in ~/.pi/agent/prompts/ or .pi/prompts/. Type /name to expand.

See docs/prompt-templates.md.

Skills

On-demand capability packages following the Agent Skills standard. Place in ~/.pi/agent/skills/ or .pi/skills/. Invoke via /skill:name or let the agent load them automatically.

See docs/skills.md.

Extensions

TypeScript modules for custom tools, commands, event interception, and UI.

export default function (pi: ExtensionAPI) {
  pi.registerTool({ name: "deploy", ... });
  pi.registerCommand("stats", { ... });
  pi.on("tool_call", async (event, ctx) => { ... });
}

Place in ~/.pi/agent/extensions/ or .pi/extensions/.

See docs/extensions.md and examples/extensions/.

Pi Packages

Bundle and share extensions, skills, prompts, and themes via npm or git:

pi install npm:@foo/pi-tools
pi install git:github.com/user/repo
pi list
pi update

See docs/packages.md.


CLI Reference

pi [options] [@files...] [messages...]

Modes

Flag Description
(default) Interactive mode
-p, --print Print response and exit
--mode json JSON event stream
--mode rpc RPC mode for process integration

Common Options

Option Description
--provider, --model Select provider and model
--thinking <level> off, minimal, low, medium, high
--models <patterns> Patterns for Ctrl+P cycling
-c, --continue Continue most recent session
-r, --resume Browse and select session
--tools <list> Limit tools (default: read,bash,edit,write)

File Arguments

pi @prompt.md "Answer this"
pi @screenshot.png "What's in this image?"

See pi --help for all options.


Programmatic Usage

SDK

import { AuthStorage, createAgentSession, ModelRegistry, SessionManager } from "@mariozechner/pi-coding-agent";

const { session } = await createAgentSession({
  sessionManager: SessionManager.inMemory(),
  authStorage: new AuthStorage(),
  modelRegistry: new ModelRegistry(authStorage),
});

await session.prompt("What files are in the current directory?");

See docs/sdk.md and examples/sdk/.

RPC Mode

pi --mode rpc --no-session

See docs/rpc.md for the protocol.

HTML Export

pi --export session.jsonl output.html

Philosophy

No MCP. Build CLI tools with READMEs (see Skills). Why?

No sub-agents. Spawn pi instances via tmux, or build your own with Extensions.

No permission popups. Run in a container or build your own confirmation flow.

No plan mode. Write plans to files, start fresh for implementation.

Read the blog post for the full rationale.


Development

See docs/development.md for forking, rebranding, and debugging.


License

MIT

See Also