Skip to content

Pi Coding Agent: A Minimalist Open-Source Terminal Coding Harness

Mar 31, 2026 1 min
TL;DR Pi is a minimalist coding agent built in TypeScript by Mario Zechner, featuring just 4 core tools (read, write, edit, bash) and a 300-word system prompt. It's extensible via Extensions, Skills, and Prompt Templates, runs on the Bun runtime, and ships with built-in Ollama support via `ollama launch pi`.

🌏 中文版

Pi is an open-source coding agent built by Mario Zechner (GitHub: badlogic), centered on a single principle: minimal but extensible. The entire system is roughly 4,000 lines of TypeScript, ships with just 4 tools and a 300-word system prompt — and leaves everything else up to you.

Installation

# Launch via Ollama with a single command
ollama launch pi

# Install via npm
npm install -g @mariozechner/pi-coding-agent

Runs on the Bun runtime for fast startup.

Design Philosophy

What Pi deliberately omits is just as important as what it includes.

Only 4 Core Tools

ToolFunction
readRead files
writeWrite files
editEdit files
bashExecute shell commands

No built-in sub-agents, no plan mode, no MCP — but all of these can be added through Extensions.

300-Word System Prompt

Most coding agents have system prompts thousands of words long. Pi uses just 300 words, maximizing prompt cache hit rates and minimizing token consumption.

Core Features

FeatureDescription
4 Execution ModesInteractive, Print/JSON (output), RPC (programmatic integration), SDK (embed in apps)
CompactionAutomatically summarizes older messages when approaching the context limit; summary strategy is customizable via Extension
SkillsOn-demand capability packs (commands + tools) that don’t occupy the prompt cache
Dynamic ContextExtensions can inject messages before each turn, filter history, or implement RAG and long-term memory
Multi-ProviderSupports Anthropic, OpenAI, Google, Azure, Bedrock, Mistral, Groq, Cerebras, xAI, Hugging Face, and more
Mid-Session Model SwitchingSwitch models during an active session

Extension System

Pi’s extension system consists of TypeScript modules with access to:

  • Tools: Add custom tools
  • Commands: Add custom commands
  • Keyboard shortcuts: Bind custom actions
  • Events: Listen to agent lifecycle events
  • TUI: Full access to the terminal UI

Through Extensions, you can implement sub-agents, plan mode, permission control, sandboxing, MCP integration, and more. Pi’s philosophy: rather than bundling everything and letting you disable what you don’t need, it lets you load only what you actually use.

TUI Engine

Pi’s TUI is powered by @mariozechner/pi-tui, featuring:

  • Flicker-free diff rendering
  • CSI 2026 synchronized output
  • Bracketed paste handling
  • Inline image support (Kitty / iTerm2 protocols)
  • Autocomplete and overlay dialogs

Relationship with OpenClaw

LayerOwnerResponsibility
GatewayOpenClawChannel management, routing, authentication, scheduling
Agent RuntimePiReasoning, tool execution, context management
SessionSharedOpenClaw owns the session; Pi runs the agent loop
MemoryPiMarkdown files, vector search

Pi serves as OpenClaw’s AI core engine. OpenClaw handles the outer layer (channels, security, scheduling); Pi handles the inner layer (reasoning, execution, memory). Pi’s configuration is passed through OpenClaw’s agents.defaults and agents.list[].

That said, Pi works perfectly fine as a standalone tool — no OpenClaw required.

Resource Requirements

Pi can run on very small models:

Use CaseModel
Lightweight useQwen3:1.7b (local)
General developmentClaude Sonnet, GPT-4o
Complex tasksClaude Opus, GPT-5

Compared to OpenClaw, which requires at least a 64K context window, Pi is far more flexible.

Comparison with Other Coding Agents

PiClaude CodeCodex CLIOpenCode
LanguageTypeScriptTypeScriptRustGo
Core tools4MultipleMultipleMultiple
Design philosophyMinimal + extensibleFeature-completeOpenAI ecosystem integrationModel flexibility
Built-in sub-agents❌ (via Extension)
Built-in MCP❌ (via Extension)
Minimum viable model1.7BRequires large modelRequires OpenAI modelFlexible

Typical Use Cases

  1. Minimalist development: When you only need basic read/write/edit capabilities without the overhead of complex features
  2. Custom agents: Build a fully tailored coding workflow using the Extension system
  3. Local small models: Connect to Ollama and run a 1.7B model in resource-constrained environments
  4. Embedding in apps: Use SDK mode to integrate Pi directly into your own product
  5. OpenClaw core: Serve as the agent runtime for an OpenClaw Gateway

Positioning vs. Other Tools

Pi’s core strengths are its minimalist design (low token consumption, high prompt cache hit rates), unlimited extensibility via TypeScript Extensions, and friendly support for small models. It’s the right fit for developers who prefer the “build it yourself” approach and want full control over agent behavior.

Resources

References