Pi Agent First Conversation
After completing installation and authentication setup, this chapter guides you through your first complete conversation experience.
You will become familiar with the interface layout and basic operations.
Starting Pi Agent
Enter your project directory and start Pi Agent:
$ cd ~/projects/runoob-demo
$ pi
You will see Pi Agent's interactive interface appear in the terminal.
The interface is divided into four main areas:
| Area | Position | Display content |
|---|---|---|
| Startup header | Top | Shortcut hints, loaded context files, prompt templates, Skills, extensions |
| Message area | Middle | User messages, AI replies, tool call details, notifications, and errors |
| Editor area | Bottom input line | Where you type; the border color indicates the current reasoning level |
| Bottom Status Bar | Bottom | Working directory, session name, token/cache usage, context usage, cost, current model name (total includes AI replies, tool-reported usage, and summary generation consumption) |
If you think the header info shown at startup is too much, you can enable the option in settings quietStartup to hide it.
First task
After entering the interface, type your first request and press Enter:
帮我总结一下这个项目的结构和主要功能
Pi Agent will use built-in tools to read your project files, analyze the code structure, and then return a summary.
You can see the operations the AI is performing in the message area—including which tools it calls and which files it reads.
The output of a complete conversation looks like:
> read README.md(1.2k 字符)
> read src/main.ts(3.4k 字符)
这是一个基于 TypeScript 的终端编程助手,主要功能分为会话管理、工具调度和扩展加载三部分。
Tokens: 2.4k 输入 / 410 输出 | 费用 $0.0152
Pi Agent provides four built-in tools by default: read, write, edit, and bash; see the "Core Concepts Overview" chapter for full details.
Including Files
You can reference specific files in a conversation in two ways:
Method 1: @ syntax (search within the editor)
Type @ in the edit area to automatically pop up a fuzzy search of project files:
@src/app.ts 解释这个文件的功能
Method 2: Command-line arguments
Pass file references directly at startup:
$ pi @README.md "总结一下这个文档"
$ pi @src/app.ts @src/app.test.ts "对比这两个文件"
You can also reference image files:
$ pi -p @screenshot.png "这张截图里显示了什么"
Paste images
Pi Agent supports sending images in conversations; operations vary slightly across platforms.
| Platform | Operation | Description |
|---|---|---|
| macOS / Linux | Ctrl+V | Paste an image from the clipboard |
| Windows | Alt+V | Paste an image from the clipboard |
| Supported terminals | Drag an image into the terminal window | Pass into the conversation as a file |
Execute commands in a conversation
You can execute shell commands directly from the edit area without exiting Pi Agent:
!npm run lint
!git diff
Commands starting with ! are executed, and the output is automatically sent to the AI to view.
The result of executing !npm run lint looks like:
> pi-agent@1.0.0 lint
> eslint .
0 errors, 0 warnings
Commands starting with !! are also executed, but the output is NOT sent to the AI:
!!echo "这只在本地显示"
这只在本地显示
Use !! The prefix executes commands that don't need AI viewing (such as opening files, viewing environment variables), avoiding wasting context window.
Multi-line input and external editor
Large blocks of text can be written with multi-line input or an external editor; relevant shortcuts are below.
| Operation | Keyboard shortcut |
|---|---|
| Insert newline | Shift+Enter (Ctrl+Enter in Windows Terminal) |
| Open external editor | Ctrl+G |
When you need to enter a large block of text, press Ctrl+G to open the system default editor (such as nano, vim, or VS Code); after editing and saving, the content is automatically filled into Pi Agent's edit area.
Message queue
Pi Agent allows you to send messages while the AI is working, without waiting for it to finish:
| Keyboard shortcut | Behavior | Description |
|---|---|---|
| Enter | Send a steering message | Sent to the AI immediately after the current tool finishes executing |
| Alt+Enter | Send a follow-up message | Sent after the AI finishes all work |
| Escape | Cancel queued messages | Restore queued messages to the edit area |
| Alt+Up | Retrieve queued messages | Retrieve queued messages back to the edit area for modification |
In Windows Terminal, Alt+Enter is the default fullscreen shortcut. If you want Pi Agent to receive this shortcut, you need to refer toMulti-platform deploymentfor remapping instructions.
Non-interactive mode
Besides interactive conversation, you can also use Pi Agent quickly in the following ways:
Example
One-shot Q&A, exit after output
pi
-p
"Summarize this codebase"
Pipe input: pass file content to the AI
cat
README.md
|
pi
-p
"Summarize this text"
One-shot Q&A with an image
pi
-p
@
screenshot.png
"What's in this image"
Named session (for easy continuation later)
pi
--name
"Code review"
-p
"Review the code under the src/ directory"
Read-only mode (file modification not allowed)
pi
--tools
read
,
grep
,
find
,
ls
-p
"Review the code without modifying"
Print mode (-p) is ideal for integration into scripts and CI pipelines.
Create a project instruction file
To help the AI better understand your project, it is recommended to create an AGENTS.md file.
Save the following content as a Markdown file at path project-root/AGENTS.md:
Example
Project instructions
Run after code changes
npm run check
Do not execute production environment migrations locally
Keep replies concise, without excessive explanation
Write code using TypeScript strict mode
Follow the project's existing code style
Pi Agent automatically loads this file at startup.
It also loads global instructions from ~/.pi/agent/AGENTS.md and instruction files in parent directories.
After updating AGENTS.md, use the /reload command to hot reload without restarting.
If you previously used Claude Code, existing CLAUDE.md files can be directly recognized and used by Pi Agent without renaming.
Interface overview
Here is a quick reference of the main shortcuts in Pi Agent interactive mode:
| Operation | Keyboard shortcut | Description |
|---|---|---|
| Submit input | Enter | Send the current edit area content; when the AI is working, it enters the message queue (see Message Queue) |
| Model selection | Ctrl+L | Open the model picker |
| Switching models | Ctrl+P / Shift+Ctrl+P | Cycle models forward/backward |
| Reasoning level | Shift+Tab | Cycle reasoning levels |
| Expand/collapse tool output | Ctrl+O | Toggle display of tool call results |
| Expand/collapse reasoning process | Ctrl+T | Toggle display of the AI's reasoning process |
| Interrupt operation | Escape | Cancel the current AI operation (see Message Queue) |
| Clear the edit area | Ctrl+C | Clear the current edit area content |
| Copy the AI's last reply | Ctrl+X | Copy reply content to clipboard |
| Path auto-completion | Tab | Complete file paths |
| Exit program | Ctrl+D | Exit the program when the edit area is empty |
| Exit the program (direct) | /quit | Exit immediately |