Pi Agent CLI Reference Manual

The following is a reference for common Pi Agent command-line parameters.


Mode Options

The following parameters control the running mode of Pi Agent. If not specified, it enters the interactive interface by default.

ParameterDescriptionExample
(Default)Interactive mode, terminal TUI interfacepi
-p, --printPrint mode, exits after outputting the resultpi -p "summarize code"
--mode jsonJSON mode, all events output as JSON linespi --mode json -p "summarize"
--mode rpcRPC mode, stdin/stdout JSONL protocolpi --mode rpc
--export <input> [output]Export session to HTML; output path can be omittedpi --export abc123 session.html

Model Options

The following parameters are used to specify the provider, model, and reasoning level, suitable for temporary switching without modifying configuration files.

ParameterDescriptionExample
--provider nameSpecify AI providerpi --provider anthropic
--model patternModel ID, supports provider/id and :thinking formatspi --model openai/gpt-4o
pi --model sonnet:high
--api-key keyPass the API Key directly, with the highest priority; replace the example value with your own Keypi --api-key sk-ant-api03-xxxx
--thinking levelReasoning level: off/minimal/low/medium/high/xhigh/maxpi --thinking high
--models patternsComma-separated model list, limits Ctrl+P cyclingpi --models "claude-*,gpt-4o"
--list-modelsList all available modelspi --list-models

Session Options

The following parameters determine which session is used in this run and where session files are saved.

ParameterDescriptionExample
-c, --continueContinue the most recent sessionpi -c
-r, --resumeBrowse and select a historical sessionpi -r
--session path|idUse a specified session file or UUIDpi --session abc123
--fork path|idFork a new session from the specified sessionpi --fork abc123
--session-dir dirCustom session storage directory; the default directory is ~/.pi/agent/sessions/, this parameter temporarily replaces itpi --session-dir .pi/sessions
--no-sessionTemporary mode, does not save sessionspi --no-session
-n, --name nameSet session display namepi --name "Refactor authentication module"

Tool Options

The following parameters control the availability of built-in tools, used to tighten permissions or for pure conversation.

ParameterDescriptionExample
-t, --tools listWhitelist specified tools, comma-separatedpi --tools read,bash,edit,write
-xt, --exclude-tools listDisable specified tools, comma-separatedpi --exclude-tools bash
-nbt, --no-builtin-toolsDisable all built-in tools, keep extension toolspi --no-builtin-tools
-nt, --no-toolsDisable all tools, pure conversation modepi --no-tools

Resource Options

The following parameters control loading of extensions, Skills, templates, and themes. Parameters with the --no- prefix are used to turn off auto-discovery.

ParameterDescriptionExample
-e, --extension sourceLoad an extension, can be used repeatedlypi -e ./my-ext.ts -e npm:@foo/bar
--no-extensionsDisable extension auto-discoverypi --no-extensions
--skill pathLoad a Skill, can be used repeatedlypi --skill ./my-skill
--no-skillsDisable Skill auto-discoverypi --no-skills
--prompt-template pathLoad a prompt template, can be used repeatedlypi --prompt-template ./review.md
--no-prompt-templatesDisable template auto-discoverypi --no-prompt-templates
--theme pathLoad a theme, can be used repeatedlypi --theme ./my-theme.json
--no-themesDisable theme auto-discoverypi --no-themes
-nc, --no-context-filesDisable loading of AGENTS.md/CLAUDE.mdpi -nc

Other Options

The following parameters override behaviors such as system prompt, project trust, and help information.

ParameterDescriptionExample
--system-prompt textReplace the default system promptpi --system-prompt "You are a Python expert"
--append-system-prompt textAppend to the system promptpi --append-system-prompt "Reply in Chinese"
--tui-modeInterface mode, e.g., fullscreen; if not specified, regular mode is usedpi --tui-mode fullscreen
--use-themeSpecify a theme to load; only effective for the current run, does not modify configurationpi --use-theme "dark-plus"
--verboseForce display of detailed startup informationpi --verbose
-a, --approveTrust project local files for this runpi -a
-na, --no-approveDo not trust project local files for this runpi -na
--Separator; content after it is passed to prompt as-ispi -- @notes.md Summarize this note
-h, --helpDisplay help informationpi -h
-v, --versionDisplay version numberpi -v

-aand-naMutually exclusive; only one can be specified in the same run.

Both are limited to the current run only and will not be written to trust.json.


pi Subcommands

In addition to startup parameters, pi also provides a set of subcommands for managing extension packages and its own updates.

SubcommandDescription
pi install <source>Install an extension package; add -l to install locally to the project
pi remove <source>Remove an installed extension package
pi uninstall <source>Alias for remove, same effect
pi listList installed extension packages
pi updateUpdate pi itself and extension packages; supports --self, --all, --models, --extensions, --extension <source>
pi configEnable or disable various resources provided by extension packages

Related Environment Variables

The following environment variables affect authentication, network, and terminal behavior, and can serve as supplementary configuration beyond command-line parameters.

VariablePurposeExample
ANTHROPIC_API_KEYAlternative method for Anthropic authentication; used when not logged in via /login subscriptionsk-ant-api03-xxxx
HTTP_PROXY / HTTPS_PROXYSpecify a proxy server for API requestshttp://127.0.0.1:7890
NO_PROXYProxy whitelist; matched hosts do not go through the proxylocalhost,127.0.0.1
COLORTERMOne of the reference values for truecolor auto-detection; if detection fails, use PI_TRUE_COLOR=1 to force enable, or configure terminal.trueColortruecolor

For proxies that need long-term use, it is recommended to write to~/.pi/agent/settings.jsonofhttpProxy。

This configuration only takes effect in the global configuration file; writing it at the project level.pi/settings.jsonis invalid.


File Arguments

Usage@Prefix to reference files:

$ pi @prompt.md "回答这个问题"
$ pi -p @screenshot.png "图中有什么"
$ pi @src/code.ts @src/test.ts "对比这两个文件"

Taking the second command as an example, the output is similar to:

The image is a screenshot of a login page, which includes a username input field, a password input field, and a login button.
Other extensions