{"slug": "pi-the-open-source-ai-coding-agent-you-probably-haven-t-tried-yet", "title": "Pi: The Open-Source AI Coding Agent You Probably Haven't Tried Yet", "summary": "The open-source AI coding agent pi, from the earendil-works project on GitHub, has surpassed 46,000 stars and offers a terminal-based assistant that reads files, writes code, runs shell commands, and iterates on tasks within a user's project directory. Built entirely in TypeScript and distributed as npm packages, the tool can be installed in under five minutes with a single command and supports authentication via subscription login or API keys for providers including Anthropic, OpenAI, Google, and GitHub Copilot. Pi automatically loads project-specific instructions from `AGENTS.md` or `CLAUDE.md` files, saves session history for resuming or forking conversations, and can operate in non-interactive mode for scripting and automation.", "body_md": "If you've been following the AI coding agent space, you've likely heard of Claude Code, GitHub Copilot, or Codex. But there's a fast-moving open-source alternative sitting at over 46,000 GitHub stars that deserves a serious look: **pi**, from [earendil-works/pi](https://github.com/earendil-works/pi).\n\nThis article walks you through what pi actually is, how to get it running in under five minutes, and whether it's worth adding to your workflow.\n\nPi is a monorepo of tools built for constructing and running AI agents. The centerpiece is a **coding agent CLI** — a terminal-based assistant that can read your files, write code, run shell commands, and iterate on tasks, all within your actual project directory.\n\nThe repo is built entirely in TypeScript and ships as a set of npm packages:\n\n`@earendil-works/pi-coding-agent`\n\n— the interactive CLI you'll use day to day`@earendil-works/pi-agent-core`\n\n— the agent runtime (tool calling, state management) for building your own agents`@earendil-works/pi-ai`\n\n— a unified LLM API layer that normalizes OpenAI, Anthropic, Google, and others behind one interface`@earendil-works/pi-tui`\n\n— a terminal UI library with differential rendering`@earendil-works/pi-web-ui`\n\n— web components for AI chat interfaces**Prerequisites:** Node.js installed, and an API key or existing subscription (Claude Pro, ChatGPT Plus, or GitHub Copilot).\n\n```\nnpm install -g @earendil-works/pi-coding-agent\n```\n\nThat's the whole install. No Docker, no Python environment, no build step.\n\nIf you prefer another package manager:\n\n```\npnpm add -g @earendil-works/pi-coding-agent\n# or\nyarn global add @earendil-works/pi-coding-agent\n# or\nbun add -g @earendil-works/pi-coding-agent\n```\n\nPi supports two authentication paths.\n\n**Option A — Subscription login (Claude Pro/Max, ChatGPT Plus/Pro, GitHub Copilot):**\n\nStart pi from any directory and run:\n\n```\npi\n/login\n```\n\nA prompt will appear to select your provider. This stores credentials in `~/.pi/agent/auth.json`\n\n.\n\n**Option B — API key:**\n\n```\nexport ANTHROPIC_API_KEY=sk-ant-...\npi\n```\n\nYou can use `OPENAI_API_KEY`\n\n, `GOOGLE_API_KEY`\n\n, or others the same way. The `/login`\n\ncommand can also store API keys interactively so you don't need to export them every session.\n\nNavigate to your project and launch:\n\n```\ncd /path/to/your/project\npi\n```\n\nPi starts in interactive mode and loads your project directory as its working context. Type a request and press Enter:\n\n```\nSummarize this repository and tell me how to run its checks.\n```\n\nOut of the box, the agent has access to four tools: `read`\n\n(read files), `write`\n\n(create or overwrite files), `edit`\n\n(patch files), and `bash`\n\n(run shell commands). Additional read-only tools like `grep`\n\n, `find`\n\n, and `ls`\n\nare available through tool options.\n\nPi loads `AGENTS.md`\n\n(or `CLAUDE.md`\n\n) files at startup to give the model project-specific instructions. You can have a global one in `~/.pi/agent/AGENTS.md`\n\nand a per-project one in your repo root. Example:\n\n```\n# Project Instructions\n\n- Run `npm run check` after code changes.\n- Do not run production migrations locally.\n- Keep responses concise.\n```\n\nRun `/reload`\n\ninside a session to pick up changes without restarting.\n\nType `@`\n\nin the editor to fuzzy-search and reference files, or pass them on the command line:\n\n```\npi @src/app.ts @src/app.test.ts \"Review these together\"\n```\n\nYou can paste images with Ctrl+V (Alt+V on Windows) or drag them into supported terminals.\n\nSessions are saved automatically. Resuming is straightforward:\n\n```\npi -c         # Continue most recent session\npi -r         # Browse previous sessions\n```\n\nInside a session, `/fork`\n\nand `/clone`\n\nlet you branch the conversation tree — useful when you want to try two different approaches to a problem without losing your current state.\n\nPi works well in scripts and pipelines:\n\n```\npi -p \"Summarize this codebase\"\ncat README.md | pi -p \"Summarize this text\"\npi -p @screenshot.png \"What's in this image?\"\n```\n\nFor automation, `--mode json`\n\ngives structured event output and `--mode rpc`\n\nallows stdin/stdout process integration.\n\nPrefix a command with `!`\n\nto run it and send the output to the model:\n\n```\n!npm run lint\n```\n\nUse `!!command`\n\nto run it without adding the output to the model's context window.\n\nUse `/model`\n\nor Ctrl+L to change models mid-session. Shift+Tab cycles thinking levels. This is useful if you want a fast cheap model for exploration and a smarter one for final implementation.\n\nIf you're building something on top of pi rather than using it as a CLI, the SDK path is clean:\n\n``` js\nimport {\n  AuthStorage,\n  createAgentSession,\n  ModelRegistry,\n  SessionManager,\n} from \"@earendil-works/pi-coding-agent\";\n\nconst authStorage = AuthStorage.create();\nconst modelRegistry = ModelRegistry.create(authStorage);\n\nconst { session } = await createAgentSession({\n  sessionManager: SessionManager.inMemory(),\n  authStorage,\n  modelRegistry,\n});\n\nawait session.prompt(\"What files are in the current directory?\");\n```\n\nFor non-Node.js integrations, pi supports RPC mode over stdin/stdout with JSONL framing — so you can integrate from any language.\n\nIf you want to contribute or run from source:\n\n```\ngit clone https://github.com/earendil-works/pi.git\ncd pi\nnpm install       # Install all dependencies\nnpm run build     # Build all packages\nnpm run check     # Lint, format, and type check\n./pi-test.sh      # Run pi from sources (any directory)\n```\n\nNote: `npm run check`\n\nrequires a prior `npm run build`\n\nbecause the web-ui package needs compiled `.d.ts`\n\nfiles from dependencies.\n\n**Yes, with some caveats.**\n\nPi earns attention for a few concrete reasons:\n\n**It's genuinely multi-provider.** Most coding agents are tied to one model provider. Pi normalizes across OpenAI, Anthropic, Google, and others at the API layer, so you can switch without re-learning a tool. If you already pay for Claude Pro or GitHub Copilot, pi can use those subscriptions directly — no extra API costs by default.\n\n**The session model is well-designed.** Branching, forking, and resuming sessions is something most similar tools handle poorly. Pi treats this as a first-class feature, which matters when you're doing long iterative work.\n\n**The extensibility story is solid.** Extensions are TypeScript modules that can add tools, slash commands, event handlers, and custom UI. If the built-in tools don't cover your workflow, you can add to them.\n\n**Where it's less compelling:** The terminal UI won't appeal to everyone, and if you're deeply embedded in VS Code with Copilot already working, the switching cost is real. The documentation is good but spread across many individual files in the repo — there's no single polished docs site yet.\n\nFor developers who want control over their AI tooling, prefer the terminal, or need to build agents programmatically rather than just use them interactively, pi is a serious option. It's the kind of tool that rewards spending an hour with it.\n\n| Task | Command |\n|---|---|\n| Install | `npm install -g @earendil-works/pi-coding-agent` |\n| Start in project | `cd /project && pi` |\n| Login (subscription) |\n`/login` inside pi |\n| Set API key | `export ANTHROPIC_API_KEY=...` |\n| Continue last session | `pi -c` |\n| Browse sessions | `pi -r` |\n| One-shot prompt | `pi -p \"your prompt\"` |\n| Switch model |\n`/model` or Ctrl+L |\n| Run shell command | `!your-command` |\n| Reload context files | `/reload` |\n| Uninstall | `npm uninstall -g @earendil-works/pi-coding-agent` |", "url": "https://wpnews.pro/news/pi-the-open-source-ai-coding-agent-you-probably-haven-t-tried-yet", "canonical_source": "https://dev.to/arshtechpro/pi-the-open-source-ai-coding-agent-you-probably-havent-tried-yet-2h0h", "published_at": "2026-05-26 10:54:21+00:00", "updated_at": "2026-05-26 11:03:35.540079+00:00", "lang": "en", "topics": ["ai-tools", "ai-agents", "artificial-intelligence", "large-language-models"], "entities": ["Claude Code", "GitHub Copilot", "Codex", "pi", "earendil-works", "OpenAI", "Anthropic", "Google"], "alternates": {"html": "https://wpnews.pro/news/pi-the-open-source-ai-coding-agent-you-probably-haven-t-tried-yet", "markdown": "https://wpnews.pro/news/pi-the-open-source-ai-coding-agent-you-probably-haven-t-tried-yet.md", "text": "https://wpnews.pro/news/pi-the-open-source-ai-coding-agent-you-probably-haven-t-tried-yet.txt", "jsonld": "https://wpnews.pro/news/pi-the-open-source-ai-coding-agent-you-probably-haven-t-tried-yet.jsonld"}}