Pi, taken apart

A coding agent that ships four tools and a short system prompt, and leaves the rest to extensions and the operating system.

Read from the source at commit 69f0be6 (2026-10-02), package version 1.0.0. Not installed or run here.

Pi is an open-source coding agent, started by Mario Zechner and now published as @earendil-works/pi-coding-agent. It works with many model providers. It's here as the opposite of Claude Code and Codex: those two build a lot into the harness, and pi builds in as little as it can. Comparing them shows which parts a working agent needs and which are choices.

Unlike the other two pages, this one has no inside view from a session. Everything here comes from reading pi's code and docs in its repository, and each claim links the file it comes from. Pi isn't small anymore: the coding-agent package alone has about 85,000 lines of TypeScript source. Most of that is the terminal UI, sessions, model providers and the extension system. The part the model sees is still small.

What the model receives

A short system prompt

The default prompt is built in system-prompt.ts. It has one sentence of identity ("an expert coding assistant operating inside pi"), a one-line summary of each tool, a list of rules and a pointer to pi's own docs. The rules are mostly tool advice ("Use read to examine files instead of cat or sed") plus two general ones: "Be concise in your responses" and "Show file paths clearly when working with files". Then come any instruction files, skill descriptions, and the working directory.

Before instruction files, that's about 2,500 characters, or roughly 620 tokens at four characters per token. The descriptions of the four tools and their parameters add about 1,900 characters, roughly 480 tokens. Claude Code's prompt, assembled for one setup, came to 3.8k tokens, and it's built from a library of pieces (see Claude Code, taken apart). Codex's base instructions for GPT-6 are about 5k tokens, from one template per model (see Codex, taken apart). Claude Code's tool descriptions are bigger too. Taking the counts from a copy of Claude Code's strings, pi's whole read tool description is about 116 tokens by my estimate, and Claude Code's is 570. Edit is 392 and Write 266, and the git commit and pull request instructions inside Bash's description alone are 2,322. Pi's prompt also has no environment section apart from the working directory: no date, platform or git status. The bash tool's guideline says the model can read PI_* environment variables if it wants the model and session details.

Each section is wrapped in its own tag, such as <tools> or <project_context>. When a section changes mid-session, pi sends only that section again rather than the whole prompt (diffSystemPromptSections, same file). A SYSTEM.md replaces the default prompt, and an APPEND_SYSTEM.md adds to it (configuration).

Four tools by default

The default tools are read, bash, edit and write. Three more, grep, find and ls, exist but are off unless selected with --tools, and there's a powershell tool for Windows. When the search tools are off, the prompt tells the model to use bash for searching instead. Output from read and bash is truncated to a set number of lines or bytes, and a truncated bash result is saved in full to a temp file (bash.ts). There are no web, task-tracking, question or subagent tools. The prompt only says that "you may have access to other custom tools depending on the project".

MCP, reached through code

Until late September pi's docs never mentioned MCP. Version 1.0 builds it in. Servers are added with pi mcp add or listed in an mcp.json file, and each of their tools is registered as mcp__<server>__<tool> (MCP servers). By default the model isn't shown those tools. Pi turns on a codemode tool instead, where the model writes JavaScript that calls the other tools, and only the script's output comes back (codemode). The script finds MCP tools by searching for them. A server can ask for a different arrangement: with deferred exposure pi turns on tool_search, which looks tools up and declares the matches for the next call, and with direct exposure the tools are declared up front like built-in ones.

So pi now has both answers to the problem of too many tools. Code mode is what Codex does, and tool search is what Claude Code does. Both stay off until an MCP server needs them or the user names them, so a session without MCP still gets four tools (CLI reference).

Instructions: one file per directory, no trust needed

Pi looks for instruction files in its own config directory, the working directory and every parent directory above it. In each directory it takes the first file it finds from AGENTS.override.md, AGENTS.md and CLAUDE.md (in that order), and ignores the rest (loadContextFileFromDir in resource-loader.ts). The files go into the system prompt itself, each in a <project_instructions> tag. Claude Code sends them as a user message instead. So my repos' AGENTS.md files would reach pi unchanged. The CLAUDE.md stubs that only import AGENTS.md would never be read, because AGENTS.md comes first.

Compaction: a summary kept in a tree

Pi compacts when the context comes within a reserve of the window's limit, 16,384 tokens by default. A summary entry then stands in for the older messages. The originals stay in the session file, which is a tree: going back to an earlier message and continuing starts a new branch in the same file (compaction, how pi works). Nothing carries over between sessions: pi has no memory feature.

Limits: left to the operating system

This is where pi differs most. It has no permission prompts, no allowlist, no classifier and no built-in sandbox. Its security page explains why: "Watching the transcript, using project trust, and reviewing changes do not create a security boundary." The only limit it counts is the one the operating system enforces. That means running pi as its own user, or better, "entirely inside a container, virtual machine, or sandbox", which the page calls "usually the strongest practical option".

Pi has one gate of its own, project trust, and it's narrow. Before loading a folder's .pi settings, extensions, skills, prompt files or MCP servers, pi asks whether to trust the folder. That stops a cloned repo from running its own code when pi starts. It doesn't limit what tools do afterwards. It also doesn't cover instruction files, which load either way. The docs say to "treat instructions in a folder as untrusted input even when you decline project trust" (same page).

Claude Code and Codex both treat permission prompts as a limit. Pi treats them as a feeling of safety without a boundary behind it. The difference is how each defines a limit, not just how many features it has.

Code mode doesn't change that. Its scripts run in a QuickJS sandbox with no file system or network of their own, but that confines the script, not the tools it calls. The docs say so directly: "Tool calls are real".

Everything else is an extension

Extensions are TypeScript modules that run inside the pi process. They can register tools, commands, MCP servers and event handlers, and a handler for the tool_call event can block a call (extensions). That event is the equivalent of Claude Code's PreToolUse hook. The repo ships example extensions that rebuild much of what the other two harnesses include:

So pi doesn't reject these features. It makes each one optional, written in code the user can read, and installed only when wanted. Claude Code and Codex have them all built in, turned on or off by settings. Pi's own MCP support, code mode and tool search are built the same way, as extensions that ship with it, and another extension can replace any of them.

What this adds to the survey

Keeping this current

This repo's check.py tracks every pi source and doc file linked here against saved snapshots. Pi isn't installed, so there's no CLI snapshot, and the line counts and prompt size were measured at the commit above.