There are many agent harnessespig is pure PHP

pig is pi ported to PHP with zero runtime dependencies.Minimal agent core, Fiber async socket transport, native ANSI TUI.

curl -fsSL https://pigagent.dev/install.sh | sh

Why pig?

pig is a minimal agent harness. Adapt pig to your workflows, not the other way around. Customize pig with extensions, skills, prompt templates, and themes. Bundle them as pig packages and share via Composer or Git.

pig ships with powerful defaults but skips features like sub-agents and plan mode. Ask pig to build what you want, or install a package that does it your way.

Four modes: interactive, print/JSON, RPC, and SDK.

Read the documentation

Change the harness, not your workflow

pig isn't a sealed product. If you need a command, tool, provider, workflow, or UI tweak, just ask pig to build it. It will customize itself on the fly.

Have pig manipulate itself in place, hit /reload, and keep going. If you think others will find what you built useful, share it!

15+ providers, hundreds of models

Anthropic, OpenAI, Google, Azure, Bedrock, Mistral, Groq, Cerebras, xAI, Hugging Face, Kimi For Coding, MiniMax, NVIDIA, OpenRouter, Ollama, and more. Authenticate via API keys or OAuth.

Switch models mid-session with /model or Ctrl+L. Cycle through your favorites with Ctrl+P.

Add custom providers and models via models.json or extensions.

Tree-structured, shareable history

Sessions are stored as trees. Use /tree to navigate to any previous point and continue from there. All branches live in a single file. Filter by message type, label entries as bookmarks.

Export to HTML with /export, or upload to a GitHub gist with /share and get a shareable URL that renders it.

Context engineering

pig's minimal system prompt and extensibility let you do actual context engineering. Control what goes into the context window and how it's managed.

AGENTS.md: Project instructions loaded at startup from ~/.pig/agent/ (and also compatible with ~/.pi/agent/), parent directories, and the current directory.

SYSTEM.md: Replace or append to the default system prompt per-project.

Compaction: Auto-summarizes older messages when approaching the context limit. Fully customizable via extensions: implement topic-based compaction, code-aware summaries, or use different summarization models.

Skills: Capability packages with instructions and tools, loaded on-demand. Progressive disclosure without busting the prompt cache. See skills.

Prompt templates: Reusable prompts as Markdown files. Type /name to expand. See prompt templates.

Dynamic context: Extensions can inject messages before each turn, filter the message history, implement RAG, or build long-term memory.

Steer or follow up

Submit messages while the agent works. Enter sends a steering message (delivered after current tool, interrupts remaining tools). Alt+Enter sends a follow-up (waits until the agent finishes).

Four modes

Interactive: The full TUI experience.

Print/JSON: pig -p "query" for scripts, --mode json for event streams.

RPC: JSON protocol over stdin/stdout for non-Node integrations. See docs/rpc.md.

SDK: Embed pig in your apps.

Primitives, not features

Features that other agents bake in, you can build yourself. Extensions are pure PHP scripts with access to tools, commands, keyboard shortcuts, events, and the full TUI.

Sub-agents, plan mode, permission gates, path protection, SSH execution, sandboxing, MCP integrations, custom editors, status bars, overlays.

Don't want to build it? Ask pig to build it for you. Or install a package that does it your way. See the 50+ examples.

Bundle pure PHP extensions, skills, prompts, and themes. Update or install from Git or Packagist:

$ pig update --extensions
$ pig update --models

What we didn't build

pig is aggressively extensible so it doesn't have to dictate your workflow. Features that other tools bake in can be built with extensions, skills, or installed from third-party pig packages. This keeps the core minimal while letting you shape pig to fit how you work.

Read the blog post

  • No MCP MCP + Codemode in PHP

    MCP is built in, and Codemode lets agents compose batch tool calls in an isolated native PHP child process. MCP extensions are still supported too. Why we changed our minds

  • No sub-agents

    Spawn pig instances via tmux, or build your own with extensions, or install a package that does it your way.

  • No permission popups

    Run in a container, or build your own confirmation flow with extensions inline with your environment and security requirements.

  • No plan mode

    Write plans to files, or build it with extensions, or install a package.

  • No built-in to-dos

    Use a TODO.md file, or build your own with extensions.

  • No background bash

    Use tmux. Full observability, direct interaction.

Get involved with pig