Six comprehensive exercise projects, plus an index of official documentation and examples.
Difficulty: ★★★★★ | Prerequisites:00、01、02、03、04、05、06、07 | This article provides 6 comprehensive projects ranging from easy to difficult. Each project provides goals, knowledge points involved, implementation tips, acceptance criteria, and official examples for comparison.
01
Project 1: Personal Workflow Suite (No Code) ★★
target: Configure Pi as your daily development assistant using only context files, prompt templates and skills.
request
~/.pi/agent/AGENTS.md: Write general preferences (language, coding style, submission specifications);- Project
AGENTS.md:Write the build/test command of the project; - 3 prompt templates:
/review [focus]、/commit [type]、/explain <path>; - 1 skill
release-notes: ContainsSKILL.mdandreferences/template.md; - in
settings.jsonSet default models, thinking levels, and themes in .
Acceptance: After opening a new session, the startup header lists these resources;/review security Can focus by parameters; when asking "Help me write instructions for this release", the model will actively read the skills.
Reference: 04 articles; official Prompt Templates, Skills, Configuration.
02
Project 2: Safety Barrier Extension ★★★
target:Write a comprehensive security extension guard.ts。
Function
tool_callintercept dangerous bash(rm -rf、sudo、git push --force、curl … | sh)——Confirm when there is UI, block when there is no UI;- Block writing
.env、.git/、node_modules/、*.pem; - According to tools
annotations(MCP tool’sdestructiveHintetc.) decide whether to confirm; ctx.ui.setStatus()The bottom bar displays the number of times this session has been blocked;/guard-logThe command lists the interception records of this session (usepi.appendEntry()persistence,session_starttime fromgetBranch()reconstruction).
Acceptance: Confirmation will pop up in interactive mode;pi -p "删除 tmp 目录" is blocked and the reason is returned; after switching branches, the interception record is consistent with the branch.
Reference:permission-gate.ts、protected-paths.ts、status-line.ts、todo.ts;Tool exposure section of the Extensions documentation.
03
Project 3: Git Workflow Extension ★★★★
target: Make Pi better integrated into git.
Function
- Register
git_summaryTools (outputSchema+structuredContent), returns the current branch, number of changed files, ahead/behind; /checkpointCommand: usepi.exec("git", [...])Create stash or WIP submissions;session_shutdownIf there are uncommitted changes, ask whether to submit them automatically (skip if there is no UI);- Register
--auto-commitCLI parameters (pi.registerFlag), submit it directly when exiting after opening.
Acceptance:codemode script call tools.git_summary({}) Can get structured objects;pi --auto-commit Generate commits on exit.
Reference:git-checkpoint.ts、auto-commit-on-exit.ts、dirty-repo-guard.ts、preset.ts(registerFlag)。
04
Project 4: Automated code review robot (Print/JSON mode) ★★★★
target: Review PR with Pi in CI.
steps
- Read-only startup:
pi --no-session --tools read,grep,find,ls --mode json; - Input:
git diff origin/main...HEAD | pi --mode json --no-session --tools read,grep,find,ls "审查这个 diff,输出风险列表" > events.jsonl; - Write a Node or Python script to parse JSONL (Split by LF without Node readline), extract the final
message_endassistant text, all tool calls, anddurationMs, total dosage; - Check if it appears
stopReason: "error", based on which the CI exit code is determined (failure in JSON mode will not be automatically non-zero); - Advanced: add a belt
terminate: trueofstructured_outputTools (refer to official examples) to turn the results into machine-readable JSON.
Acceptance: Run on a sample repository and generate a Markdown review report; CI fails when the API key is intentionally invalid.
safe: Used in CI --no-approve or explicit defaultProjectTrust, and run within the container (refer to the Docker example in 03).
Reference:CLI Integration、JSON Event Stream、structured-output.ts。
05
Project 5: Build your own chat frontend with SDK/RPC ★★★★★
Option A (SDK, Node):
- use
createAgentSession()+SessionManager.continueRecent()Build an HTTP/WebSocket service; - put
session.subscribe()oftext_delta、tool_execution_*Events are pushed to the front end; - Messages sent by the front end during operation go
session.steer()/session.followUp(); - Pass
extensionFactoriesInject an inline extension that provides business tools (such as querying internal APIs); - to
agent_settledAs a "done" signal; when the page is closedsession.dispose()。
Option B (RPC, any language):
- Start with Python/Go
pi --mode rpc; - Implement command id association, event distribution,
streamingBehavior; - Implement extended UI subprotocol: received
extension_ui_request(select/confirm) pop-up window on the front end and returnextension_ui_response; - Implement session list (
get_state、switch_session、get_tree)。
Acceptance: Ability to talk in the browser, see tool calls, steer mid-stream, and confirm dangerous commands.
Reference:06 articles;examples/sdk/*、examples/rpc-client.ts、examples/rpc-extension-ui.ts、examples/extensions/rpc-demo.ts。
06
Project 6: MCP + Codemode + Virtual Model + Package Release ★★★★★
target: Integrate the previous results into a distributable Pi package.
steps
- To connect to a real MCP server (such as GitHub, file system or your company's service), use
toolExposureDesign: query classcodemode, high frequency toolsdirect, delete classhidden; - turn on
+codemode, design a reminder template/triage, guide the model to use codemode to pull issues, filter, and summarize in parallel; - (Optional) If you have classifier model credentials, use
models.classify()Give the issue an urgency score; - Implement virtual models
router/auto: Use a strong model for planning, a cheap model for execution, and store routing status.phase; - Package guard extensions, git extensions, templates, skills, and virtual model extensions into
@yourname/pi-kit: Set correctlypeerDependencies、pilist andpi-packageKeywords; - use
pi install ./pi-kitlocal verification,pi configCheck the resource; then use it on another machinepi install git:...@v0.1.0Installation.
Acceptance: A new machine can be installed with a single command;/triage Can generate an issue list with urgency;/session Can see the cost of different physical models.
Reference: 07 articles; MCP, Codemode, Virtual Models, Pi Packages documents;jev-router.ts。
07
self-test checklist
- [ ] can explain turn, run,
agent_endwithagent_settledThe difference - [ ] can tell
/tree、/fork、/clonedifference - [ ] Know when compaction is triggered, what is retained, and whether the original entries are deleted
- [ ] Can select the smallest customization mechanism for a requirement
- [ ] can write with TypeBox parameters,
detailsand rendering tools - [ ] Knowing the status of the extension why it is necessary to start from
getBranch()rebuild - [ ] Ability to create in-memory sessions and subscribe to streaming events using the SDK
- [ ] Can correctly parse JSONL of RPC/JSON (without readline)
- [ ] can explain the values of the four exposures MCP and codemode
- [ ] Know which dependencies should be placed in the Pi package
peerDependencies - [ ] It is clear that Pi has no permission system by default and knows how to use container isolation
08
Reference Index
Official documentation (https://pi.dev/docs/latest/)
Getting Started
- Page
- Overview(/)、Quickstart(/quickstart)、How Pi Works(/how-pi-works)
Use
- Page
- Usage(/usage)、Models(/models)、Sessions(/sessions)、Security(/security)、Containerization(/containerization)、llama.cpp(/llama-cpp)、Terminal Setup(/terminal-setup)
Customized
- Page
- Configuration(/configuration)、Settings(/settings)、Prompt Templates(/prompt-templates)、Skills(/skills)、Themes(/themes)、Keybindings(/keybindings)
Expand
- Page
- Extensions(/extensions)、Terminal UI(/tui)、Custom Providers(/custom-provider)、Virtual Models(/virtual-models)、Packages(/packages)
Tools and MCP
- Page
- MCP(/mcp)、Codemode(/codemode)、CLI(/cli)
Integrate
- Page
- SDK(/sdk)、CLI Integration(/cli-integration)、RPC(/rpc)、RPC Commands(/rpc-commands)、RPC Extension UI(/rpc-extension-ui)、JSON(/json)
Reference
- Page
- Session Format(/session-format)、Compaction(/compaction)、Message Types(/message-types)、Providers(/providers)、Models Configuration(/models-configuration)、Slash Commands(/slash-commands)、Environment Variables(/environment-variables)
| Classification | Page |
|---|---|
| Getting Started | Overview(/)、Quickstart(/quickstart)、How Pi Works(/how-pi-works) |
| Use | Usage(/usage)、Models(/models)、Sessions(/sessions)、Security(/security)、Containerization(/containerization)、llama.cpp(/llama-cpp)、Terminal Setup(/terminal-setup) |
| Customized | Configuration(/configuration)、Settings(/settings)、Prompt Templates(/prompt-templates)、Skills(/skills)、Themes(/themes)、Keybindings(/keybindings) |
| Expand | Extensions(/extensions)、Terminal UI(/tui)、Custom Providers(/custom-provider)、Virtual Models(/virtual-models)、Packages(/packages) |
| Tools and MCP | MCP(/mcp)、Codemode(/codemode)、CLI(/cli) |
| Integrate | SDK(/sdk)、CLI Integration(/cli-integration)、RPC(/rpc)、RPC Commands(/rpc-commands)、RPC Extension UI(/rpc-extension-ui)、JSON(/json) |
| Reference | Session Format(/session-format)、Compaction(/compaction)、Message Types(/message-types)、Providers(/providers)、Models Configuration(/models-configuration)、Slash Commands(/slash-commands)、Environment Variables(/environment-variables) |
The complete URL looks like https://pi.dev/docs/latest/extensions。
Source code and examples
- Warehouse:https://github.com/earendil-works/pi (original https://github.com/badlogic/pi-mono , redirected)
- coding-agent package:https://github.com/earendil-works/pi/tree/main/packages/coding-agent
- Extended example:https://github.com/earendil-works/pi/tree/main/packages/coding-agent/examples/extensions
- SDK example:https://github.com/earendil-works/pi/tree/main/packages/coding-agent/examples/sdk
- CHANGELOG:https://github.com/earendil-works/pi/blob/main/packages/coding-agent/CHANGELOG.md
- Extended type declaration:https://github.com/earendil-works/pi/blob/main/packages/coding-agent/src/core/extensions/types.ts
- RPC type:https://github.com/earendil-works/pi/blob/main/packages/coding-agent/src/modes/rpc/rpc-types.ts
ecology
- npm:https://www.npmjs.com/package/@earendil-works/pi-coding-agent
- Model directory:https://pi.dev/models
- Package Gallery:https://pi.dev/packages
- Pi skills:https://github.com/badlogic/pi-skills
- Agent Skills specification:https://agentskills.io/specification
- Real integration example OpenClaw:https://github.com/OpenClaw/OpenClaw
- Slack/Chat Automation:https://github.com/earendil-works/pi-chat
- Conversation sharing tools:https://github.com/badlogic/pi-share-hf
- Community Discord:https://discord.com/invite/3cU7Bz4UPx
- MCP Specifications:https://modelcontextprotocol.io
Version milestones (from CHANGELOG)
0.99.0
- Date
- 2026-09-29
- Highlights
- Codemode with MCP, system theme, Sign in with ChatGPT, virtual model, classifier model
0.99.2
- Date
- 2026-09-30
- Highlights
- The MCP exposed by the default codemode is no longer listed in the codemode description/does not block the first prompt;
/reloadEnable new joinsdefaultToolstools
1.0.0
- Date
- 2026-10-01
- Highlights
- Default full screen, codemode prompt words reduced by about 40%, codemode image generation, MCP OAuth enhancement
1.1.0
- Date
- 2026-10-07
- Highlights
--tools +name/-name, GPT-6 Luna classifier and image classification, OSC 7501 program status
1.2.0
- Date
- 2026-10-12
- Highlights
- Release configuration JSON Schema,
before_agent_startOverriding extension-triggered runs (breaking changes)
1.3.0
- Date
- 2026-10-15
- Highlights
sessionShareDestination, restore the session to retain the activation tool, and discard the old model when switching models.
| version | Date | Highlights |
|---|---|---|
| 0.99.0 | 2026-09-29 | Codemode with MCP, system theme, Sign in with ChatGPT, virtual model, classifier model |
| 0.99.2 | 2026-09-30 | The MCP exposed by the default codemode is no longer listed in the codemode description/does not block the first prompt;/reload Enable new joins defaultTools tools |
| 1.0.0 | 2026-10-01 | Default full screen, codemode prompt words reduced by about 40%, codemode image generation, MCP OAuth enhancement |
| 1.1.0 | 2026-10-07 | --tools +name/-name, GPT-6 Luna classifier and image classification, OSC 7501 program status |
| 1.2.0 | 2026-10-12 | Release configuration JSON Schema,before_agent_start Overriding extension-triggered runs (breaking changes) |
| 1.3.0 | 2026-10-15 | sessionShareDestination, restore the session to retain the activation tool, and discard the old model when switching models. |
Learning suggestions: Pi iterates quickly. If you encounter any inconsistencies with this article, please use
pi --help, installed version.d.tsand the latest CHANGELOG shall prevail.