Pi's default system prompt is 605 tokens. I rendered buildSystemPrompt from @earendil-works/pi-coding-agent 1.4.0 on 30 October 2026, with the default tools (read, bash, edit, write), no context files, no skills, and the working directory set to /tmp/project. The docs paths in that render sit under /tmp/pi-measure/node_modules/@earendil-works/pi-coding-agent. Counted with OpenAI's o200k_base tokenizer, the string is 605 tokens and 2,702 characters. A different install path moves the count, because those absolute paths are part of the prompt. Tool JSON schemas are sent separately and are not in the 605.

Pi vs Claude Code, in one line: use Claude Code when the job is Claude and you want the harness Anthropic ships. Use Pi when you want other models, a session you can fork, and a prompt short enough to read. I ran both on the same work. I use Claude Code for work.

Updated 30 October 2026. Pi 1.0 added MCP on 1 October, the npm package is @earendil-works/pi-coding-agent, the prompt size above is measured from that package, and the subscription section follows the help article and the legal page as they stood on this date.

What I checked: Pi sessions, MCP, providers, CLI, and settings, plus buildSystemPrompt and the subscription warning in package 1.4.0. earendil-works/pi via the GitHub API (118,887 stars). Pi 1.0. Anthropic's Agent SDK help article and legal and compliance. claude.com/pricing. The VS Code marketplace entry for anthropic.claude-code. The May Reddit thread and the April billing incident are the same sources as the first version of this post.

What Pi taught me about my own workflow

This part is what happened when I used Pi.

I came to it from two Claude Code subscriptions, one personal and one at work, plus a Cursor subscription.

Pi looked like the way out. Open source, model agnostic, a short prompt, and the harness in my hands. I set it up and started scaffolding create-sbastack-app.

Within the first hour I blew through my Z.ai cap. Four million tokens were gone. I switched to OpenAI Codex and hit the 5-hour cap after two hours of intense coding.

I posted about it on Reddit. As of May 2026 the thread had 16K views and 49 comments. Half the replies were "I don't understand how people run out of tokens like that." The other half were "I have the same issue."

The blowout was on my side.

Pi exposes what Claude Code hides

Claude Code's prompt is large enough to paper over a messy instruction file. When AGENTS.md or CLAUDE.md is bloated, that harness drops things and compensates. You don't see the waste.

After that 605 token prompt, Pi sends your files. The default tools are read, bash, edit, and write. An earlier version of this post used round token counts for both prompts. The Pi number above is the one I measured. I did not remeasure Claude Code as a single string on 30 October 2026, because the current build is a set of conditional sections.

I ported over my CLAUDE.md, my skills, my MCP notes, and the planning workflows from Matt Pocock's skills package. Pi loaded the instruction files. Every token went to the model, and the caps were gone in an hour.

The comment that matched what I found, from that May thread:

Pi is a reflection of you and you only. So there's a snag in your pipeline somewhere.

What is Pi? What is Claude Code?

Pi is an open-source terminal coding agent by Mario Zechner, MIT licensed. The repo earendil-works/pi had 118,887 stars on 30 October 2026. It was around 60K when I first wrote this in May. Claude Code is Anthropic's coding agent, launched May 2025, and it stays on Claude's models.

FeaturePiClaude Code
LicenseMITProprietary
GitHub stars118,887 on 30 Oct 2026Proprietary distribution
Models15+ providers, per the Pi homepageClaude models
System prompt605 tokens, default tools, package 1.4.0Many conditional sections. I did not count one string.
Default toolsread, bash, edit, writeSub-agents, MCP, web search, and the rest of the built-in set
MCPNative since 1.0 (1 Oct 2026). Default exposure is codemode.Native
InterfaceTerminal TUI, print, RPC, SDKTerminal, VS Code, JetBrains, desktop
PriceFree tool. You pay the model.Pro $20/month, or $17/month annual

Pi: the minimal coding harness

npm install -g @earendil-works/pi-coding-agent

That package name is @earendil-works/pi-coding-agent. The 1.4.0 release is what was on npm on 30 October 2026. The 1.0 announcement also offers an install script at https://pi.dev/install.sh.

The default tools are read, bash, edit, and write. grep, find, ls, and powershell are built in and off until you add them. Sub-agents and planning modes are extensions. The Pi homepage still says 15+ providers and hundreds of models: Anthropic, OpenAI, Google, Azure, Amazon Bedrock, and local models through Ollama are on that list. Switch mid-session with /model or Ctrl+L. Cycle favourites with Ctrl+P.

Claude Code: the integrated coding agent

Claude Code ships sub-agents, native MCP, memory that persists between sessions, and path-scoped rules. It runs as a terminal CLI, a VS Code extension, JetBrains IDEs, and a desktop app. The VS Code extension anthropic.claude-code was at 29,068,184 installs on version 2.1.314 when I queried the marketplace API on 30 October 2026. An earlier version of this post said 22,470,151 installs on 6 August 2026.

The pricing page lists Opus, Sonnet, Haiku, and Fable, and says the context window is up to 1M tokens, varying by model. I did not recheck which of those appear in the Claude Code model picker.

I use Claude Code for work, and I don't watch the cap there. That convenience is why it stays my work tool, and the dependence is the risk that comes with it.

Which tool supports more AI models?

Pi does. The subscription question sits in that gap.

Pi: any model, any provider

Pi is model-agnostic. The homepage says 15+ providers. The providers page names a longer set, including regional endpoints. You can switch mid-session, and Ollama is on the list. The May thread had people on cheap hosted plans and on local models. Those bills are under the cost heading.

Claude Code stays on Claude

You get Claude's models, one subscription, and a harness that already knows the tools.

Can Anthropic change how Pi uses your Claude subscription?

Yes. The help article and the legal page describe different rules.

On 4 April 2026 Anthropic stopped third-party agents using Claude subscription OAuth tokens. Pi and the other harnesses were pushed onto extra usage or a separate API key. On 13 May 2026 Anthropic reversed that and described a separate monthly credit, due on 15 June. On 15 June the change was paused.

I read Use the Claude Agent SDK with your Claude plan on 30 October 2026. Two notes are still on it.

The 7 October 2026 note: Max and Team plans include monthly API credits for the Claude API, Claude Managed Agents, and the Agent SDK and claude -p when you use an API key from your linked Claude Console organization. Signed in with the plan, the Agent SDK and claude -p still draw from subscription limits.

The 15 June 2026 note: the announced changes are paused, and the Agent SDK, claude -p, and third-party app usage still draw from subscription limits.

The legal and compliance page, same day, is the stricter text. OAuth is for ordinary use of Claude Code and other native Anthropic apps. Third-party developers are not allowed to offer Claude.ai login in their own applications, or to route Free, Pro, or Max credentials for their users. They are not allowed to collect, store, or intermediate Claude.ai credentials or session tokens. Sign-in has to finish through Anthropic's own flow, and Anthropic can enforce that without notice. Signing in to the unmodified Claude Code binary with your own subscription is the case that page allows.

Pi 1.4.0 prints this once when the selected model is Anthropic and the stored credential is OAuth, unless warnings.anthropicExtraUsage is false. From interactive-mode.js:

Anthropic subscription auth is active. Third-party harness usage draws from extra usage and is billed per token, not your Claude plan limits. Manage extra usage at https://claude.ai/settings/usage. Disable this warning in /settings.

An API key is the path the legal page describes. A subscription login is what the June notice still mentions, and what Pi warns you about. I did not run a fresh login to see which meter a request hits. The paused credit is in Claude Code pricing 2026: autonomous credits explained.

Later in April 2026 a separate incident landed. An overactive anti-abuse system, Anthropic's own words via Boris Cherny, was scanning git history for strings associated with competing harnesses. If Claude Code saw the exact string HERMES.md (case-sensitive) in your commit messages, it routed the session from subscription billing to extra usage. No notification.

One user reported $200.98 in extra usage while 86% of a Max 20x plan sat untouched. He was not using Hermes. The incident is in GitHub issue #53262 and thekavin.com's writeup. Theo Brown ran his own tests and published "Seriously, Anthropic??" on 1 May 2026. Affected users got refunds, and Cherny attributed the bug to the anti-abuse heuristics. I did not re-test the HERMES.md string on 30 October 2026.

You point Pi at a model and it calls the API. A third-party login has already been blocked, restored, and paused once. Keep an API key path when Claude has to run outside Claude Code.

Pi with a Claude subscription logs in, then warns about extra usage

Pi with a Claude subscription sends an OAuth login or a token. An API key is the other Anthropic credential. The sources below were read on 2 November 2026.

The API key is the path both sides describe the same way. Set ANTHROPIC_API_KEY before you start Pi, or store a key with /login. Pi's providers page also accepts ANTHROPIC_AUTH_TOKEN as bearer authentication.

Anthropic's legal and compliance page says subscription OAuth is for ordinary use of Claude Code and other native Anthropic apps. The page tells developers building their own products, including with the Agent SDK, to use an API key. They are not allowed to offer a Claude.ai login, to route Free, Pro, Max, or Ultra credentials for their users, or to collect, store, or intermediate Claude.ai credentials. Sign-in has to finish through Anthropic's own flow. Signing in to the unmodified Claude Code binary with your own plan is the case that page allows.

Pi's repo also ships a subscription login. The Anthropic provider registers OAuth under the name "Anthropic (Claude Pro/Max)", with isSubscription: true, in packages/ai/src/providers/anthropic.ts. /login then offers browser login or copy-code login against https://claude.ai/oauth/authorize (packages/ai/src/auth/oauth/anthropic.ts). The containerization doc shows a token route under the heading "Use a Claude Pro or Max token": run claude setup-token in Claude Code and pass the value as ANTHROPIC_OAUTH_TOKEN. The providers page lists that variable as an API credential.

When the selected model is Anthropic and the stored credential is OAuth, or the key starts with sk-ant-oat, Pi prints this from interactive-mode.ts:

Anthropic subscription auth is active. Third-party harness usage draws from extra usage and is billed per token, not your Claude plan limits. Manage extra usage at https://claude.ai/settings/usage. Disable this warning in /settings.

The settings page names the switch warnings.anthropicExtraUsage, on by default, and describes it as a warning "when Anthropic subscription authentication may use paid extra usage."

Anthropic's pages do not clearly say that this login spends a Claude plan inside Pi. The authentication page says claude setup-token creates a one-year token for Claude Code, set as CLAUDE_CODE_OAUTH_TOKEN, and that the token authenticates with a Pro, Max, Ultra, Team, or Enterprise subscription. The page covers Claude Code. It does not mention Pi or ANTHROPIC_OAUTH_TOKEN.

The Agent SDK help article, read on 2 November 2026, still carries two notes. On 7 October 2026, a signed-in Agent SDK and claude -p draw from subscription limits, and monthly API credits on Max, Ultra, and Team cover the Claude API, Claude Managed Agents, and the Agent SDK and claude -p when the API key comes from the linked Claude Console organization. On 15 June 2026, the announced changes are paused, and the Agent SDK, claude -p, and third-party app usage still draw from subscription limits. The article names the Agent SDK and claude -p. Pi's warning says extra usage, billed per token. Neither page reports what a Pi request is billed against.

How each tool understands your code

Context loading

Pi loads context files from the agent directory (~/.pi/agent by default), the working directory, and parent directories. In each directory it takes the first readable file among AGENTS.override.md, AGENTS.md, AGENTS.MD, CLAUDE.md, and CLAUDE.MD. Those files load even if you decline project trust. SYSTEM.md replaces the default prompt. APPEND_SYSTEM.md adds to it. A trusted project's .pi/SYSTEM.md wins over the agent-directory file, and the two are not merged.

Full skill instructions load on demand. The request still carries skill descriptions, tool definitions, and whatever those context files contain. That last part is what burned the Z.ai cap.

Claude Code loads global instructions, the project CLAUDE.md, auto-generated MEMORY.md, and environment info. Sub-agents can take research into a separate context. /compact summarises the session. Which file each tool reads is covered in CLAUDE.md vs AGENTS.md.

Context window: where Pi forces you to be better

When the active branch approaches the model's limit, Pi normally compacts older history. Compaction adds a summary and keeps recent messages. The original entries stay in the session file. /compact runs it by hand, and you can pass instructions for what the summary has to keep. If the provider is down, compaction fails and you run it again. Settings control the automatic pass.

The overhead difference is the 605 token prompt, plus your files. On the Z.ai blowout I blamed the tool. The cause was the instruction files I had ported, which Claude Code had been absorbing.

Extensibility: build it vs ship it

Pi extensions

Pi extensions are TypeScript modules with access to tools, commands, shortcuts, events, and the TUI. You can replace the UI, override a tool, or inject prompt text.

When I first wrote this, MCP was something you built as an extension. Pi 1.0, 1 October 2026, added it, along with codemode. The 1.0 note says they wait until a feature has proved itself, then weigh it against the complexity. The MCP docs show the setup:

pi mcp add filesystem -- npx -y @modelcontextprotocol/server-filesystem .

Servers speak stdio or streamable HTTP. The default exposure is codemode: the tools are callable from a script, and they are not declared to the model. direct declares them like a built-in tool. deferred waits for tool_search. /mcp inspects the connection. Project servers in .pi/mcp.json load only after you trust the project.

Claude Code extensions

MCP is first-class. A plugin marketplace ships with it. Hooks run shell commands on agent events. CLAUDE.md holds project instructions. You work inside Anthropic's harness, and the agent loop stays theirs.

Which approach is better?

If you will spend the time, Pi can be shaped until it matches one workflow. Claude Code is ready on a fresh install. When I needed something done fast, I reached for Claude Code, and for Cursor when I wanted the editor. Pi made me look at every instruction file, and that takes longer.

How much do Pi and Claude Code cost?

Pi

The tool is free, MIT licensed. You pay the provider you connect.

The bills below are from the May 2026 Reddit thread, not a survey I repeated in October. One person said they spend $300 to $600 a month paying by the token. Another was on the OpenAI 5x Pro plan and not hitting limits, and credited the small prompt. One commenter described MiniMax on Pi at $10, with 1,500 requests every 5 hours and no monthly cap. People in the thread were also running Qwen 3.6 on 64GB M4 Pro Macs, and others were on local models, paying nothing beyond electricity.

Claude Code

You need a paid Claude plan. On 30 October 2026, Pro is $20 a month, or $17 a month if you pay $200 for the year. Max starts at $100 a month, with a 5x or 20x usage choice. Claude Code is listed on Pro, Max, Team, and Enterprise. Free does not include it. Pro includes at least 5x the Free plan's usage per 5-hour window. The page gives no fixed message count, because the model and the session length change what that window buys.

Anthropic briefly tested removing Claude Code from Pro in early April 2026, then restored it on 26 April 2026. It is on the pricing page again as of this update. If you are tracking the paused Agent SDK credit, the pricing post has that timeline.

The real comparison

If you only want Claude, Pro at $20 a month is the predictable bill. Claude through Pi on an API key is token pricing on top of any subscription you already pay. Other providers, or a local model, are where Pi costs less, because the tool itself is free.

At the time, Claude Code with Max was what I used at work, and Pi with Codex was what I used on personal projects. I was still working out the split.

What is Pi's session tree feature?

Pi stores the session as a tree. Each entry has an id and a parent. The active branch is what the model sees on the next request. The other branches stay in the file.

From the sessions docs, checked 30 October 2026:

| Command | What it does | | --- | --- | | /tree | Moves inside the current session file. Select a user message and its text comes back to the editor. Edit and submit, and you have another branch. Select an assistant entry and you continue after it with an empty editor. | | /fork | Creates a new session from an earlier user message. pi --fork plus a session path or id does that before the TUI starts. | | /clone | Copies the active branch into a new session. |

When you leave a branch, Pi can summarise it and attach that summary to the branch you enter. The model still receives the active branch, not every branch in the file. /tree is for alternatives you want in one file. /fork is for work that has become its own session.

When to use each

Reach for Pi when

You want more than one provider, and you want the instruction-file cost where you can see it. You are paying by the token, or you are on a local model. You want extensions, RPC, or the SDK. You still add MCP servers yourself. The client has been in the product since 1.0.

Reach for Claude Code when

You want Claude on a monthly plan, with sub-agents, MCP, and memory already there. You want the terminal, the VS Code extension, JetBrains, and the desktop app on one subscription. You need an MCP server declared to the model without an exposure setting.

The verdict

Use Claude Code for Claude work. Use Pi when you want the small prompt, other models, and a session you can fork. Install both if you want that split. The bill is the Claude plan plus whatever you connect to Pi.

Pi's author built it after using Claude Code, to get at the parts a proprietary harness doesn't hand you. If Claude-through-Pi matters to the work, keep an API key path. The help article and the legal page still describe different rules, and the April HERMES.md incident showed a subscription can be rerouted by a string in git history.

If you are also weighing Amp, I ran the same kind of comparison in Amp vs Claude Code.

Frequently asked questions

Is Pi open source?
Yes, under the MIT license. Mario Zechner created it, the repo is earendil-works/pi, and the GitHub API reported 118,887 stars on 30 October 2026. The default tools are read, bash, edit, and write. The tool itself has no paid tier.
Can Pi use Claude models?
Yes. An API key is the path Anthropic's legal page describes for a third-party product. Pi 1.4.0 can also log in with a subscription, then warns that third-party harness usage draws from extra usage, while the help article's 15 June 2026 notice, still up on 30 October 2026, says third-party app usage draws from subscription limits.
How much does Claude Code cost?
Pro is $20 a month, or $17 a month if you pay $200 for the year. Max starts at $100 a month. On 30 October 2026 the pricing page includes Claude Code on Pro, Max, Team, and Enterprise, and not on Free.
What models does Pi support?
The Pi homepage says 15+ providers, including Anthropic, OpenAI, Google, and local models through Ollama. Switch with /model or Ctrl+L, and cycle favourites with Ctrl+P.
Can I use Pi and Claude Code together?
Yes. Install Pi with npm install -g @earendil-works/pi-coding-agent and keep Claude Code for Claude work. They are separate programs. The bill is the Claude plan plus whatever you connect to Pi.
What is Pi's session tree feature?
/tree moves inside the current session file, /fork starts a new session from an earlier user message, and /clone copies the active branch. The model sees the active branch, not every branch in the file.
Is Claude Code free?
No. It needs a paid Claude plan, starting at Pro for $20 a month. Pi itself is free under MIT, and you pay the model provider you connect, which can be nothing beyond electricity if you run a local model through Ollama.