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

  1. ~/.pi/agent/AGENTS.md: Write general preferences (language, coding style, submission specifications);
  2. Project AGENTS.md:Write the build/test command of the project;
  3. 3 prompt templates:/review [focus]、/commit [type]、/explain <path>;
  4. 1 skill release-notes: Contains SKILL.md and references/template.md;
  5. in settings.json Set 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

  1. tool_call intercept dangerous bash(rm -rf、sudo、git push --force、curl … | sh)——Confirm when there is UI, block when there is no UI;
  2. Block writing .env、.git/、node_modules/、*.pem;
  3. According to tools annotations(MCP tool’s destructiveHint etc.) decide whether to confirm;
  4. ctx.ui.setStatus() The bottom bar displays the number of times this session has been blocked;
  5. /guard-log The command lists the interception records of this session (use pi.appendEntry() persistence,session_start time from getBranch() 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

  1. Register git_summary Tools (outputSchema + structuredContent), returns the current branch, number of changed files, ahead/behind;
  2. /checkpoint Command: use pi.exec("git", [...]) Create stash or WIP submissions;
  3. session_shutdown If there are uncommitted changes, ask whether to submit them automatically (skip if there is no UI);
  4. Register --auto-commit CLI 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

  1. Read-only startup:pi --no-session --tools read,grep,find,ls --mode json;
  2. Input:git diff origin/main...HEAD | pi --mode json --no-session --tools read,grep,find,ls "审查这个 diff,输出风险列表" > events.jsonl;
  3. Write a Node or Python script to parse JSONL (Split by LF without Node readline), extract the final message_end assistant text, all tool calls, and durationMs, total dosage;
  4. 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);
  5. Advanced: add a belt terminate: true of structured_output Tools (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):

  1. use createAgentSession() + SessionManager.continueRecent() Build an HTTP/WebSocket service;
  2. put session.subscribe() of text_delta、tool_execution_* Events are pushed to the front end;
  3. Messages sent by the front end during operation go session.steer() / session.followUp();
  4. Pass extensionFactories Inject an inline extension that provides business tools (such as querying internal APIs);
  5. to agent_settled As a "done" signal; when the page is closed session.dispose()。

Option B (RPC, any language):

  1. Start with Python/Go pi --mode rpc;
  2. Implement command id association, event distribution,streamingBehavior;
  3. Implement extended UI subprotocol: received extension_ui_request(select/confirm) pop-up window on the front end and return extension_ui_response;
  4. 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

  1. To connect to a real MCP server (such as GitHub, file system or your company's service), use toolExposure Design: query class codemode, high frequency tools direct, delete class hidden;
  2. turn on +codemode, design a reminder template /triage, guide the model to use codemode to pull issues, filter, and summarize in parallel;
  3. (Optional) If you have classifier model credentials, use models.classify() Give the issue an urgency score;
  4. Implement virtual models router/auto: Use a strong model for planning, a cheap model for execution, and store routing status. phase;
  5. Package guard extensions, git extensions, templates, skills, and virtual model extensions into @yourname/pi-kit: Set correctly peerDependencies、pi list and pi-package Keywords;
  6. use pi install ./pi-kit local verification,pi config Check the resource; then use it on another machine pi install git:...@v0.1.0 Installation.

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_end with agent_settled The difference
  • [ ] can tell /tree、/fork、/clone difference
  • [ ] 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,details and 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)
ClassificationPage
Getting StartedOverview(/)、Quickstart(/quickstart)、How Pi Works(/how-pi-works)
UseUsage(/usage)、Models(/models)、Sessions(/sessions)、Security(/security)、Containerization(/containerization)、llama.cpp(/llama-cpp)、Terminal Setup(/terminal-setup)
CustomizedConfiguration(/configuration)、Settings(/settings)、Prompt Templates(/prompt-templates)、Skills(/skills)、Themes(/themes)、Keybindings(/keybindings)
ExpandExtensions(/extensions)、Terminal UI(/tui)、Custom Providers(/custom-provider)、Virtual Models(/virtual-models)、Packages(/packages)
Tools and MCPMCP(/mcp)、Codemode(/codemode)、CLI(/cli)
IntegrateSDK(/sdk)、CLI Integration(/cli-integration)、RPC(/rpc)、RPC Commands(/rpc-commands)、RPC Extension UI(/rpc-extension-ui)、JSON(/json)
ReferenceSession 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

ecology

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;/reload Enable new joins defaultTools tools
  • 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_start Overriding 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.
versionDateHighlights
0.99.02026-09-29Codemode with MCP, system theme, Sign in with ChatGPT, virtual model, classifier model
0.99.22026-09-30The 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.02026-10-01Default full screen, codemode prompt words reduced by about 40%, codemode image generation, MCP OAuth enhancement
1.1.02026-10-07--tools +name/-name, GPT-6 Luna classifier and image classification, OSC 7501 program status
1.2.02026-10-12Release configuration JSON Schema,before_agent_start Overriding extension-triggered runs (breaking changes)
1.3.02026-10-15sessionShareDestination, 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.ts and the latest CHANGELOG shall prevail.