PiG Documentation

Guides and references for configuring, using, and extending PiG.

Command line

This page lists the pig command-line verbs and subcommands, and the pig docs commands for the embedded reference bundle. Command line by example runs the common ones and shows their output. PiG follows the command line of Pi 1.5.0 (Pi's command line reference). Run pig --help or append --help to a command for the exact interface of the installed binary.

CLI verbs

pig [options] [prompt]
Verb
Purpose
pigStart interactive TUI in current directory.
pig --print <prompt>, pig -p <prompt>One-shot: send prompt, print response, exit. When the model stops at its output token limit, PiG prints the partial text, writes Response was truncated: the model reached its output token limit. to stderr and exits 1. Pi 1.2.0 added this; Pi 1.1.0 exited 0 without a warning.
pig --mode json <prompt>One-shot: write JSONL events to stdout, then exit. See JSON event stream.
pig --model <provider/model>Override model for this run.
pig -e <path> (repeatable)Load an extension file or directory, or a built-in extension such as builtin:mcp.
pig --skill <path>Load a Skill file or directory. Repeat the option for several Skills.
pig --no-extensions, pig -neSkip discovered, configured, and built-in extensions; useful for isolating bugs. Explicit -e paths still load, so pig -ne -e builtin:mcp keeps only the built-in MCP support.
pig --models <patterns>Scope Ctrl+P model cycling to comma-separated model patterns. It is not an allow list. Without --model, a new session starts on the saved default model when the scope includes it, and otherwise on the first matching model.
pig --session-id <id>Use an exact session ID; may be combined with --no-session for provider cache affinity without disk persistence.
pig --mode rpcStart the JSONL RPC command loop on stdin/stdout.
pig --versionPrint the composite version <PiG version>+<pinned Pi version>. Pi prints only its own version (D63).
pig versionDetailed pig/pi/Go/platform/build banner.
pig diagnosePrint resolved config + binary identity.

Generic subcommands

Product distributions may contribute additional top-level or nested command paths. Core command paths always win; use pig --help and the product's focused docs for contributed commands.

Subcommand
Purpose
pig login [provider]Authenticate a built-in or contributed target. Built-ins use auth.json; contributed providers may own their credential store.
pig logout [provider]Remove credentials through the same provider/store used by login and TUI /logout.
pig auth check --provider <provider> [--model <model>] [--json] [--credentials] [--no-refresh]Print ready, not_ready, or invalid and exit 0, 1, or 2. --json writes the structured result; --credentials emits the resolved credential when ready. Expired OAuth credentials are refreshed unless --no-refresh is given, which also leaves auth.json and its directory untouched.
pig auth print-api-key --provider <provider> [--model <model>]Print the resolved API key for an external client. Refuses a provider configured with OAuth.
pig auth print-bearer-token --provider <provider> [--model <model>] [--min-expiry <duration>]Print an OAuth bearer token, refreshing it when less than --min-expiry (default 30m; units ms, s, m, h) remains. Refuses a provider configured with an API key.
pig install <source> [-l]Install a package through a core or contributed resolver. -l installs into the project.
pig remove <source> [-l]Remove a package from settings. pig uninstall is an alias.
pig update [self\|pig\|<source>] [--self\|--extensions\|--models\|--all] [--extension <source>] [--force]Bare pig update updates the pig binary, as pi update does. <source> (or --extension <source>) updates one package, --extensions updates every package, --models refreshes the model catalogs, and --all updates packages and then pig. --force reinstalls pig even when it is the latest version.
pig install <path> --validate-only [--json]Validate without installing; emits structured diagnostics.
pig install --validate-only [--json]With no source, check that every configured local Package path resolves; exit 1 and name each missing one (D216).
pig install --validate-only --set "<p1>,<p2>"Validate a piglet-style extension set.
pig extension init <path> [--name <matching-name>] [--lang go\|python\|rust\|lisp] [--login] [--isolated] [--force] [--json]Scaffold an extension that resolves the staged SDK offline (Go default). --login scaffolds a Go login factory with standard PiG art.
pig extension upgrade [<name\|path>...] [--all] [--dry-run] [--summary]Rewrite Go extensions written for an older SDK with the SDK's tested rules: back up, show a diff, rebuild, report per extension (D109). See Upgrade a Go extension.
pig extension preview-login <path>Start exactly one extension and render the login set during session_start; no model session starts.
pig extensions cache stats [--json]Inspect extension and runtime-cell cache classifications without changing use metadata.
pig extensions cache prune [--retention <duration>] [--max-size <bytes>] [--failures] [--dry-run] [--json]Remove eligible inactive cache entries. Hard roots always remain. --failures also removes recorded build failures, so the next start compiles those extensions again.
pig piglet prune [--keep <n>] [--max-size <size>] [--dry-run]Remove old built Piglet Binaries, keeping the newest n of each Piglet and target (default 2). Pulled installs always remain.
pig reloadStage the embedded extension SDKs and drop extension builds an older SDK produced.
pig listList installed Packages with Pi-compatible output.
pig package list [--json]Inspect configured Package state without starting runtimes.
pig package validate <dir> [--json]Validate ordinary Package source and Resource membership without installing.
pig package publish [<dir>] --to npm [--yes] [--tag <dist-tag>] [--access public\|restricted] [--otp <code>]Optional sugar over npm publish for a Package: validate it, check the catalog fields and that name@version is free, show npm's dry run, and publish only with --yes. PiG never handles an npm token.
pig status [--json]Side-effect-free Package/Resource/Piglet health and canonical path overview; invalid state exits non-zero. It shows the project trust decision, marks resources that a run ignores (ignored: untrusted or ignored: piglet-discovery), and gives a skill or theme that the loader rejects a health text and enabled: false.
pig login --list [--json]List generic built-in and contributed authentication targets without reading credentials.
pig piglet list\|show\|validate\|schema\|add\|pull\|update\|publish\|remove\|prune\|build\|keygen\|verify\|tree\|lineage\|trustCurrent Piglet source, signed release distribution, inspection, build, and Binary-signing surface (D18). Owned verbs use full words.
pig piglet build <name> --format script --out <path\|->Write an explicit source-bound entry script: a POSIX shell script, or a cmd.exe batch file on Windows (D69). Creates no PiG state or records.
pig piglet build <name> --format binary --out <path> [--sign-key <private-key>]Build a Piglet Binary and managed v1 resolution/Binary records. The optional Ed25519 signature is checked before command dispatch.
pig piglet keygen <private-key>Create an Ed25519 private key and <private-key>.pub without replacing existing files.
pig piglet publish <name\|path> --to github --repo <owner/repo> --sign-key <key> [--targets os/arch,...] [--artifacts <dir>] [--tag-prefix <name>/] [--dry-run\|--yes]Publish signed per-target Piglet Binaries, SHA256SUMS, and a signed release index as one GitHub Release. Dry run until --yes. See Piglet Binaries.
pig piglet publish <name\|path> --to npm [--yes] [--tag <dist-tag>] [--access public\|restricted] [--otp <code>] [--npm-name <name>] [--package-map <alias>=<ref>] [--binaries github:<owner/repo>\|--no-binaries]Publish Piglet source to npm so pig piglet add npm:<name> installs it. Local Packages become npm: references. Dry run until --yes; refuses an existing name@version; PiG never handles an npm token. See pig docs show publishing.
pig piglet verify <binary> [--source <name\|path>] [--workspace <dir>]Verify a Piglet Binary signature offline without running it. An unsigned Binary reports unsigned and exits non-zero. With --source, also bake that source as the build does and fail when the Binary records a different source or Piglet digest. --workspace names the workspace the build used (default: the current directory).
pig piglet tree [name] [--depth <n>] [--json]Show the installed Piglets arranged by extends; * marks the selected one and [installed] one with a built Binary.
pig piglet lineage <name\|path\|binary> [--source <name\|path>] [--json]Show an extends chain root first with what each link adds, removes or alters, or a signed Binary's recorded identity. Reads local files only.
pig piglet trust [list\|add\|revoke\|require]Manage trusted and revoked signer keys and the required-signature policy.
pig piglet build <name> --format image ...Reserved Piglet Image shape. It fails with Piglet Image build is not implemented.
pig config [--local]Open the Resource filter TUI. Press Tab to switch global and project scope.
pig setup [status\|go\|container]Show the toolchains that extensions and Piglet builds use (default), install a verified Go toolchain under $PIG_HOME/toolchains/go, or show how to install a container runtime.
pig verify [--json] [--checksums <file>] [--provenance] [--packages] [path...]Verify this binary, downloaded files, Piglet files, Packages, and extension directories by SHA-256 digest. Piglet Binary signatures are checked offline against the local trust policy.
pig mcp add\|remove\|list\|login\|logoutConfigure and check MCP servers without starting a session. See MCP servers.
pig docs [sync\|path\|list\|show <name>]Materialize and read the documentation bundled with Stock PiG.

pig install accepts one source. Missing sources and unknown options show the ordinary single-source usage, except that --validate-only with no source checks the configured local Packages (D216). Use pig install --help for the separate multi-source --validate-only forms (D28).

Options

These options apply to pig [options] [prompt]. Run pig --help for the full list.

Option
Purpose
--provider <name>, --api-key <key>Select the provider to search for --model and pass its API key for this run. --provider requires --model.
--thinking <level>Set the thinking level: off, minimal, low, medium, high, xhigh, or max.
--system-prompt <text>Replace the system prompt.
--append-system-prompt <text>Append text or a file's contents to the system prompt. Repeat it to append more.
--continue, -cContinue the most recent session for the current directory.
--resume, -rPick a session to resume.
--session <path\|id>Open a session by file path or full/partial ID.
--fork <path\|id>Fork a session by file path or full/partial ID into the current directory.
--session-dir <dir>Directory for session storage and lookup.
--no-sessionDo not save the session.
--name, -n <name>Set the session display name.
--no-mcpTurn off the built-in MCP support for this run: no servers connect, and there are no MCP tools or /mcp. It does not affect an extension that replaces the built-in MCP support.
--no-skills, -nsTurn off skill discovery and loading.
--prompt-template <path>Load a prompt template file or directory. Repeat it for more.
--no-prompt-templates, -npTurn off prompt template discovery and loading.
--theme <path>Load a theme file or directory. Repeat it for more.
--use-theme <name>Set the initial interactive theme for this run.
--no-themesTurn off theme discovery and loading.
--no-context-files, -ncDo not load AGENTS.md or CLAUDE.md files.
--export <file> [output]Export a session file to HTML and exit.
--list-models [search]List available models, with optional fuzzy search.
--tui-mode <mode>Set the TUI mode for this run: fullscreen (the default) or regular.
--verboseForce verbose startup, overriding quietStartup.
--approve, -aTrust project-local files for this run.
--no-approve, -naIgnore project-local files for this run.
--offlineTurn off startup network operations, as PI_OFFLINE=1 does.
--no-stdinIgnore piped stdin. Use it when the process that starts PiG leaves the stdin pipe open and never closes it. Without it, PiG waits for end of input, as Pi does. Pi 1.5.0 has no such option and treats --no-stdin as an unknown extension flag (D150, Pi #10415).
--piglet <name\|path>Run a named Piglet or the Piglet file at a path. A Piglet Binary lays the selected Piglet over its own, unless it was built with build.closed: true, which makes it refuse the option (Accept overlay Piglets). See Piglets.

Extensions can register their own options, such as --plan from a plan-mode extension.

PiG resolves local extension, Skill, prompt-template, and theme arguments relative to the launch directory. It leaves package-source and remote-URL arguments unchanged during this step.

File arguments

Use @path to attach a file to the initial prompt:

pig -p @notes.txt "Summarize these notes."

Text files use <file name="/absolute/path">\ncontent\n</file>\n. PiG adds the newline before </file> even when the file already ends with a newline, as Pi does. It skips empty files. The first positional prompt follows the closing tag's newline without an additional separator.

Tools

pig --tools read,grep,find,ls -p "Review the code in src/"

The tool options select the tools the model can call for one run. See Settings to change the default selection.

Option
Effect
--tools, -t <list>Replace the default selection with a comma-separated allowlist. It applies to built-in, extension, and custom tools. Entries are tool names or patterns where * matches any characters. MCP tools are kept unless an entry starts with mcp__ (see MCP tools). A list of only +name and -name entries is not an allowlist: it adds tools to or removes them from the default selection, for example pig --tools +codemode,-write. These entries take exact tool names, not patterns, and cannot be mixed with plain names. A tool removed with -name stays removed after /reload.
--exclude-tools, -xt <list>Turn off the named tools or patterns after all other selection options, MCP tools included. It applies to built-in, extension, and custom tools. An excluded tool cannot be called.
--no-builtin-tools, -nbtTurn off the default built-in tools and keep extension and custom tools.
--no-tools, -ntStart with every built-in, extension, custom, and MCP tool turned off.

Without these options, PiG enables read, bash, edit, and write, unless the defaultTools setting changes the set. Extension tools stay enabled. An explicit empty active tool set also stays empty in the system prompt, including after reload.

Built-in tool
Purpose
On by default
readRead text files and supported imagesyes
bashRun shell commandsyes
powershellRun PowerShell commands on Windowsno
editReplace exact text in an existing fileyes
writeCreate or overwrite a fileyes
grepSearch file contentsno
findFind paths by glob patternno
lsList directory contentsno

Two built-in extensions add tools that are off by default. codemode runs JavaScript that calls the other tools, and tool_search finds tools that are not declared to the model. The mcp extension turns them on when an MCP server needs them. To enable them yourself, name them in --tools or in the defaultTools setting, for example pig --tools read,bash,edit,write,codemode. See Codemode and tool search and MCP servers.

<a id="mcp-tools"></a>

--tools selects the tools declared to the model. It does not remove MCP tools, whose reach is set by their exposure: pig --tools read,codemode keeps every MCP tool callable from codemode scripts. An MCP tool that no entry names or matches is never declared directly, whatever its exposure; only tool_search, if listed, can load it. Once an entry starts with mcp__, --tools filters MCP tools too, so this keeps only the tools of the radius server:

pig --tools read,bash,codemode,'mcp__radius__*'

The MCP resource tools (list_mcp_resources, list_mcp_resource_templates, read_mcp_resource) count as MCP tools. To remove MCP tools, use --exclude-tools 'mcp__*' or --no-mcp.

For a read-only session, allow only the tools that cannot change files:

pig --tools read,grep,find,ls

To keep the default set without one tool, exclude it:

pig --exclude-tools bash

Custom update command

When a wrapper or another package manager provides PiG, set PI_SELF_UPDATE_COMMAND (or PIG_SELF_UPDATE_COMMAND) so pig update runs its update command:

export PI_SELF_UPDATE_COMMAND="mise use -g npm:{packageName}@{version}"

pig update checks the signed release manifest first and runs the command only when the release is newer (or with --force), after printing the release note. {packageName}, {version} and {installSpec} ({packageName}@{version}) come from that release. The value is split on whitespace. For arguments with spaces, use the selfUpdateCommand setting in ~/.pig/agent/settings.json, an argv array such as ["nix", "profile", "upgrade", "pig"]. A project's settings file is never read for it.

The configured command is your explicit choice of the one owner of the update. It replaces PiG's own tier selection (standalone replace, package manager, immutable Piglet Binary, container image) and never falls through to one of them. Without an update source there is no release to fill the placeholders from, so the command does not run. Exit code 0 does not prove an update: pig update prints Updated pig from X to Y when pig --version reports Y (from the replaced executable, else from PATH), and otherwise warns with the version it found.

pig docs

Stock PiG materializes its reference docs under ~/.pig/docs/ so the coding agent can read the API implemented by the running binary.

pig docs              # sync + summary (default)
pig docs sync         # force re-sync
pig docs path         # write the bundle if missing, print its directory
pig docs list         # list available files
pig docs show <name>  # print one doc to stdout

Each build writes its bundle to its own directory, ~/.pig/docs/bundle-<hash>/, named by the content hash of its pages. Two PiG builds that share a config root (two installed versions, or Stock PiG beside a Piglet Binary) each keep their own bundle, so neither rewrites the other's docs and a running session's docs never change. A sync keeps the four most recently used bundles and removes older ones. Pages an older PiG wrote directly in ~/.pig/docs/ stay for that version. PiG writes the bundle before anything other than PiG can read it: before the first tool call, before an extension starts, at interactive and RPC start, and for pig docs path. A print or JSON run that calls no tool and starts no extension writes nothing. When the bundle is already there, a start reads one marker file.

When the config root cannot be written and holds no bundle of the running build, startup writes nothing and prints nothing (D157). The system prompt then has no docs section, and no other text names a docs page, because Pi's docs always exist and PiG does not name files that are not there (D22). pig docs show still prints the embedded pages. To give a read-only image its docs, run pig docs sync while the config root is still writable. pig diagnose reports a read-only config root and what PiG does not write there.

Adapted from upstream Pi documentation · Upstream documentation ↗ · MIT License