Home
[[TOC]]

↑ Back to Top

Quick Update:

So let's do some agentic programming I have the the PI agent installed, so here we are these are some old tests that I created some time ago they should more or less work. but let's see what this beast can do I want him to test my website. let's try with localhost so he doesn't fuck things up. let's create a test plan have a look at this web page and create a test okay that's that's very very simple can we make this bigger is much nicer. let's do a simple come on let's do a simple sanity test, after you had a look around create a test plan called Jeff Meridian localhost test suite or something. okay now I'm gonna hit enter let's see what happens he's working on it that's fast there's hardly I'm hardly able to read that.. is some scary shit... oh he's fast... now.... okay at least he takes it's time.... now working on the test plan.... if he's... if he's.. so fast.... that scares me... oh all right what now Jesus Christ the inference speed is insane.... I'm speechless for a forehandling you can run the test Jesus Christ let's have a look what he's doing check page a title visible your allies change okay interesting interest let's run them all in failing failing this thing it's fairly lame it's a very some stupid shit .. lets download some browsers except we don't whatever we don't happens now we have browsers expect curious if you runston headless no he's not he's open when that's my bad I should have restrained him .... we open a gazillion of window... maybe my computer can handle it... can we handle it.... oh yeah magic.... I'm a bit pissed... if it's okay... at least it's failing in...... this just kind of makes me dizzy.... just looking at it... and it's hard to imagine... I hope he's going to close all the browsers..... that he's opening... this is fucking up with my recording.... because the frame rates are dropping..... panic...... should I stop the tests..... this is crazy..... I'm still in shock..... Jesus Christ..... all right we are so lucky because I just checked and we don't have a gazillion of chrome instances open so that's a good sign I don't want to debug those I think that's why we have the healer this is already amazing let's just run one failing text to display the language we see if it was a performance nope he has a problem actually a great example to see what the what the AI coding agent can do.... gonna use our new agent... please go ahead and no please fix this failing test.... heal this failing test... let's see what he is doing.... cool Wow, alright..., so that's what's going on.....

↑ Back to Top

Introduction to Pi

Pi is a minimal terminal coding harness that puts you in control. Unlike other coding agents, Pi doesn't force you into a specific workflow. Instead, you adapt Pi to match how you work — without forking or modifying Pi internals.

↑ Back to Top

What Makes Pi Different

Pi ships with powerful defaults but intentionally skips features like sub-agents and plan mode. Instead, you can:

↑ Back to Top

Key Features

Four Flexible Modes

  1. Interactive: Full terminal UI with session management
  2. Print/JSON: One-shot responses for scripting
  3. RPC: Process integration over stdin/stdout
  4. SDK: Embed Pi in your own applications

Extensibility First

Multi-Provider Support

Pi supports 20+ LLM providers through unified APIs:

Subscriptions (OAuth):

API Keys:

Session Management

Built-in Tools

Pi gives models access to your codebase through tools:

Extensions can replace or augment these with custom implementations.

↑ Back to Top

Philosophy

Note: 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.

Read the blog post for the full rationale.


↑ Back to Top

Quick Start Install Pi

Pi is distributed as an npm package and requires Node.js 20 or later.

Step 1: Install Pi globally

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

This makes the pi command available system-wide.

Step 2: Set up authentication

Choose one of two authentication methods:

API Key (Simple):

Set an environment variable for your preferred provider:

export ANTHROPIC_API_KEY=sk-ant-...

Tip: Add this to your ~/.bashrc or ~/.zshrc to make it permanent.

Supported providers:

Subscription (OAuth):

For Pro/Plus subscribers (Claude Pro, ChatGPT Plus, etc.), Pi supports OAuth authentication.

Step 3: Launch Pi

pi

You'll see the interactive terminal interface with an editor at the bottom.

Step 4: Start coding

Type your request and press Enter:

List all TypeScript files in this directory

Pi will use the built-in tools (read, write, edit, bash) to fulfill your request.

↑ Back to Top

Your First Session

Let's walk through a typical Pi session:

# Start Pi in your project directory
cd ~/my-project
pi

Pi loads and shows the interface

Type your first message:

"Create a simple HTTP server in Node.js that responds with 'Hello World'"

Pi will:

1. Create a new file (server.js)

2. Write the code

3. Show you what it did

Continue the conversation:

"Add a /status endpoint that returns JSON"

Pi edits the existing file and shows the changes

Note: Sessions auto-save to ~/.pi/agent/sessions/ organized by working directory. Use pi -c to continue your most recent session.

↑ Back to Top

Essential Commands

Type / in the editor to see all commands. Here are the most useful:

CommandDescription
/modelSwitch between LLM models
/settingsAdjust thinking level, theme, and more
/treeNavigate session history and branches
/copyCopy last assistant message to clipboard
/hotkeysShow all keyboard shortcuts
/quitExit Pi

↑ Back to Top

Essential Keyboard Shortcuts

KeyAction
Ctrl+LOpen model selector
Ctrl+P / Shift+Ctrl+PCycle through models
Shift+TabCycle thinking level (off → minimal → low → medium → high → xhigh)
EscapeCancel current operation
Escape twiceOpen session tree view
Ctrl+CClear editor (press twice to quit)
Ctrl+OCollapse/expand tool output
@Fuzzy-search and reference files

Tip: Use Shift+Enter (or Ctrl+Enter on Windows Terminal) for multi-line input.

↑ Back to Top

File References

Include files in your messages using the @ symbol:

@src/server.ts Review this file for security issues

Type @ and start typing to get fuzzy-search suggestions. You can reference multiple files:

@package.json @README.md Update the dependencies and document the changes

↑ Back to Top

Running Bash Commands

Prefix commands with ! to run them and send output to the LLM:

!ls -la src/

Use !! to run without sending output:

!!npm install lodash

↑ Back to Top

Session Management

↑ Back to Top

Switching Models

Pi supports 20+ LLM providers. Switch models at any time:

  1. Open model selector: Press Ctrl+L or type /model
  2. Choose your model: Use arrow keys and search to find your model. The list shows:
  1. Continue conversation: Your session continues with the new model. Pi handles cross-provider compatibility automatically.

Note: Use pi --models "claude-*,gpt-4o" to limit Ctrl+P cycling to specific model patterns.

↑ Back to Top

Troubleshooting

Pi command not found

Ensure Pi was installed globally and your npm bin directory is in PATH.

Authentication errors

Verify your API key environment variables are set correctly.

Windows: bash not found

Install Git Bash or WSL2 for bash support.

Node.js version errors

Pi requires Node.js 20 or later. Update with nvm install 20.

Tip: For more help, join the Discord community or check the GitHub issues.


↑ Back to Top

Installation

↑ Back to Top

System Requirements

↑ Back to Top

Global Installation

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

↑ Back to Top

Verification

pi --version

↑ Back to Top

API Key Providers

Set environment variables for your preferred providers:

# Anthropic
export ANTHROPIC_API_KEY=sk-ant-...

OpenAI

export OPENAI_API_KEY=sk-...

Google Gemini

export GEMINI_API_KEY=...

Groq

export GROQ_API_KEY=...

Mistral

export MISTRAL_API_KEY=...

Azure OpenAI

export AZURE_OPENAI_API_KEY=...
export AZURE_OPENAI_ENDPOINT=...

Amazon Bedrock

export AWS_ACCESS_KEY_ID=...
export AWS_SECRET_ACCESS_KEY=...
export AWS_REGION=...

And many more...

↑ Back to Top

OAuth Authentication

For Pro/Plus subscribers, Pi supports OAuth authentication for:

Run pi auth to start the OAuth flow.

↑ Back to Top

Custom Configuration

Create a configuration file at ~/.pi/config.json:

{
  "theme": "dark",
  "thinkingLevel": "medium",
  "defaultModel": "claude-sonnet-4-5-20250929",
  "extensions": [],
  "skills": []
}

↑ Back to Top

Core Concepts

↑ Back to Top

Architecture

Pi is built as a modular system with the following components:

  1. CLI Interface: Terminal-based user interface
  2. Agent Core: Runtime for tool calling and conversation management
  3. AI Layer: Unified API for multiple LLM providers
  4. Tool System: File operations, bash execution, and search
  5. Extension System: Custom tools, commands, and UI components
  6. Session Store: JSONL-based session storage with branching

↑ Back to Top

Tool System

Pi provides models with tools to interact with your codebase:

Built-in Tools

Tool Configuration

Tools can be enabled/disabled via configuration:

{
  "tools": {
    "read": true,
    "write": true,
    "edit": true,
    "bash": true,
    "grep": false,
    "find": false,
    "ls": false
  }
}

Custom Tools

Extensions can provide custom tool implementations:

export const tool: Tool = {
  name: 'customTool',
  description: 'Does something custom',
  parameters: z.object({
    param: z.string()
  }),
  execute: async (params, context) => {
    // Implementation
  }
};

↑ Back to Top

Extension System

Extensions are TypeScript modules that extend Pi's functionality.

Creating an Extension

  1. Create a directory in ~/.pi/extensions/
  2. Add an index.ts file with your extension code
  3. Enable the extension in config

Extension Capabilities

Extensions can:

Example Extension

import { Extension, Tool } from '@mariozechner/pi-coding-agent';

export const extension: Extension = {
name: 'my-extension',
tools: [
{
name: 'hello',
description: 'Say hello',
parameters: z.object({
name: z.string()
}),
execute: async (params) => {
return Hello, ${params.name}!;
}
}
]
};

↑ Back to Top

Session Management

Session Storage

Sessions are stored as JSONL files in ~/.pi/agent/sessions/, organized by working directory.

Session Structure

{
  "id": "session-id",
  "createdAt": "2024-01-01T00:00:00Z",
  "cwd": "/path/to/project",
  "messages": [
    {
      "role": "user",
      "content": "Hello",
      "timestamp": "2024-01-01T00:00:00Z"
    },
    {
      "role": "assistant",
      "content": "Hi there!",
      "timestamp": "2024-01-01T00:00:01Z",
      "toolCalls": []
    }
  ],
  "branches": []
}

Branching

Sessions support in-place branching:

Context Compaction


↑ Back to Top

Guides

↑ Back to Top

Interactive Mode

Interface Overview

The interactive mode provides:

Editor Features

Message Queue

Tool Output

↑ Back to Top

Providers & Models

Supported Providers

Subscription-based (OAuth):

API Key-based:

Model Selection

Use Ctrl+L or /model to open the model selector. The list shows:

Thinking Levels

Adjust the thinking level with Shift+Tab:

Cost Management

↑ Back to Top

Customization

Themes

Pi supports custom themes with hot-reload.

Built-in themes:

Custom themes:

Create ~/.pi/themes/my-theme.json:

{
  "name": "my-theme",
  "colors": {
    "background": "#000000",
    "foreground": "#ffffff",
    "primary": "#00ff00",
    "error": "#ff0000"
  }
}

Skills

Skills are on-demand capabilities following the Agent Skills standard.

Using skills:

/skill install <skill-name>
/skill list
/skill enable <skill-name>

Creating skills:

Skills are CLI tools with a specific interface. See the Skills documentation for details.

Prompt Templates

Create reusable prompts with variable substitution.

Example template:

Review the following code for  best practices:

Focus on:

  • Security issues
  • Performance
  • Readability

Using templates:

/template review-code language=typescript code=@src/file.ts

Extensions

See the Extension System section for details.

Configuration

Full configuration options in ~/.pi/config.json:

{
"theme": "dark",
"thinkingLevel": "medium",
"defaultModel": "claude-sonnet-4-5-20250929",
"models": ["claude-*", "gpt-4o"],
"extensions": ["my-extension"],
"skills": ["my-skill"],
"tools": {
"read": true,
"write": true,
"edit": true,
"bash": true
},
"sessionDir": "~/.pi/agent/sessions",
"maxContextTokens": 100000,
"compactStrategy": "auto"
}

↑ Back to Top

Programmatic Usage

SDK

Pi can be embedded in applications using the SDK.

Installation:

npm install @mariozechner/pi-agent-core @mariozechner/pi-ai

Basic usage:

import { Agent } from '@mariozechner/pi-agent-core';
import { createProvider } from '@mariozechner/pi-ai';

const provider = createProvider({
provider: 'anthropic',
apiKey: process.env.ANTHROPIC_API_KEY
});

const agent = new Agent({
provider,
tools: [read, write, edit, bash]
});

const response = await agent.complete({
messages: [{ role: 'user', content: 'Hello' }]
});

RPC Mode

Run Pi in RPC mode for process integration:

pi --rpc

Communicate over stdin/stdout with JSON messages.

Print Mode

Get one-shot responses for scripting:

pi --print "List all TypeScript files"

JSON Mode

Get structured JSON output:

pi --json "List all TypeScript files"

↑ Back to Top

Packages Overview

Pi is built as a monorepo with multiple packages:

PackageDescription
@mariozechner/pi-coding-agentInteractive coding agent CLI
@mariozechner/pi-aiUnified multi-provider LLM API
@mariozechner/pi-agent-coreAgent runtime with tool calling
@mariozechner/pi-tuiTerminal UI library
@mariozechner/pi-web-uiWeb components for AI chat
@mariozechner/pi-momSlack bot integration
@mariozechner/pi-podsCLI for managing vLLM deployments

↑ Back to Top

@mariozechner/pi-coding-agent

The main CLI package for interactive coding assistance.

Features:

Installation:

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

↑ Back to Top

@mariozechner/pi-ai

Unified API for multiple LLM providers.

Features:

Installation:

npm install @mariozechner/pi-ai

↑ Back to Top

@mariozechner/pi-agent-core

Core agent runtime with tool calling capabilities.

Features:

Installation:

npm install @mariozechner/pi-agent-core

↑ Back to Top

@mariozechner/pi-tui

Terminal UI library used by Pi.

Features:

Installation:

npm install @mariozechner/pi-tui

↑ Back to Top

@mariozechner/pi-web-ui

Web components for building AI chat interfaces.

Features:

Installation:

npm install @mariozechner/pi-web-ui

↑ Back to Top

@mariozechner/pi-mom

Slack bot integration for Pi.

Features:

Installation:

npm install @mariozechner/pi-mom

↑ Back to Top

@mariozechner/pi-pods

CLI for managing vLLM deployments.

Features:

Installation:

npm install @mariozechner/pi-pods

↑ Back to Top

API Reference

↑ Back to Top

AI Package API

createProvider(options)

Create an LLM provider instance.

Parameters:

Returns: Provider instance

Example:

const provider = createProvider({
  provider: 'anthropic',
  apiKey: 'sk-ant-...',
  model: 'claude-sonnet-4-5-20250929'
});

streamAndComplete(options)

Stream a completion response.

Parameters:

Returns: Async iterable of stream events

Example:

const stream = await streamAndComplete({
  provider,
  messages: [{ role: 'user', content: 'Hello' }],
  tools: [read, write, bash]
});

for await (const event of stream) {
if (event.type === 'text') {
console.log(event.text);
} else if (event.type === 'toolCall') {
console.log('Tool call:', event.toolCall);
}
}

↑ Back to Top

Agent Core API

Agent class

Main agent class for running conversations.

Constructor options:

Methods:

Example:

const agent = new Agent({
  provider,
  tools: [read, write, edit, bash]
});

const response = await agent.complete({
messages: [{ role: 'user', content: 'Hello' }]
});

↑ Back to Top

Tool Interface

Tools follow a standard interface:

interface Tool {
  name: string;
  description: string;
  parameters: z.ZodSchema;
  execute: (params: any, context: ToolContext) => Promise<ToolResult>;
}

interface ToolContext {
cwd: string;
sessionId: string;
signal: AbortSignal;
}

interface ToolResult {
output?: string;
error?: string;
files?: Array<{ path: string; content: string }>;
}

↑ Back to Top

Extension Interface

Extensions follow a standard interface:

interface Extension {
  name: string;
  description?: string;
  tools?: Tool[];
  commands?: Command[];
  middleware?: Middleware[];
  activate: (context: ExtensionContext) => Promise<void>;
  deactivate: () => Promise<void>;
}

↑ Back to Top

Additional Resources

Last updated: 2026-04-27

Comments & Ratings

Leave a Comment

#

Loading ratings...

Loading comments...