co-mono/packages/coding-agent/README-NEW.md

10 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. Ask it to work on your codebase, run commands, or perform tasks for you.

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:

  • Header - On startup, shows shortcuts (/hotkeys for all), loaded AGENTS.md files, prompt templates, skills, and extensions
  • Messages - Your messages, assistant responses, tool calls and results, custom UI from extensions
  • Editor - Where you type
  • Footer - Working directory, token usage, cost, 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 Prefix with ! (e.g., !git status)

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
/settings Thinking level, theme, message delivery
/resume, /new Session management
/tree, /fork Navigate and branch session history
/compact Manually compact context
/export, /share Export to HTML or GitHub gist
/reload Reload extensions, skills, prompts, themes
/hotkeys Show all keyboard shortcuts

See Customization for skills, prompt templates, and extensions.

Keyboard Shortcuts

See /hotkeys for the full list. Customize via ~/.pi/agent/keybindings.json. See docs/keybindings.md.

Highlights:

Key Action
Ctrl+P Cycle models
Ctrl+L Open model selector
Shift+Tab Cycle thinking level
Ctrl+O Toggle tool output
Ctrl+T Toggle thinking blocks
Escape Cancel/abort

Sessions

Sessions auto-save to ~/.pi/agent/sessions/ with tree structure for branching.

pi -c              # Continue most recent
pi -r              # Browse and select
pi --no-session    # Ephemeral mode

Branching: Use /tree to navigate history in-place, or /fork to create a new session from any point.

Compaction: Long sessions can exhaust context. Use /compact manually or enable auto-compaction in /settings.

See docs/sessions.md for file format and branching details.


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