pi-coding-agent

Embed pi as a Node.js SDK for scripted agent workflows with custom tools and restricted toolsets.

416|6|Updated Apr 24, 2026
Ready to run
npx skills add https://github.com/mizchi/skills --skill pi-coding-agent-mizchi
💬 Prompt for ChatGPT / Claude Chat▼
Please help me install this Agent Skill.
Skill: pi-coding-agent
Source: https://github.com/mizchi/skills/tree/main/pi-coding-agent
Command: npx skills add https://github.com/mizchi/skills --skill pi-coding-agent-mizchi

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @mariozechner/pi-coding-agent, @mariozechner/pi-ai, @mariozechner/pi-agent-core, @mariozechner/pi-tui, typebox.

What problem does it solve? Developers need to integrate ai-powered coding agents into Node.js applications without running interactive CLIs, and need fine-grained control over available tools, authentication, and session management. ## Core Features & Use Cases - SDK Integration: Spawn agent sessions from any Node 20.6+ script with full programmatic control. - Tool Restriction: Limit agents to read-only, domain-specific, or custom tool sets; prevent dangerous operations. - Extension System: Register custom tools, commands, and lifecycle hooks via TypeScript modules. - Use Case: A DevOps orchestrator registers a deploy tool and restricts bash to read-only operations, then spawns ephemeral agent sessions to diagnose and fix infrastructure issues without exposing full shell access. ## Quick Start Create a Node script that imports createAgentSession, configure your allowed tools, pass your API key, and call session.prompt() to send a task to the agent.

Frequently Asked Questions about pi-coding-agent

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I restrict a pi agent to read-only tools in Node?▼

Pass tools: ['read', 'grep', 'find', 'ls'] or tools: readOnlyTools to createAgentSession(). When using a custom cwd, bind tools via factory functions like createReadOnlyTools(cwd) to prevent path resolution bugs.

What is the cwd × tools trap and how do I avoid it?▼

Pre-built tool instances (readOnlyTools, codingTools) capture process.cwd() at import time and don't rebind. Use string names (tools: ['read', 'grep']) or factories (tools: createReadOnlyTools(cwd)) when passing a custom cwd alongside explicit tools.

How do I add a custom tool to a pi agent session?▼

Define a tool with defineTool() using TypeBox schemas, then pass customTools: [myTool] to createAgentSession(). Custom tools merge additively with the requested tool set and receive typed parameters in their execute handler.

Can I embed pi extensions in Node without the CLI?▼

Yes. Pass extensionFactories to DefaultResourceLoader or load extensions from disk via additionalExtensionPaths. Extensions must be in auto-discovery directories (~/.pi/agent/extensions/) or specified explicitly; they load before session_start fires.

Why does pi install fail even though peerDependencies are installed?▼

The five core packages—@mariozechner/pi-coding-agent, @mariozechner/pi-ai, @mariozechner/pi-agent-core, @mariozechner/pi-tui, typebox—must be in peerDependencies with "*" and never bundled. Pi provides them at runtime; bundling causes module identity mismatches.

When should I use pi SDK instead of pi --mode rpc?▼

Use the SDK for type-safe in-process control, registering TypeScript tools, and direct event streams in Node. Use RPC mode for non-Node hosts (Python, Go, Rust) or when you need process isolation.