Use Pi (the earendil-works/pi coding agent, running GLM by default) from inside Claude Code for code reviews or to delegate tasks.
Pi runs in RPC mode (pi --mode rpc): the plugin spawns a Pi process, speaks the JSONL protocol over stdin/stdout, and waits for agent_settled before reading the result. This gives clean abort, real session resume, and native Pi session transfer — improvements over a plain CLI-spawn approach.
It is intended for Claude Code users who want a second model — GLM via Pi — to review their work or take on delegated tasks.
/pi:reviewfor a read-only code review/pi:adversarial-reviewfor a steerable challenge review/pi:rescue,/pi:transfer,/pi:status,/pi:result, and/pi:cancelto delegate work, hand off sessions, and manage background jobs
- Pi CLI installed (see https://pi.dev)
- A configured Pi provider for GLM. The default model is
zai/glm-5.1. - Node.js 18.18 or later
Pi talks to GLM through the zai provider. Set the API key as an environment variable:
export ZAI_API_KEY="your-zai-coding-plan-key"Verify Pi can see the model:
pi --version
# then in an interactive Pi session, /models should list zai/glm-5.1Note on provider/model ids: Pi registers the ZAI Coding Plan provider as
zai, so the full model id iszai/glm-5.1(passed to the plugin as--model zai/glm-5.1or set viaPI_PLUGIN_MODEL). Thezai-coding-cnprovider points at the domestic endpoint.
Add the marketplace:
/plugin marketplace add cuongducle/pi-plugin-ccInstall the plugin:
/plugin install pi@cuongducle-piReload plugins:
/reload-plugins/pi:setup/pi:setup checks whether Pi is installed and the runtime is ready. There is no separate login step if ZAI_API_KEY is set; otherwise run pi interactively and use /login.
After install you should see the slash commands listed below and the pi:pi-rescue subagent in /agents.
A simple first run:
/pi:review --background
/pi:status
/pi:resultRuns a read-only code review of your current work by handing the diff to GLM and asking for structured findings.
Use --base <ref> for branch review. It also supports --wait and --background.
/pi:review
/pi:review --base main
/pi:review --backgroundNote
Code review for multi-file changes may take a while. It is generally recommended to run it in the background.
The review prompt asks GLM to return a strict JSON object (verdict, summary, findings, next_steps). The parser also tolerates models that wrap the JSON in prose or markdown fences — it scans every fenced block and balanced {...} substring and picks the first that both parses and matches the review shape.
Runs a steerable review that questions the chosen implementation and design. It supports --base <ref>, --wait, --background, and extra focus text after the flags.
/pi:adversarial-review --base main challenge whether this was the right caching and retry design
/pi:adversarial-review --background look for race conditions and question the chosen approachHands a task to Pi through the pi:pi-rescue subagent. It supports --background, --wait, --resume, --fresh, and --model. Add --write for a write-capable run (the subagent defaults to write-capable unless you ask for read-only behavior).
/pi:rescue investigate why the tests started failing
/pi:rescue fix the failing test with the smallest safe patch
/pi:rescue --resume apply the top fix from the last run
/pi:rescue --model zai/glm-5.1 investigate the flaky integration test
/pi:rescue --background investigate the regressionNotes:
- If you do not pass
--model, the default (zai/glm-5.1, or whateverPI_PLUGIN_MODELis set to) is used. - Follow-up rescue requests can continue the latest Pi task in the repo via
--resume.
Writes a real Pi session file from the current Claude Code transcript so you can continue the conversation natively in Pi. Unlike a prompt-seed, this emits a valid Pi session JSONL (header + chained user/assistant message entries) that Pi loads via pi --session <path>.
/pi:transfer
/pi:transfer --source ~/.claude/projects/-Users-me-repo/<session-id>.jsonlNote
The continuation is not byte-for-byte identical to the Claude session (tool calls/results are summarized into text), but Pi sees the full turn history and can continue from there.
Shows running and recent Pi jobs for the current repository.
/pi:status
/pi:status task-abc123Shows the final stored Pi output for a finished job. When available it includes the Pi session id so you can reopen that run with pi --session <id>.
/pi:result
/pi:result task-abc123Cancels an active background Pi job. The plugin sends a Pi RPC abort and terminates the worker process tree.
/pi:cancel
/pi:cancel task-abc123Checks whether Pi is installed. If Pi is missing it can offer to install it for you.
export PI_PLUGIN_MODEL="zai/glm-5.1"You can also pass --model <provider/model> to /pi:rescue and the review commands for a one-off override.
Each task or review spawns a fresh pi --mode rpc process. The companion speaks the JSONL RPC protocol:
- Sends
{"type":"prompt","message":"..."}— thesuccessresponse only means "accepted", not "done". - Streams events (
message_update,tool_execution_*,turn_end). - Waits for
{"type":"agent_settled"}— the authoritative stop signal (NOTagent_end, which may be followed by retry/compaction/queued follow-ups). - Retrieves the final answer via
get_last_assistant_text. - Aborts via
{"type":"abort"}(clean cancel) and closes stdin.
stdout is split on LF only (NOT readline — U+2028/U+2029 are legal inside JSON strings and would corrupt framing). Job state (status, session id, logs) is persisted per workspace so /pi:status, /pi:result, and /pi:cancel work across foreground and background runs.
Pi has no permission gate in RPC mode — bash/edit/write run non-interactively by default. The plugin launches Pi with --no-extensions --no-skills so no extension can block on a UI request, and restricts tools to read,grep,find,ls,bash for review/read-only runs.
| Aspect | codex-plugin-cc | opencode-plugin-cc | pi-plugin-cc |
|---|---|---|---|
| Backend | Codex CLI (GPT) | opencode CLI (GLM) | Pi RPC mode (GLM) |
| Transport | JSON-RPC app server | opencode run NDJSON |
pi --mode rpc JSONL |
| Cancel | turn/interrupt RPC |
kill process | {"type":"abort"} (clean) |
| Done signal | turn/completed | process exit | agent_settled (precise) |
| Resume | codex resume |
--session |
switch_session + JSONL |
| Transfer | native import | summarize → prompt | write real Pi session JSONL |
| Permissions | approval policy | --auto |
no gate (RPC default) |
Apache-2.0. See NOTICE.