In early 2026, much of the agent hype centered on OpenClaw — the messaging-connected agent that went viral and later became the substrate for a broader ecosystem. Under that surface sits a smaller project with a different thesis: Pi, the minimal terminal coding harness at pi.dev.
Pi is not trying to be the most feature-complete coding agent. It is trying to be the smallest useful harness you can extend, embed, and reason about. That design choice matters if you care about context engineering, session observability, multi-provider portability, or building your own agent product on top of a stable core.
On July 7, 2026, I rechecked Pi against its official site, docs, GitHub README, Mario Zechner’s November 2025 builder essay, and Armin Ronacher’s January 2026 practitioner write-up. The thesis holds: Pi is a harness-first tool for engineers who want control over what enters the model context and how agent loops behave — not a sealed IDE product.
TL;DR
- Pi is a minimal terminal coding harness by Mario Zechner (
badlogic/pi-mono). It ships four default tools (read,write,edit,bash), a tiny system prompt, and extension hooks for everything else. - What it is for: interactive terminal coding, scripted
pi -pruns, RPC integration, and SDK embedding — notably how OpenClaw embedscreateAgentSession()from@earendil-works/pi-coding-agent. - Versus Claude Code, Cursor, Codex, and OpenCode: Pi trades built-in plan mode, MCP, sub-agents, permission popups, and background bash for observability, context control, and self-extension.
- Handoff pattern: tree-structured sessions, branch-and-rewind (
/tree,/fork), file-based plans (PLAN.md,TODO.md), andpi --printsub-sessions for review — instead of opaque in-session sub-agents. - When Pi wins: harness builders, context engineers, multi-model workflows, and teams that want the agent to extend itself rather than install a feature matrix.
- When Pi loses: IDE-native teams, users who want MCP/plan mode out of the box, and anyone who needs permission guardrails without building them.
What You Will Learn Here
- What Pi is, what problem it solves, and how its monorepo is structured
- How Pi compares to Claude Code, Cursor, Codex CLI, and OpenCode on philosophy and workflow
- Common use cases and handoff patterns that replace built-in sub-agents and plan mode
- Advantages of the minimal-harness approach — and honest limits
- A decision table for choosing Pi versus sealed products
What Is Pi?
Pi is a minimal terminal coding harness: a CLI and SDK that wires together a model provider, an agent loop, session storage, and a terminal UI. The product site at pi.dev describes it as “a minimal agent harness” you adapt to your workflows — not the other way around.
The implementation lives in the open-source monorepo badlogic/pi-mono. As of July 2026, the repo packages four main layers:
| Package | Role |
|---|---|
pi-ai | Unified LLM API across Anthropic, OpenAI, Google, Bedrock, Mistral, Groq, OpenRouter, Ollama, and other OpenAI-compatible endpoints |
pi-agent-core | Agent loop: tool execution, validation, event streaming, steering, follow-ups |
pi-tui | Terminal UI with differential rendering and synchronized output |
pi-coding-agent | CLI harness: sessions, extensions, skills, themes, context files, RPC/SDK modes |
Install globally:
npm install -g --ignore-scripts @earendil-works/pi-coding-agent
# or
curl -fsSL https://pi.dev/install.sh | sh
Then authenticate with /login (subscription OAuth) or an API key such as ANTHROPIC_API_KEY, and run pi in a project directory.
Default surface area
Pi’s defaults are deliberately small. The official README states the model gets four tools: read, write, edit, and bash. Mario Zechner’s November 30, 2025 essay publishes the full system prompt; together, prompt plus tool definitions stay below ~1,000 tokens — far smaller than native harness prompts from Claude Code, Codex, or OpenCode-derived stacks.
That small core is the product thesis: fewer baked-in features means fewer hidden context injections and fewer behavior changes you did not choose.
Four runtime modes
Pi is not only an interactive TUI. Official docs list four modes:
- Interactive — full terminal session with slash commands and extensions
- Print / JSON —
pi -p "query"for scripts;--mode jsonfor structured event streams - RPC — JSON protocol over stdin/stdout for non-Node integrations
- SDK — embed Pi in Node.js apps via
createAgentSession()
OpenClaw is the canonical “real-world SDK integration” cited in Pi docs: it imports Pi directly rather than shelling out to a subprocess, which gives the gateway full control over sessions, tools, and prompts.
What Pi Is For
Pi targets three overlapping audiences:
- Daily terminal coders who want a fast, flicker-resistant TUI and mid-session model switching across 15+ providers
- Harness builders embedding agent loops in gateways, bots, or internal tools (OpenClaw is the headline example)
- Context engineers who need to see, filter, and customize everything that enters the model window
Pi explicitly does not try to be:
- an IDE (compare Cursor)
- a permission-gated enterprise shell (compare Claude Code’s approval flows)
- an MCP host (compare Codex, Claude Code, Cursor with MCP enabled)
- a batteries-included multi-agent orchestrator (compare Claude Code sub-agents or Cursor background agents)
Instead, Pi’s docs and philosophy page say: if you want sub-agents, plan mode, MCP, todos, or background bash, ask Pi to build an extension, use tmux, write files, or install a pi package — or use a different product.
That is a feature choice, not a missing roadmap item.
Architecture at a Glance
User prompt
|
v
+------------------+
| pi-coding-agent | AGENTS.md / SYSTEM.md / skills / extensions
| (CLI or SDK) |
+--------+---------+
|
v
+------------------+
| pi-agent-core | tool loop, steering, follow-up queue
+--------+---------+
|
v
+------------------+
| pi-ai | provider routing, context handoff, cost tracking
+--------+---------+
|
v
LLM provider(s)
Steering vs follow-up is a useful workflow primitive. While the agent works:
Entersends a steering message (delivered after the current tool; can interrupt remaining tools)Alt+Entersends a follow-up (queued until the agent finishes)
That gives human-in-the-loop control without spawning opaque sub-agents.
Pi Versus Popular Alternatives
No single harness wins every task. Pi’s differentiation is architectural minimalism and extensibility, not benchmark crown-chasing.
Comparison matrix
| Dimension | Pi | Claude Code | Cursor | Codex CLI | OpenCode |
|---|---|---|---|---|---|
| Primary surface | Terminal TUI + SDK | Terminal + IDE plugins + web | IDE-first + cloud agents | Terminal / IDE-adjacent CLI | Terminal harness |
| Default tools | 4 (read, write, edit, bash) | Rich built-in toolset | IDE-integrated tools + agents | Minimal-ish CLI tools | Model-specific, broader than Pi |
| Plan mode | No — use PLAN.md or --tools read,grep,find,ls | Built-in Plan Mode (--permission-mode plan) | To-dos, queues, custom modes | Varies by surface | Varies |
| Sub-agents | No — spawn pi --print via bash/tmux | Native sub-agents | Background / subagents | Agent features vary | Community patterns |
| MCP | No — CLI tools + skills; mcporter bridge | First-class | First-class | Supported | Supported |
| Permissions | YOLO by default; container docs | Approval prompts, sandbox options | IDE guardrails | Policy layers | Varies |
| Session model | Tree-structured JSONL, branch/rewind | Session history | Cloud + local threads | Session-based | Session-based |
| Multi-provider | Core design; mid-session /model | Anthropic-first | Multi-model picker | OpenAI-first | Strong multi-provider |
| Embed SDK | createAgentSession() | Limited | Cloud API / automations | API-oriented | Harness-oriented |
| Best fit | Harness builders, context control | Anthropic-native deep loops | IDE-centric teams | OpenAI-native automation | Multi-model terminal users |
Table mixes official product docs with editorial judgment on “best fit.” Re-check vendor docs before production commitments.
Versus Claude Code
Claude Code is the closest cultural competitor: terminal-native, agentic, strong at repo-wide work. Mario Zechner’s builder essay (November 30, 2025) names the friction that led to Pi: Claude Code gained features and changing system prompts/tools across releases, which broke stable personal workflows.
Pi’s response:
- Fixed minimal prompt you can replace wholesale via
SYSTEM.md - No built-in sub-agents — you spawn
pi --printand keep output visible - No plan mode — you collaborate on
PLAN.mdwith full command observability - tmux over background bash — long-running processes stay inspectable
Claude Code still wins when you want Anthropic-native Plan Mode, sub-agents, IDE integrations, and permission workflows without building them.
Versus Cursor
Cursor optimizes for IDE-native planning and execution: background agents, PR review in-editor, Slack automations, and visual diff workflows. Pi does not compete on IDE ergonomics.
Choose Cursor when the team lives in the editor and wants async cloud agents. Choose Pi when the loop should be terminal-scriptable, embeddable, and context-transparent.
Versus Codex CLI
OpenAI’s Codex tooling targets OpenAI-model automation with growing IDE and cloud surfaces. Pi is provider-agnostic by design — including OAuth for Claude Pro/Max, ChatGPT/Codex subscriptions, and GitHub Copilot per the official providers list.
Pi’s pi-ai layer also supports cross-provider context handoff (with documented caveats for thinking traces and signed blobs). That matters for cost routing or model A/B tests inside one session.
Versus OpenCode
OpenCode (and similar terminal harnesses) shares Pi’s multi-provider story. Pi differentiates on:
- Published session tree format with
/tree,/fork,/export,/share - Extension system with hot reload (
/reload) so the agent can modify its own harness - Explicit anti-MCP stance with CLI+README progressive disclosure
- SDK embedding proven at OpenClaw scale
Versus OpenClaw (layer above Pi)
OpenClaw is not a Pi alternative — it is a consumer of Pi’s SDK. The gateway adds channels (WhatsApp, Telegram, Slack), cron, memory search, multi-agent routing, and sandboxing. Pi remains the agent runtime.
Editorial split: use Pi when you want the harness itself; use OpenClaw when you want a messaging-connected personal agent without building gateway infrastructure.
Handoffs, Use Cases, and Workflow Patterns
Pi removes several convenience features other harnesses bundle. The replacement patterns are consistent: make state visible, file-based, or externally observable.
1. Planning without plan mode
Pattern: maintain PLAN.md (or OpenSpec artifacts) in the repo; agent reads and updates it across sessions.
# PLAN.md
## Goal
Refactor auth to support OAuth
## Current step
3 — authorization endpoints
## Done when
- Integration tests pass
- Migration documented
For read-only exploration:
pi --tools read,grep,find,ls
Why this beats opaque plan mode (editorial): every source the agent consulted stays in the session tree. Claude Code Plan Mode can delegate to sub-agents you cannot inspect; Pi keeps planning commands in the main transcript.
2. Review handoffs with session trees
Armin Ronacher’s /review extension pattern (January 31, 2026) branches a session for code review, then merges findings back — using tree navigation instead of a black-box reviewer sub-agent.
Built-in commands that support this:
/tree— jump to any prior point and continue/fork— branch from a user message/clone— duplicate the active branch into a new session/compact— summarize older context with optional custom instructions
main session (implementation)
|
+-- branch: /review on uncommitted diff
| |
| +-- findings recorded
|
+-- rewind to pre-review point
+-- apply fixes with review context summarized
3. Sub-agent work without sub-agent tools
Pi’s documented alternative to sub-agents:
pi --print "Review PR #42 for security issues. Output markdown only."
Or spawn inside tmux for interactive co-debugging. Mario’s essay includes a prompt-template pattern where the main session delegates review to a child pi --print run and reports findings — without a dedicated sub-agent API.
Handoff rule (editorial): use separate sessions for context gathering; pass artifacts (markdown briefs, grep outputs, architecture notes) into a fresh session instead of nesting opaque agents.
4. Long-running processes
Pi intentionally has no background bash. The documented pattern is tmux: dev servers, test watchers, and debuggers stay visible and attachable.
This trades convenience for observability — aligned with Pi’s “no hidden processes” stance.
5. Skills, extensions, and pi packages
Pi supports three extension layers:
| Mechanism | What it does | Token posture |
|---|---|---|
| Skills | On-demand capability packages (Agent Skills format) | Loaded progressively |
| Prompt templates | /name expands Markdown templates | Pay when invoked |
| Extensions | TypeScript modules: tools, commands, TUI widgets, events | Registered at startup; hot reload |
Share bundles via pi packages:
pi install npm:@foo/pi-tools
pi install git:github.com/badlogic/pi-doom
MCP alternative: build CLI tools with READMEs (progressive disclosure), or use Peter Steinberger’s mcporter to expose MCP servers as CLI commands Pi can invoke via bash.
6. Embedding in your own product
SDK sketch from official README:
import {
AuthStorage,
createAgentSession,
ModelRegistry,
SessionManager,
} from "@earendil-works/pi-coding-agent";
const session = await createAgentSession({
cwd: process.cwd(),
modelRegistry: new ModelRegistry(),
sessionManager: SessionManager.open("my-session.jsonl"),
authStorage: new AuthStorage(),
});
OpenClaw’s architecture imports this directly — gateway handles channels and policy; Pi handles the agent loop. That split is the reference design for “harness inside, product outside.”
7. Scripted CI and loop engineering
For loop engineering (see also senior-engineer-agent-orchestrating-subagents-loop-engineering):
pi -p "Run tests, fix failures, stop when green" --mode json > events.jsonl
JSON mode emits structured events for orchestrators — closer to a composable primitive than a sealed IDE agent.
More Advantages of the Minimal Harness
Beyond comparisons, Pi’s design pays off in specific engineering dimensions.
Context engineering you can actually see
Pi docs emphasize context engineering: minimal system prompt, optional SYSTEM.md override, hierarchical AGENTS.md loading (~/.pi/agent/, parents, project root), compaction extensions, and dynamic context injection via extension hooks.
Unlike harnesses that inject hidden instructions, Pi’s startup header lists loaded context files, skills, extensions, and templates — so you know what the model saw before the first turn.
Tree-structured sessions as a workflow primitive
Sessions are stored as trees in a single JSONL file. Branching is not a gimmick; it enables review side-quests, speculative fixes, and rewind-without-losing-history — a handoff primitive most chat UIs lack.
Export paths:
/export— HTML or JSONL/share— private GitHub gist with renderable HTML
Multi-model sessions with honest portability limits
pi-ai supports switching providers mid-session (/model, Ctrl+L). The docs and builder essay are explicit that thinking traces and provider-specific blobs do not port perfectly — editorial honesty rare in vendor harnesses.
Performance and reliability
Armin Ronacher’s practitioner post (January 31, 2026) highlights Pi’s TUI quality: low flicker (especially in Ghostty/iTerm2), low memory use, and stability. Mario’s pi-tui uses differential rendering with synchronized output — a deliberate alternative to full-screen scrollback-eating TUIs.
Self-modifying harness
Pi encourages agents extending the harness they run in: write an extension, /reload, iterate. Hot reload turns the harness into clay — relevant for teams building agent-native tooling (see also self-modifying-software-from-theory-to-practice).
Security posture is explicit, not theatrical
Pi runs YOLO by default — full filesystem and shell access. Official docs point to containerization (Gondolin, Docker, OpenShell) rather than faux permission popups. Mario’s essay argues permission theater fails once agents can read data and reach the network; Pi chooses honest defaults.
Benchmark signal (with caveats)
Mario’s November 2025 Terminal-Bench 2.0 run placed Pi competitively against Codex, Cursor, and other harnesses using Claude Opus 4.5 — evidence that minimal tooling can perform, not proof it always wins in your repo. Treat benchmarks as directional; run your own task bakeoff.
When Not to Choose Pi
Be explicit about limits:
- IDE-native teams will fight the terminal-first model.
- MCP-heavy workflows need extensions or
mcporter; nothing is pre-wired. - Enterprise permission models require you to build confirmation flows or use containers.
- Out-of-the-box sub-agents and plan mode are faster to adopt elsewhere.
- Non-technical users should not start with YOLO shell access.
If those are hard requirements, Claude Code or Cursor is usually the faster path.
Decision Flow
Need IDE + cloud agents + PR review in-editor?
yes -> Cursor (or Claude Code IDE surfaces)
no
|
v
Need Anthropic-native plan/sub-agent UX without building it?
yes -> Claude Code
no
|
v
Building a gateway/bot/product on an agent runtime?
yes -> Pi SDK (see OpenClaw pattern)
no
|
v
Care most about context control + session trees + multi-provider CLI?
yes -> Pi
no
|
v
Default -> try Pi and your incumbent side-by-side on 3 real tasks
Sources
Primary sources consulted on July 7, 2026:
- Pi product site — philosophy, features, anti-feature list. pi.dev
- Pi documentation — install, modes, sessions, extensions, SDK, security. pi.dev/docs
badlogic/pi-mono—packages/coding-agent/README.md— tools, providers, commands, SDK, philosophy. github.com/badlogic/pi-mono/tree/main/packages/coding-agent- Mario Zechner — “What I learned building an opinionated and minimal coding agent” (November 30, 2025) — design rationale, anti-MCP argument, Terminal-Bench run, tmux patterns. mariozechner.at/posts/2025-11-30-pi-coding-agent/
- Armin Ronacher — “Pi: The Minimal Agent Within OpenClaw” (January 31, 2026) — practitioner workflows, extensions (
/answer,/review,/todos), skills-over-MCP pattern. lucumr.pocoo.org/2026/1/31/pi/ - OpenClaw repository — SDK integration reference cited by Pi docs. github.com/openclaw/openclaw
- Peter Steinberger —
mcporter— MCP-to-CLI bridge recommended by Pi docs. github.com/steipete/mcporter - Anthropic Claude Code docs — Plan Mode and permission-mode reference for comparison. docs.anthropic.com/en/docs/claude-code
- Cursor documentation — IDE agent, background agents, and planning surfaces for comparison. cursor.com/docs
Editorial judgment is labeled throughout (best-fit rows, handoff recommendations, decision flow). Re-verify vendor features before production rollout; this space changes weekly.