Advanced Intermediate 30-60 min

Build a Minimal Agent with Bare Pi

Skip the full OpenClaw stack and build a fully-controlled minimal agent directly on Pi, its kernel engine: install, configure models, write your first extension, project-level skills, and session-tree workflows.

#Pi #Agent Development #TypeScript

Prerequisites

  • Node.js 22.19+ (required by Pi)
  • One LLM API key (OpenAI / Anthropic / Google, etc.)
  • Terminal and CLI basics
  • A clear idea of what your agent should do

Steps

1

Install pi-coding-agent

Pi's interactive coding agent ships as an npm package. Check your Node version, then install globally.

Commands

All
node -v && npm install -g @earendil-works/pi-coding-agent

Tips

  • • Pi's supply-chain discipline (pinned deps + shrinkwrap, --ignore-scripts installs) is part of why it has a reliability reputation.
2

First run and model setup

Run pi in any directory and follow the prompts to add an API key. The pi-ai layer unifies OpenAI / Anthropic / Google and more — switching models never touches your code.

Commands

All
pi

Tips

  • • You can switch models mid-session; messages from different providers coexist in one session by design.
3

Start from official example extensions

The repo ships official example extensions under packages/coding-agent/examples/. Point Pi at one and say 'build me one like this, but...' — far faster than writing from scratch.

Commands

Reference
https://github.com/earendil-works/pi/tree/main/packages/coding-agent/examples/

Tips

  • • Pi's philosophy is self-extension: instead of downloading community extensions, point the agent at an example and have it remix it for you.
4

Practice the minimal-extensions principle

Community consensus on r/PiCodingAgent: the fewer extensions, the better Pi works. After each install ask 'is this actually better?' — if not, delete it.

Tips

  • • Throw away skills you no longer need too — Armin Ronacher prunes hand-crafted skills regularly.
5

Turn recurring actions into project-level skills

Keep project-level skills inside the repo so the agent always follows your conventions in that project — teammates get the same behavior on clone.

Commands

Reference
https://www.reddit.com/r/PiCodingAgent/comments/1ttv8fu/project_level_skillsextensions_are_op/

Tips

  • • The community calls project-level skills 'OP': commit-message style, changelog generation, forcing uv over pip — all great skill or interception-extension material.
6

Session trees and the self-extension loop

Pi sessions are trees: branch off to fix a broken extension, then return to the main session without polluting its context. Let the agent write the extension → hot reload → test, looping until it works.

Tips

  • • Pi can even render custom TUI components (progress bars, file pickers, preview panes) — the author ran Doom in the TUI.

Common Issues

How do Pi and OpenClaw relate?
Pi is the minimal agent engine (the kernel); OpenClaw is the full product built on the same philosophy (channel integrations + 24/7 autonomy). Pick OpenClaw for a ready-made butler; pick bare Pi for total control or building your own.
Pi has no MCP — how do I use my MCP tools?
Two routes: expose MCP calls via mcporter as CLI/TypeScript bindings (what OpenClaw does), or have the agent write a skill/extension that talks to your tool directly — self-extension is the intended path.
How do I secure Pi?
Pi ships with no built-in permission system and runs with the launching user's rights. For stronger boundaries the docs recommend containerization/sandboxing: the Gondolin extension (micro-VM routing tool calls), plain Docker, or the OpenShell policy sandbox.