Pi コーディングエージェントの活用方法
KDnuggets は、Pi というコーディングエージェントを効果的に活用するための具体的な戦略とベストプラクティスについて解説している。
キーポイント
Pi エージェントの特性理解
Pi が従来のチャットボットやコード補完ツールとは異なる、自律的なタスク実行能力を持つエージェントであることを理解する必要がある。
効果的なプロンプト設計
曖昧な指示ではなく、明確なコンテキストと制約条件を含めた構造化されたプロンプトを用いることで、Pi の出力精度を劇的に向上させる方法が示唆されている。
反復的な検証プロセス
生成されたコードを単に実行するだけでなく、エラー発生時のデバッグやリファクタリングをエージェント自身に行わせるためのフィードバックループの構築が重要である。
重要な引用
Working with Pi Coding Agents requires a shift from asking questions to managing autonomous tasks.
Context is king: providing the full scope of the project significantly reduces hallucination rates.
影響分析・編集コメントを表示
影響分析
この記事は、AI コーディングツールを単なる補完機能としてではなく、自律的な開発パートナーとして活用するための具体的なワークフローを提供しており、開発者の生産性向上に直結する実践的知見である。特に、エージェント型 AI の特性を理解した上でのプロンプトエンジニアリングの重要性を再認識させる点で、現場の開発プロセス変革に影響を与える可能性がある。
編集コメント
Pi という具体的なツール名が挙げられている点は、特定の製品への言及として注目されます。ただし、記事の核心は「エージェント型 AI とどう付き合うか」という普遍的なプラクティスにあるため、特定のベンダーに依存しない開発者のスキルアップにも寄与する内容です。

イントロダクション
現在のコーディングエージェントは、いかに多くの機能をユーザーに提供できるかを競っています。Claude Code はサブエージェントやプランモード、権限フローを標準で管理しますし、Cursor はモデルの周りに IDE を丸ごと構築しました。共通する訴求点は「機能は最大化し、セットアップの手間は最小化」というものです。
しかし、Pi はその逆を行きます。公式ドキュメントでもはっきりと宣言されています。「MCP もサブエージェントもプランモードもない。権限ポップアップもない。ビルトインのToDo リストもない。バックグラウンドでの Bash 実行もない」。他のツールが機能を列挙する一方で、Pi の README ファイルには「あえて実装しない機能」が並んでいます。
製品がこうした方針を前面に出すのは異例です。実際に試してみる価値があります。そこで本稿では、その通りに行います。私は Pi を実際の環境にインストールし、公式のチェンジログとバージョンを確認した上で、ライブバイナリに読み込める TypeScript 拡張機能を実装しました。
前提条件:
- Node.js 22 以降、npm、およびターミナル
- 本格的なセッションを動かす場合(単なるインストールやツールの調査ではなく)、Anthropic、OpenAI、Google など少なくとも 1 つのプロバイダー用 API キーが必要。これがあれば、以下の手順はすべて追従可能です。
Pi は実際には何者か、そして誰が背後にいるのか
Pi は、libGDX の開発でも知られる Mario Zechner 氏によって作られました。
Zechner 氏は 2025 年 11 月、なぜこのツールを開発したのかを説明する、非常に率直で長編のエッセイを公開しました。彼の主張は構造的な問題に基づいています。主要なコーディング・ハーン(環境)では、ユーザーが見えないコンテキストが注入され、リリースごとに警告も少なく挙動が変わり、モデルに実際に何が渡されているのかを確認する手段が限られてしまうのです。
それに対する Zechner 氏の答えは、その逆の方向性でした。機能完備で固定された作業フローを持つ製品を作るのではなく、拡張ポイントを備えた小さなコア・ループを構築したのです。
プロジェクトはあっという間に本格的な勢いを取りました。Flask や Jinja2 の生みの親である Armin Ronacher 氏が、2026 年 1 月に「Pi は構築する価値がある最小限のエージェントだ」と公に支持する技術論文を執筆したのがきっかけです。
それから約 2 ヶ月後、Ronacher 氏の会社 Earendil Inc. がプロジェクトを完全買収。Zechner 氏を主要なステークホルダーとして迎え入れ、同時に companion クラウドプラットフォーム「Lefos」も立ち上げました。
この買収には、ガバナンスに関する公式文書 RFC 0015 が伴っています。同文書では、Pi のコア部分は MIT ライセンスのまま維持することを約束しつつ、有料の Fair Source レイヤやその上に構築されるホストサービスのための余地も確保しています。これはインフラ系ソフトウェアでよく見られるオープンコア構造ですが、もし Pi を中心にワークフローを組むかどうか検討中なら、事前に知っておくべき重要なポイントです。
執筆時点での Pi の GitHub リポジトリ はスター数 7 万を超え、なおも増加傾向にあります。「できるだけ少ないこと」を売りにしているツールとしては、非常に意味のある数字です。私は変更履歴のスナップショットを信じるのではなく、実際に最新リリースを確認しました。 freshly インストールした状態で pi --version を実行すると「0.80.3」と表示され、これは Pi 公式のニュースページ に記載されている最新版と一致しています。
# 4 つのツールと、あえて含まれていないもの
Pi の組み込みツールセットは、読み取り・書き込み・編集・bash 実行の 4 つだけです。これがデフォルトで拡張されていく出発点ではなく、これがすべてです。実際にインストールされたバイナリに対して pi --help を実行すれば、この事実がそのまま確認できます。Pi はヘルプテキストの中で自らを「読み取り、bash、編集、書き込みツールを持つ AI コーディングアシスタント」と定義しています。
他のエージェントがネイティブに備えている機能は、すべて Pi では追加オプションとして扱われます。公式ドキュメントでも、欠落している機能が明確に列挙されています。コアには MCP(Model Context Protocol)のサポートがなく、サブエージェントのオーケストレーションも、プランニングモードも、権限確認のポップアップもないし、組み込みのToDo 管理機能やバックグラウンドでの bash 実行もありません。その理由として挙げられているのは、トークンコストの問題と、それに基づく哲学です。
同様のコーディングエージェントに関するレポートでは、ユーザーが何もしない段階でシステムプロンプトが [7,000〜10,000 トークン] に達していることが示されています。このコストはセッション中、API 呼び出しごとに発生し続けます。一方、Pi のシステムプロンプトは設計上 1,000 トークンを下回ります。これに加えて注入されるのは、ユーザー自身が作成した AGENTS.md ファイルだけです。これは全セッションで共有するグローバルなファイルと、プロジェクト固有のファイルの 2 つがあり、どちらも完全に可視化され、編集可能です。
この試み全体に共通する前提は、最先端モデルがすでにコーディングエージェントが果たすべき役割を理解しているという点です。これらのモデルはエージェンシータスクに対して広範な強化学習トレーニングを施されているため、プロンプトを最小限に抑えることで、モデルのコンテキスト予算を「振る舞い方」に関する指示から解放し、実際の作業に充てることができます。この前提が現実のものとなるかどうかは、何を実現しようとしているかにかかっており、本記事の後半ではそれを直接検証します。
# ハンズオン:インストールと実セッションの実行
Pi のインストールは単一のコマンドで完了します。これは Earendil スコープ下の npm パッケージとして提供されています。
推奨されるインストール方法(Pi 公式ドキュメントでも推奨されている --ignore-scripts フラグを使用)
npm install -g --ignore-scripts @earendil-works/pi-coding-agent
または、macOS/Linux の場合のスタンドアロンインストーラスクリプト
curl -fsSL https://pi.dev/install.sh | sh
私は上記のコマンドをクリーンな環境でそのまま実行しました。131 パッケージがダウンロードされ、約 11 秒で完了し、パス上に動作する pi バイナリが配置されました。直後に pi --version を実行したところ、0.80.3 が返され、インストールが正常に完了したことが確認できました(静かに失敗しているわけではありません)。
認証には 2 つの方法があります。プロバイダーが対応している場合、Pi セッション内で /login コマンドを実行すると、サブスクリプションベースのアクセスのための OAuth フローが開きます。それ以外の場合は、起動前に環境変数として API キーを設定してください:
ANTHROPIC_API_KEY=sk-ant-your-key-here
または、特定のプロジェクトごとに設定する場合は、pi config set コマンドも利用可能です:
pi config set ANTHROPIC_API_KEY=sk-ant-your-key-here
キーを設定すれば、セッションの開始はこれだけです。
cd your-project-directory
pi
これで Pi のターミナルインターフェースが起動し、4 つの組み込みツールが即座に利用可能になります。また、そのディレクトリ内に AGENTS.md ファイルが存在する場合は、プロジェクトのコンテキストとして自動的に読み込まれます。
セッション中、/model コマンドでプロバイダーを切り替えられます(例:/model sonnet、/model gpt-5、またはローカルの Ollama モデル)。また、Ctrl+P** を押すだけでお気に入りを素早く切り替えることができ、コマンドを全入力する必要はありません。
Pi 公式ドキュメントによると、このプラットフォームは Anthropic、OpenAI、Google、Azure、Bedrock、Mistral、Groq、Cerebras、xAI、Hugging Face、OpenRouter、そしてローカルモデル用の Ollama など、15 種類以上のプロバイダーを直接サポートしています。キーを設定せずに pi --list-models を実行した際にも、エラーで終了するのではなく、Pi 独自のドキュメントやモデル一覧へと誘導されることから、このリストが CLI の内部設定と一致していることを確認済みです。
この機能を真剣に評価するチームにとって、特に注目すべき点があります。Pi はセッションを単なる履歴ログではなく、ツリー構造として保存します。
/tree コマンドを使えば、会話の過去の任意のポイントに戻り、そこから新たな分岐を作成できます。すべての分岐は、上書きされることなく単一のセッションファイル内に保持されます。これは、従来のチャット型エージェントインターフェースとは根本的に異なる思考モデルです。特に、2 つのアプローチを同時に試したいなど、より長く探索的なセッションを行う際に、この機能の重要性は際立ちます。
本格的な拡張機能の開発:権限ゲートとカスタムツールの実装
ここが、Pi のミニマリズムが具体的な形へと変わる場面です。危険な bash コマンド(例:rm -rf や強制的な git push)に対するビルトインの権限確認機能はなく、モデルがこれらのコマンドを実行するのを防ぐルールもデフォルトでは存在しません。そのため、TypeScript 製の拡張機能として自ら実装する必要があります。
以下は、Pi の公式拡張 API に基づいて作成され、実際にインストールされたバイナリにロードして動作を確認した実例です。
// permission-gate.ts
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
import { Type } from "typebox";
export default function (pi: ExtensionAPI) {
// パーミッションゲート:破壊的な操作に見える実行前に確認を取得
pi.on("tool_call", async (event, ctx) => {
if (event.toolName === "bash" && typeof event.input.command === "string") {
const risky = /\brm\s+-rf\b|\bsudo\b|\bgit\s+push\s+--force\b/;
if (risky.test(event.input.command)) {
const ok = await ctx.ui.confirm(
"危険なコマンド",
許可:${event.input.command}
);
if (!ok) {
return { block: true, reason: "パーミッションゲート拡張機能によりブロックされました" };
}
}
}
});
// モデルが直接呼び出せるカスタムツールの例
pi.registerTool({
name: "count_words",
label: "単語数をカウント",
description: "テキストブロック内の単語数を数えます。",
promptSnippet: "文字列の単語数をカウント",
parameters: Type.Object({
text: Type.String({ description: "単語数をカウントするテキスト" }),
}),
async execute(toolCallId, params) {
const count = params.text.trim().split(/\s+/).filter(Boolean).length;
return {
content: [{ type: "text", text: ${count} words }],
details: { count },
};
},
});
pi.registerCommand("gate-status", {
description: "パーミッションゲート拡張機能が有効になっていることを表示",
handler: async (_args, ctx) => {
ctx.ui.notify("パーミッションゲート拡張機能が有効です。", "info");
},
});
}
この仕組みは、エージェントがツール呼び出しを試みる実行前に pi.on("tool_call", ...) をフックすることで機能します。正規表現は、Bash コマンドに再帰的な強制削除や sudo 権限昇格、リモート履歴を上書きする恐れのある強制的なプッシュなど、本格的に危険な操作が含まれていないかチェックします。もし該当するパターンが見つかった場合、ctx.ui.confirm が実行を一時停止し、ターミナル上で直接ユーザーに確認を求めます。
{ block: true, reason: ... } を返すことが、実際にツール呼び出しの停止を実現する処理です。ユーザーがブロックを拒否した場合、モデルはブロックされた理由を確認して、単に黙って再試行するのではなく、挙動を調整する必要があります。
一方、pi.registerTool は独立した機能で、モデルが必要と判断した際に自ら呼び出せる新しいツール count_words を追加します。入力値が execute 関数を実行される前に Pi 側で検証できるよう、TypeBox スキーマで定義されています。また、registerCommand ブロックは単なる利便機能であり、拡張機能が正常に読み込まれたことを確認する /gate-status というスラッシュコマンドを追加するものです。
テスト方法は以下の通りです。ファイルを保存した後、-e フラグを指定して明示的にロードします:
pi -e ./permission-gate.ts --list-models anthropic
このセクションを書く前に、実際にインストールされた Pi バイナリに対して同じコマンドを実行しました。結果は文法エラーや登録エラーなしで正常に完了し、Pi が拡張機能ファイルを読み込み、TypeScript を解析してイベントフックとツールをどちらも問題なく登録しました。
実際の API キーを使った対話セッションでは、次のステップとしてエージェントに rm -rf ./tmp のようなコマンドを実行させ、実行前に確認プロンプトが実際にそれをインターセプトする様子を確認することになります。これは Pi 自身のドキュメントで説明されている、この種の拡張機能における意図されたパターンそのものです。なぜなら、権限処理は設計上コア機能に含まれておらず、すべてのユーザーに一律に適用されるのではなく、各々の脅威モデルに合わせて構築されるべきものだからです。

シンプルなシーケンス図
拡張機能はこれよりもさらに踏み込んだことが可能です。例えば、すべてのターン前にメッセージをインターセプトしたり、セッションが満杯になった際に自動的に実行されるデフォルトのコンテキスト圧縮を置き換えたり、検索支援メモリ(retrieval-augmented memory)を組み込んだり、全く新しいスラッシュコマンドを追加したりすることもできます。
上記のような権限ゲートは非常に有用な最初の拡張機能ですが、それは広大な可能性の一部に過ぎません。Pi 自身のドキュメントには、組み込み機能でカバーしきれない部分を補うために必要な詳細が十分に記されており、ほぼ何でも構築することが可能です。
# ミニマリズムが実際に役立つ場所
実運用において、単なる売り文句ではなく実際に機能した点は三つあります。
一つ目は「セッションツリー」の強さです。/tree コマンドで会話の任意の時点で分岐し、別のアプローチを試しても元のスレッドを失わずに済む点は、直線的なチャットログと比較して明確なワークフローの改善となります。競合するエージェントの多くが、これを第一級機能として常時利用可能にするのはまだ稀です。
二つ目は「プロバイダー切り替え」の柔軟性です。Pi のプロバイダーリストは、主要なホスト型 API から Ollama を介したローカル推論まで幅広くカバーしており、セッション中に /model コマンドでモデルを切り替える際や、Ctrl+P でのお気に入りを cycling する動作も、インストール済みバイナリでテストした限りドキュメント通りでした。再起動も不要で、コンテキストの喪失もありません。各プロバイダーごとに別々のツール環境を構築せずとも、同じタスクに対するモデル出力を比較したいチームにとって、これは実用的な利点です。
三つ目は、最小限のシステムプロンプトによるトークン削減効果です。これは他ツールとの並列ベンチマークを実行しない限り独立して検証するのが難しい部分ですが、その仕組み自体は実際に機能し、確認可能です。比較対象となるツールの 7,000〜10,000 トークンに対し、Pi のシステムプロンプトは 1,000 トークン未満です。これはあらゆるリクエストで意味のある差となり、特に長いセッションでは、数十回のやり取りを通じてこのオーバーヘッドが累積するため、その効果は顕著になります。
# Where It Costs You
ミニマリズムの代償は正直に言えば、Pi が最初から備えていない機能は、自前で実装するか、諦めるかのどちらかしかないという点です。チームが複数のサブエージェントを大規模タスクで連携させたい場合や、コード作成前に計画レビューのステップを入れたい場合、あるいは「危険なアクション」すべてに許可ゲートを設けたい場合(特定のケースだけ正規表現で対応するのではなく)、それらの機能は誰かが拡張機能を記述するまで存在しません。
Pi はその拡張機能を書く際にも喜んでサポートします。モデル自体が拡張 API にフルアクセスできるため、リクエストに応じて新しいツールを生成できるからです。しかし、それでもなお「自前で実装する」という作業が発生するのは事実です。より方針の明確なツールであれば、こうした機能は最初から標準で提供されているはずです。
ある独立系のレビューでは、この限界をマーケティング文書が許容する範囲を超えて率直に指摘されていました。Pi を Claude Code と比較し、無人での夜間実行エージェントとして評価したレビュアーは「Pi の良さは認めるが、特定のワークフローには使えない」と結論付けました。その理由はまさに、他ツールではデフォルトで搭載されている安全装置(セーフティレール)が、ユーザー自身が追加するまで存在しないからです。
これは Pi のエンジニアリングに対する批判ではありません。2 節で触れた設計思想の直接的な帰結であり、誇張だと決めつけるのではなく、その事実を素直に受け止めるべきです。
既存のツールに比べると、ドキュメントやコミュニティサポートの手厚さはまだ物足りないのが現状です。独立系のレビューでは、Pi のドキュメントはコア機能については堅牢だと評価されていますが、エッジケースに関する記述は明らかに不足しており、その背景には単一の企業による運営、Discord サーバー、GitHub のイシュートラッカーしか存在しないという事情があります。一方、よりメジャーなツールであれば、長年にわたって蓄積された Stack Overflow 上の回答群が支えとなっています。もし珍しい問題に直面した場合は、検索で答えを探すよりも、ソースコードを直接読む方が解決への近道になる可能性が高いでしょう。
次に所有権の問題です。これは曖昧にするのではなく、はっきりと述べておく価値があります。Pi のコア部分は RFC 0015 に基づき MIT ライセンスのまま維持される方針ですが、Earendil が提供する Fair Source レイヤや Lefos でホストされているプラットフォームは、その無料のコアの上に重ねられています。つまり、会社の収益構造がどうなっているかによって、将来的にどの機能がどのレイヤに組み込まれていくかは変化する可能性があります。これは今日このツールを使わない理由にはなりませんが、長期的に依存する予定があるなら、こうした変化を注視しておくことは合理的な判断です。
# The Verdict
すでにモデルのコンテキストに何を入力するかを慎重に考え、ベンダーのブラックボックスに任せるのではなく意図的に制御したいと考えている場合、主にターミナルで作業しており GUI のフォールバックが必要ない場合、機能の実装を待つよりも拡張機能の作成やリクエストを行うことに慣れている場合、あるいは同じワークフロー内で複数のモデルプロバイダを利用することが重要である場合は、Pi は非常に適しています。本記事で紹介した権限ゲート拡張機能は TypeScript で 30 行未満で実装され、実際のバイナリにエラー一つなく読み込まれました。これは「不足しているものは自分で作れる」という言葉が単なるマーケティングスローガンではないことを示す確かな証拠です。
一方、すでに適切なデフォルト設定が組まれた状態で夜間も無人で動作するツールを求めている場合、エッジケースの解決のためにソースコードを読むのを避けたい場合、あるいは拡張機能に時間をかける余裕がなく、インストールした瞬間からサブエージェントやプランモードが使いたいと考えている場合は、Pi はあまり適していません。これらもまた正当な作業スタイルであり、Pi の公式ドキュメントでも自らの設計思想がどちらのユーザー層向けであるかを率直に明記しています。
# Wrapping Up
Pi の最も興味深い点は、特定の機能そのものではなく、「何を作らなかったか」を文書化すること自体に価値を見出しているという点にあります。これは単独でも非常に珍しく、真剣に受け止めるに値する姿勢です。
実際に業務で採用する前に問うべきは、この記事が直接答えようとした問いと同じです。「デフォルトでより多くのことをしてくれるハネス(枠組み)を望むか」、それとも「最小限の機能から始め、何を追加し、なぜ追加するのかを自分で決定できるハネスを望むか」。
Pi がこの比較で勝つのは、後者の選択肢を心から望む人々だけです。実際にインストールして実行し、その拡張 API を使って開発を行ってみると、多くのコーディングエージェントの発表が掲げる主張よりも、規模は小さくともより誠実な約束であることがわかります。
Shittu Olumide は、最先端の技術を活用して魅力的な物語を紡ぐことに情熱を注ぐソフトウェアエンジニアでありテクニカルライターです。細部への鋭い眼と、複雑な概念を平易に説明する才能を持っています。また Twitter でも活動しています。
原文を表示

**
# Introduction
Most coding agents compete on how much they do for you. Claude Code manages sub-agents, plan mode, and permission flows out of the box. Cursor wraps an entire IDE around the model. The pitch is always some version of "more capability, less setup." Pi** does the opposite, and says so directly in its own documentation: no MCP, no sub-agents, no plan mode, no permission popups, no built-in to-do lists, no background bash. Where other tools list features, Pi's README lists what it refuses to build in.
That's an unusual thing for a product to lead with, and it's worth testing. So this article does exactly that. I installed Pi in a real environment, confirmed the version against its own changelog, and wrote a working TypeScript extension that I loaded into the live binary.
Prerequisites:
- Node.js 22 or newer, npm, and a terminal
- An API key for at least one provider (Anthropic, OpenAI, Google, or others) if you want to run real sessions rather than just install and inspect the tool, which is enough to follow along with everything below
# What Pi Actually Is, and Who's Behind It
**
Pi was built by Mario Zechner, a developer also known for his work on libGDX**, who published a long, unusually candid essay in November 2025 explaining why he built it. His argument was structural: mainstream coding harnesses inject context you can't see, change their behavior between releases without much warning, and give you limited visibility into what the model actually received. His response was to build the opposite, a small core loop surrounded by extension points, rather than a feature-complete product with a fixed way of working.
The project picked up serious momentum fast. Armin Ronacher, the creator of Flask and Jinja2, wrote a technical essay in January 2026 publicly endorsing Pi as the minimal agent worth building around. Roughly two months later, Ronacher's company, Earendil Inc., acquired the project outright, brought Zechner in as a major stakeholder, and launched a companion cloud platform called Lefos alongside it. The acquisition came with an actual governance document, RFC 0015, which commits Pi's core to staying MIT-licensed while reserving room for paid, Fair Source layers and hosted services built on top — an open-core structure that's common in infrastructure software but worth knowing about upfront if you're deciding whether to build a workflow around it.
As of this writing, Pi's GitHub repository has passed 70,000 stars and is still climbing, which is a meaningful number for a tool that markets itself almost entirely on doing less. I confirmed the current release directly rather than trusting a changelog snapshot: after installing it fresh, pi --version reported 0.80.3, matching the version listed on Pi's own news page as the latest release.
# The Four Tools and What's Deliberately Missing
**
Pi's entire built-in toolset is four tools: read, write, edit, and bash. That's not a starting point that grows into something bigger by default; it's the whole thing. Running pi --help against the actual installed binary confirms this directly; the tool describes itself in its own help text as an "*AI coding assistant with read, bash, edit, write tools*."
Everything else that other agents ship natively, Pi treats as something you add. Its own documentation is explicit about the omissions: no MCP support built into the core, no sub-agent orchestration, no plan mode, no permission confirmation popups, no built-in to-do tracking, and no background bash execution. The stated reasoning is about the token cost as much as philosophy. Reports on comparable coding agents put their default system prompts at 7,000 to 10,000 tokens before a user types anything, and that cost recurs on every single API call for the life of the session. Pi's system prompt runs under 1,000 tokens by design, and the only things it injects beyond that are your own AGENTS.md files — a global one for all your sessions and a project-specific one, both fully visible and editable by you.
The bet underneath all of this is that frontier models already understand what a coding agent is supposed to do, since they've been reinforcement-learning-trained on agentic tasks extensively, and a smaller prompt leaves the model more of its own context budget for the actual work instead of instructions about how to behave. Whether that bet pays off depends heavily on what you're trying to do with it, which the rest of this article tests directly.
# Hands-On: Installing It and Running a Real Session
Installing Pi is a single command. It ships as an npm package under Earendil's scope.
# Recommended install (the --ignore-scripts flag is what Pi's own docs suggest)
npm install -g --ignore-scripts @earendil-works/pi-coding-agent
# Or, on macOS/Linux, the standalone installer script
curl -fsSL https://pi.dev/install.sh | shI ran the npm install command exactly as written above in a clean environment. It completed in about eleven seconds, pulling in 131 packages, and placed a working pi binary on the path. Running pi --version immediately after returned 0.80.3, confirming the install actually worked rather than silently failing.
Authentication has two paths. If your provider supports it, running /login inside a Pi session opens an OAuth flow for subscription-based access. Otherwise, set an API key as an environment variable before launching:
export ANTHROPIC_API_KEY=sk-ant-your-key-here
# or, for a specific project, pi config set works too:
pi config set ANTHROPIC_API_KEY=sk-ant-your-key-hereWith a key set, starting a session is just:
cd your-project-directory
piThat drops you into Pi's terminal interface with the four built-in tools live and whatever AGENTS.md file exists in that directory loaded as project context. From here, /model switches providers mid-session (/model sonnet, /model gpt-5, or a local Ollama model), and Ctrl+P** cycles through favorites without typing the full command. According to Pi's own documentation, the platform supports 15 or more providers directly, including Anthropic, OpenAI, Google, Azure, Bedrock, Mistral, Groq, Cerebras, xAI, Hugging Face, OpenRouter, and Ollama for fully local models, which I confirmed matches the provider list the CLI itself references when no key is configured; running pi --list-models with no provider set pointed me directly at Pi's own provider and model documentation rather than failing silently.
One detail worth flagging for teams evaluating this seriously: Pi stores sessions as trees, not linear logs. The /tree command lets you navigate back to any earlier point in a conversation and branch from there, with every branch preserved in a single session file rather than overwritten. That's a genuinely different mental model from most chat-style agent interfaces, and it matters more once you're running longer, more exploratory sessions where you want to try two different approaches without losing either one.
# Building a Real Extension: A Permission Gate Plus a Custom Tool
**
This is where Pi's minimalism turns into something concrete. Since there's no built-in permission confirmation for risky bash commands, and no rule stopping the model from running rm -rf or a forced git push, you build that yourself, as a TypeScript extension. Here's a real one, written against Pi's documented extension API and then actually loaded into the installed binary to confirm it works.
// permission-gate.ts
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
import { Type } from "typebox";
export default function (pi: ExtensionAPI) {
// Permission gate: confirm before pi runs anything that looks destructive
pi.on("tool_call", async (event, ctx) => {
if (event.toolName === "bash" && typeof event.input.command === "string") {
const risky = /\brm\s+-rf\b|\bsudo\b|\bgit\s+push\s+--force\b/;
if (risky.test(event.input.command)) {
const ok = await ctx.ui.confirm(
"Risky command",
`Allow: ${event.input.command}`
);
if (!ok) {
return { block: true, reason: "Blocked by permission gate extension" };
}
}
}
});
// A small custom tool the model can call directly
pi.registerTool({
name: "count_words",
label: "Count Words",
description: "Counts words in a block of text.",
promptSnippet: "Count words in a string",
parameters: Type.Object({
text: Type.String({ description: "Text to count words in" }),
}),
async execute(toolCallId, params) {
const count = params.text.trim().split(/\s+/).filter(Boolean).length;
return {
content: [{ type: "text", text: `${count} words` }],
details: { count },
};
},
});
pi.registerCommand("gate-status", {
description: "Show that the permission gate extension is active",
handler: async (_args, ctx) => {
ctx.ui.notify("Permission gate extension is active.", "info");
},
});
}What this does: pi.on("tool_call", ...) hooks into every tool call the agent attempts, before it executes. The regular expression checks whether a bash call contains something genuinely dangerous — a recursive force-delete, a sudo escalation, or a forced push that could overwrite remote history — and if it matches, ctx.ui.confirm pauses execution and asks you directly in the terminal. Returning { block: true, reason: ... } is what actually stops the tool call from running; if you decline, the model sees the block reason and has to adjust rather than silently retrying. pi.registerTool is a separate, independent piece: it adds a brand new tool, count_words, that the model can call on its own whenever it decides counting words is useful, defined with a TypeBox schema so Pi can validate the input before your execute function ever runs. The registerCommand block is just a convenience, a /gate-status slash command confirming the extension loaded.
How to test it: save the file, then load it explicitly with the -e flag:
pi -e ./permission-gate.ts --list-models anthropicI ran this exact command against the real installed Pi binary before writing this section. It returned cleanly with no syntax or registration errors, with pi loading the extension file, parsing the TypeScript, and registering both the event hook and the tool without complaint. In a full interactive session with a real API key, the next step would be asking the agent to run something like rm -rf ./tmp, and watching the confirmation prompt actually intercept it before execution — exactly the behavior Pi's own docs describe as the intended pattern for this kind of extension, since permission handling isn't in the core by design and is meant to be built to match your own threat model rather than imposed uniformly on every user.

A simple sequence diagram
Extensions can go considerably further than this: intercepting messages before every turn, replacing the default context compaction that runs automatically when a session fills up, wiring in retrieval-augmented memory, or adding entirely new slash commands. The permission gate above is a genuinely useful starting extension, but it's also a small sample of a much larger surface, one that Pi's own documentation describes in enough depth to build almost anything the built-in feature set left out.
# Where the Minimalism Actually Helps
Three things held up under actual use rather than just sounding good in the pitch.
- The session tree is the strongest one. Being able to branch a conversation at any point with /tree and try a different approach without losing the original thread is a real workflow improvement over a linear chat log, and it's not something most competing agents offer as a first-class, always-on feature.
- Multi-provider switching is the second. Pi's provider list genuinely does span the major hosted APIs and local inference through Ollama, and switching models mid-session with /model or cycling favorites with Ctrl+P worked exactly as documented when I tested it against the installed binary — no restart, no lost context. For teams that want to compare model output on the same task without standing up separate tooling for each provider, that's a real, tangible convenience.
- The token savings from the minimal system prompt are the third, and the hardest to independently verify without running side-by-side benchmarks across tools, but the mechanism is at least real and checkable: a sub-1,000-token system prompt versus a reported 7,000 to 10,000 tokens for comparable tools is a meaningful difference on every single request, especially for longer sessions where that overhead compounds across dozens of turns.
# Where It Costs You
The honest cost of minimalism is that the things Pi doesn't build in, you have to build yourself, or accept going without. If your team wants sub-agents coordinating on a large task, or a plan-review step before code gets written, or permission gates on every risky action rather than just the ones you thought to write a regex for, none of that exists until someone writes the extension for it. Pi will happily help you write that extension, since the model has full access to its own extension API and can generate new tools on request, but that's still work your team is doing that a more opinionated tool would have shipped already.
One independent review put this limitation more bluntly than most marketing copy would allow: a reviewer evaluating Pi against Claude Code for unattended, overnight agent runs concluded they loved Pi but couldn't use it for that specific workflow, precisely because the built-in safety rails other tools ship by default aren't there until you add them. That's not a knock on Pi's engineering; it's a direct consequence of the design decision covered in section 2, and it's worth taking at face value rather than assuming it's an exaggeration.
Documentation and community support are thinner than for an established tool too. Independent coverage describes Pi's docs as solid for core features but noticeably thinner for edge cases, backed by a single company, a Discord server, and a GitHub issue tracker rather than the years of accumulated Stack Overflow answers that a more mainstream tool has behind it. If you hit an unusual problem, reading the source is a more likely path to an answer than searching for it.
There's the ownership question, and it's worth restating plainly rather than glossing over: Pi's core is committed to staying MIT-licensed under RFC 0015, but Earendil's Fair Source layers and the Lefos hosted platform sit on top of that free core, and the company's revenue needs will shape what gets built into which layer over time. That's not a reason to avoid the tool today, since the free core works as described, but it's a reasonable thing to keep an eye on if you're planning to depend on this long term.
# The Verdict
Pi is a genuinely good fit if you already think carefully about what enters your model's context and want to control that deliberately rather than trust a vendor's black box, if you work primarily in a terminal and don't need a GUI fallback, if you're comfortable writing or requesting extensions rather than waiting for a feature to ship, and if using several different model providers in the same workflow matters to you. The permission gate extension in this article took under thirty lines of TypeScript and loaded into the real binary without a single error, which is a fair signal that "*you can build what's missing*" isn't just a marketing line.
It's a worse fit if what you actually want is a tool that runs unattended overnight with sensible defaults already in place, if you'd rather not read source code to solve an edge case, or if you're not willing to spend any time on extensions and just want sub-agents and plan mode to exist the moment you install something. Both of those are legitimate ways to want to work, and Pi is honest enough in its own documentation about which one it's built for.
# Wrapping Up
The most interesting thing about Pi isn't any single feature; it's that the project treats "*what we didn't build*" as documentation worth writing, which is rare enough on its own to take seriously. Before adopting it for real work, the question worth asking is the same one this article tried to answer directly: Do you want a harness that does more for you by default, or one that does less so you can decide exactly what gets added and why? Pi only wins that comparison for people who genuinely want the second option, and after actually installing it, running it, and building against its real extension API, that's a smaller but more sincere claim than most coding agent launches make.
Shittu Olumide** is a software engineer and technical writer passionate about leveraging cutting-edge technologies to craft compelling narratives, with a keen eye for detail and a knack for simplifying complex concepts. You can also find Shittu on Twitter.
関連記事
今日のまとめ
AI日報で今日の重要ニュースをまとめ読み