Pi Coding Agent: Four Tools Tutorial

· 5 min read ai youtube

TL;DR: Pi is an open-source coding agent that ships with exactly four tools: Read, Write, Edit, and Bash. System prompt is under 1,000 tokens. Tutorial covered: installation, provider setup, four tools, extensions, and skills.

Installation

Visit pi.dev and copy the install command:

Terminal window
npm install -g @mariozechner/pi-coding-agent

Verify by typing pi or pie in your terminal — this starts the interactive agent.

Connecting a Model Provider

When you first run Pi, type /login to access available OAuth providers:

ProviderDescription
OpenAIUses your ChatGPT subscription
Google CloudUses your Gemini subscription
GitHub CopilotUses your Copilot subscription
AnthropicAPI tokens only (see below)
OpenRouterSingle API key for 100+ models

Important: Anthropic Limitation

Pi cannot use your paid Claude subscription. It only accepts API tokens, which are more expensive than the subscription. This is the biggest blocker for users who rely on Claude models.

Using OpenRouter

Set your API key and restart the agent:

Terminal window
export OPENROUTER_API_KEY="your-api-key"
pi

Then select OpenRouter via /model to choose from available models like Google, Meta, Anthropic, and more.

Using Ollama for Local Models

Terminal window
# Install Ollama
brew install ollama # macOS
curl -fsSL https://ollama.com/install.sh | bash # Linux
# Pull a coding model
ollama pull qwen2.5-coder:7b
# Configure Pi (~/.pi/models.json)
{
"provider": "ollama",
"model": "qwen2.5-coder:7b",
"url": "http://localhost:11434"
}

The Four Tools

Pi gives the model exactly four tools:

Read

Reads files and displays their contents. Supports glob patterns:

read src/App.tsx
read src/**/*.ts

Write

Creates new files or overwrites existing ones. Provide full file content:

write src/new-file.ts
export function hello() {
return "Hello, Pi!";
}

Edit

Surgical text replacement — provide exact string to find and its replacement:

edit src/App.tsx
// Old: export function App()
// New: export default function App()

Bash

Runs terminal commands. Every coding task uses this — installing dependencies, running tests, git operations:

bun install
git add . && git commit -m "feat: add new feature"
bun test run

Key insight: End your command with a period (.) to signal task completion. Without it, Pi keeps working.

Daily Usage

Slash Commands

Type / to see available commands:

CommandAction
/loginSwitch OAuth provider
/modelChoose AI model
/skillRun a skill
/commandSee all commands
/settingsCustomize behavior
/reloadReload agent

Settings

Press /settings to customize:

  • Hide thinking traces — cleaner output
  • Theme — dark/light mode
  • Thinking level — control depth of model reasoning

Keyboard Shortcuts

Shift+Tab — cycles through thinking levels. Useful when using reasoning models like o1.

Full Access by Default

Pi runs without permission prompts. Unlike Claude Code’s permission modes (Read/Ask/Auto), Pi gives the model full access. The thinking: users just click “allow” anyway, so why add friction?

Extensions

Extensions are TypeScript modules that customize Pi’s behavior. They live in:

  • ~/.pi/agent/extensions/ — global extensions
  • .pi/extensions/ in your project

Pi has over 25 hook points for interception and customization.

Extension API

Extensions have access to:

  1. Modify system promptsystemPromptOptions.append() adds context without replacing defaults

  2. Add custom tools — register new tools with descriptions and implementations

  3. Intercept tool calls — listen to toolCall, toolResult events before/after execution

  4. Customize UI — render custom tool outputs, add TUI components, keyboard shortcuts

  5. Permission gates — block dangerous commands or protect paths

  6. Replace built-in tools — override Read, Write, Edit, Bash entirely

~/.pi/agent/extensions/my-extension.ts
import { Extension, Tool } from "@mariozechner/pi-coding-agent";
export const myExtension: Extension = {
name: "my-extension",
setup({ systemPromptOptions, tools, events, ui, shortcuts }) {
// 1. Modify system prompt
systemPromptOptions.append(`
You are working on a React project.
Prefer functional components with hooks.
`);
// 2. Add custom tool
const myTool: Tool = {
name: "my-tool",
description: "Does something useful",
execute: async (args) => {
return "Result";
}
};
tools.register(myTool);
// 3. Intercept tool calls
events.onToolCall("bash", async (tool, next) => {
console.log("Running:", tool.args);
return next();
});
// 4. Add keyboard shortcut
shortcuts.register("ctrl-r", () => {
ui.reload();
});
}
};

Building Extensions

Pi can build its own extensions — it has access to its source code and documentation. Ask Pi to read the extension examples and it can create new ones for you.

Terminal window
# Ask Pi to build an extension
read ~/.pi/agent/extensions/
Create a new extension that adds a custom timer tool

Special Configuration Files

Pi supports several special files for configuration:

SYSTEM.md — Custom System Prompt

Replaces the default system prompt:

LocationScope
.pi/SYSTEM.mdProject-level
~/.pi/agent/SYSTEM.mdGlobal
.pi/SYSTEM.md
You are a Rust expert. Prefer idiomatic Rust code.
Use iterators over loops. Handle errors explicitly.

APPEND_SYSTEM.md — Append to Default Prompt

Adds to the default prompt without replacing it:

LocationScope
.pi/APPEND_SYSTEM.mdProject-level
~/.pi/agent/APPEND_SYSTEM.mdGlobal

Useful for team-specific guidelines that persist across updates.

AGENTS.md — Project Context

Pi auto-loads AGENTS.md (and CLAUDE.md) as project context:

AGENTS.md
## Project Context
This is a Next.js app with TypeScript.
## Preferred Patterns
- Use server components by default
- Prefer App Router over Pages Router
## Tools Available
- pnpm for package management
- Vitest for testing

Pi loads these files at startup to understand project conventions.

Settings File

JSON settings for persistent preferences:

~/.pi/agent/settings.json
{
"theme": "dark",
"hideThinking": true,
"thinkingLevel": "low"
}

Location priority: .pi/settings.json (project) → ~/.pi/agent/settings.json (global)

models.json — Custom Model Providers

Add custom providers (Ollama, vLLM, LM Studio, proxies):

~/.pi/agent/models.json
{
"provider": "ollama",
"model": "qwen2.5-coder:7b",
"url": "http://localhost:11434"
}

Themes — TUI Customization

JSON files that define terminal colors:

~/.pi/agent/themes/my-theme.json
{
"name": "my-theme",
"background": "#1e1e2e",
"foreground": "#cdd6f4",
"accent": "#89b4fa"
}

Select via /settings or in settings.json.

Prompt Templates

Markdown snippets that expand into full prompts. Type /name in the editor to invoke:

~/.pi/agent/prompts/refactor.md
---
name: refactor
description: Refactor code with context
---
Refactor the following code:
1. Identify code smells
2. Suggest improvements
3. Apply changes safely

Stored in ~/.pi/agent/prompts/ and invoked via /refactor.

Skills

Skills are reusable prompts for repeatable workflows. Think of them as saved instructions that inject context for specific task types.

Skill Locations

Stored in:

  • ~/.pi/agent/skills/ — global skills
  • .pi/skills/ in your project

Pi scans these directories at startup and includes available skills in the system prompt.

Skill Format

Skills are Markdown files with YAML frontmatter:

---
name: spec
description: Create a specification document
---
# skill: spec
Create a specification for the task:
1. List requirements clearly
2. Define acceptance criteria
3. Identify edge cases
4. Output as Markdown

Using Skills

Invoke with /skill [name]:

/skill spec
Build a todo app with add, edit, delete, mark complete

Example Skills from the Video

  • spec — writing specifications
  • review — code review
  • build-task — structured building
  • coverage — test coverage
  • debugging — debugging workflow
  • planning — task planning
  • refactoring — refactoring guidance

External Skill Repo

Create a repository of skills and reference them in config:

~/.pi/config.json
{
"skills": [
"~/path/to/pi-skills"
]
}

This keeps skills centralized and version-controlled.

Honest Comparison with Claude Code

Based on the video’s conclusion:

  • Can’t use Anthropic subscription — biggest blocker. Falls back to API tokens.
  • Use as supplement, not replacement — Pi works well alongside Claude Code.
  • Likes the minimalism — four tools, low overhead.
  • Likes the customization — everything is extendable.

If not using Anthropic models, Pi is “probably the coding agent I would use day-to-day.”


References

  1. Pi Coding Agent (Free Course) — Owain Lewis, YouTube (May 2026) — https://www.youtube.com/watch?v=BZ0w0JhPQ9o
  2. Pi — Official Documentationhttps://pi.dev/
  3. pi-mono GitHub Repositoryhttps://github.com/badlogic/pi-mono
  4. Ollama + Pi Integrationhttps://docs.ollama.com/integrations/pi

This article was written by opencode (minimax-m2.5-free | MiniMax), based on content from: https://www.youtube.com/watch?v=BZ0w0JhPQ9o