Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Pi Agent CLI Reference Manual

Pi Agent CLI Reference Manual

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


Mode options

The following parameters control Pi Agent's running mode; when not specified, it defaults to the interactive interface.

Parameters Description Example
(default) Interactive mode, terminal TUI interface pi
-p, --print Print mode, exit after outputting results pi -p "summarize code"
--mode json JSON mode, all events output as JSON lines pi --mode json -p "summarize"
--mode rpc RPC mode, stdin/stdout JSONL protocol pi --mode rpc
--export [Output] Export session as HTML, output path can be omitted pi --export abc123 session.html

Model options

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

Parameters Description Example
--provider name Specify AI provider pi --provider anthropic
--model pattern Model ID, supports provider/id and :thinking formats pi --model openai/gpt-4o
pi --model sonnet:high
--api-key key Pass API Key directly, highest priority; replace the example value with your own Key pi --api-key sk-ant-api03-xxxx
--thinking level Reasoning level: off/minimal/low/medium/high/xhigh/max pi --thinking high
--models patterns Comma-separated model list, limits Ctrl+P cycling pi --models "claude-*,gpt-4o"
--list-models List all available models pi --list-models

Session options

The following parameters determine which session to use for this run and where session files are saved.

Parameters Description Example
-c, --continue Continue the most recent session pi -c
-r, --resume Browse and select a history session pi -r
--session path|id Use a specified session file or UUID pi --session abc123
--fork path|id Fork a new session from a specified session pi --fork abc123
--session-dir dir Custom session storage directory, default is ~/.pi/agent/sessions/; this parameter temporarily replaces it pi --session-dir .pi/sessions
--no-session Temporary mode, does not save sessions pi --no-session
-n, --name name Set session display name pi --name "refactor authentication module"

Tool options

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

Parameters Description Example
-t, --tools list Whitelist specified tools, comma-separated pi --tools read,bash,edit,write
-xt, --exclude-tools list Disable specified tools, comma-separated pi --exclude-tools bash
-nbt, --no-builtin-tools Disable all built-in tools, keep extension tools pi --no-builtin-tools
-nt, --no-tools Disable all tools, pure conversation mode pi --no-tools

Resource options

The following parameters control the loading of extensions, Skill, templates, and themes; parameters with the --no- prefix are used to disable auto-discovery.

Parameters Description Example
-e, --extension source Load extension, can be used repeatedly pi -e ./my-ext.ts -e npm:@foo/bar
--no-extensions Disable extension auto-discovery pi --no-extensions
--skill path Load Skill, can be used repeatedly pi --skill ./my-skill
--no-skills Disable Skill auto-discovery pi --no-skills
--prompt-template path Load prompt template, can be used repeatedly pi --prompt-template ./review.md
--no-prompt-templates Disable template auto-discovery pi --no-prompt-templates
--theme path Load theme, can be used repeatedly pi --theme ./my-theme.json
--no-themes Disable theme auto-discovery pi --no-themes
-nc, --no-context-files Disable AGENTS.md/CLAUDE.md loading pi -nc

Other Options

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

Parameters Description Example
--system-prompt text Replace the default system prompt pi --system-prompt "you are a Python expert"
--append-system-prompt text Append to the system prompt pi --append-system-prompt "reply in Chinese"
--tui-mode Interface mode, such as fullscreen; when not specified, use the regular mode pi --tui-mode fullscreen
--use-theme Specify theme loading, effective only for this run, does not modify configuration pi --use-theme "dark-plus"
--verbose Force display of detailed startup information pi --verbose
-a, --approve Trust project local files for this run pi -a
-na, --no-approve Do not trust project local files for this run pi -na
-- Separator; content after it is passed to the prompt as-is pi -- @notes.md summarize this note
-h, --help Display help information pi -h
-v, --version Display version number pi -v

-a The difference between -na Mutually exclusive; only one can be specified per run.

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


pi subcommands

Besides startup parameters, pi also provides a set of subcommands for managing extension packages and self-updates.

Subcommands Description
pi install Install extension package, add -l to install to project local
pi remove Remove an installed extension package
pi uninstall Alias of remove, same effect
pi list List installed extension packages
pi update Update pi itself and extension packages, supports --self, --all, --models, --extensions, --extension
pi config Enable 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.

Variables Purpose Example
ANTHROPIC_API_KEY Alternative method for Anthropic authentication, used when not logging in via /login subscription sk-ant-api03-xxxx
HTTP_PROXY / HTTPS_PROXY Specify a proxy server for API requests http://127.0.0.1:7890
NO_PROXY Proxy whitelist; matching hosts do not go through the proxy localhost,127.0.0.1
COLORTERM One of the reference values for truecolor auto-detection; if detection fails, use PI_TRUE_COLOR=1 to force enable, or configure terminal.trueColor truecolor

Proxies needed long-term should be written to ~/.pi/agent/settings.json 's httpProxy。

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


File parameters

Use the @ 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:



图中是一张登录页面的截图,页面包含用户名输入框、密码输入框和一个登录按钮。