claude-code-pi
Bridge Claude Code CLI models into Pi strictly through claude -p
Package details
Install claude-code-pi from npm and Pi will load the resources declared by the package manifest.
$ pi install npm:claude-code-pi- Package
claude-code-pi- Version
1.0.1- Published
- Aug 21, 2026
- Downloads
- 399/mo · 21/wk
- Author
- luong.nguyen
- License
- MIT
- Types
- extension
- Size
- 68.7 KB
- Dependencies
- 0 dependencies · 2 peers
Pi manifest JSON
{
"extensions": [
"./src/index.ts"
]
}Security note
Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.
README
claude-code-pi

claude-code-pi registers a claude-code-cli provider in Pi and delegates every model call to the local Claude Code CLI with claude -p / --print.
This extension is intentionally a CLI bridge. It does not use the Anthropic SDK, direct HTTP APIs, or Pi's built-in Claude provider as a fallback. If claude -p is unavailable or fails, the Pi model turn fails with setup guidance instead of silently using another transport.
Requirements
- Pi Coding Agent
- Claude Code CLI installed and available on the same machine:
claude --version
- Claude Code authenticated/configured according to your local Claude Code setup.
Install
From this repository:
npm run install-extensions
Then restart Pi or run:
/reload
For one-off development testing without copying:
pi -e ./extensions/claude-code-pi/src/index.ts
Usage
Pick provider claude-code-cli from /model, or start Pi directly:
pi --provider claude-code-cli --model sonnet
Bundled model aliases mirror common Claude Code CLI --model aliases:
| Pi provider | Pi model id | Passed to Claude Code |
|---|---|---|
claude-code-cli |
sonnet |
claude -p --model sonnet |
claude-code-cli |
opus |
claude -p --model opus |
claude-code-cli |
fable |
claude -p --model fable |
Print-mode smoke test:
pi -p --provider claude-code-cli --model sonnet "Reply with exactly OK"
Direct Claude Code transport check:
claude -p --model sonnet --no-session-persistence --tools "" "Reply with exactly OK"
Commands:
/claude-code-pi status
/claude-code-pi models
/claude-code-pi test
/claude-code-pi help
Configuration
| Environment variable | Description |
|---|---|
CLAUDE_CODE_PI_BIN |
Override the Claude Code executable path. Defaults to claude. |
CLAUDE_CODE_PI_MODELS |
Comma- or space-separated model aliases to register. Defaults to sonnet,opus,fable. |
CLAUDE_CODE_PI_TIMEOUT_MS |
Per-turn claude -p timeout in milliseconds. Defaults to 300000. |
CLAUDE_CODE_PI_CONTEXT_WINDOW |
Override the advertised context window in tokens. Defaults to 1000000 (current Claude aliases serve 1M-token context windows). |
Example:
CLAUDE_CODE_PI_MODELS="sonnet,opus,claude-fable-5" pi
Thinking levels
Pi thinking levels map to Claude Code's --effort flag:
| Pi thinking level | Passed to Claude Code |
|---|---|
off / unset |
no --effort flag |
minimal, low |
--effort low |
medium |
--effort medium |
high |
--effort high |
xhigh |
--effort xhigh |
Images
Models advertise image input. When a turn contains images, the extension switches to the stream-json transport (--input-format stream-json --output-format stream-json --verbose) and sends images as base64 content blocks over stdin. Text-only turns keep the plain-text transport.
How it works
For each Pi model turn, the extension:
- Serializes Pi's system prompt, conversation transcript, and available tool schemas into one text prompt.
- Spawns the local Claude Code CLI with
claude -p --model <selected> --no-session-persistence --tools "" --output-format text, plus--effort <level>when a thinking level is set. - Writes the serialized prompt (or a stream-json user message with base64 image blocks) to Claude Code over stdin.
- Converts Claude Code stdout into a Pi assistant text message, or converts
<pi_tool_call>{...}</pi_tool_call>markers into native Pi tool calls. - Emits a clear assistant error if the CLI is missing, exits non-zero, is aborted, or times out.
The extension disables Claude Code's own tools with --tools "". Pi tool schemas are included in the prompt, and explicit <pi_tool_call>{...}</pi_tool_call> markers are handed back to Pi so Pi executes tools through its normal pipeline.
Notes and limitations
- This is slower than native HTTP providers because a
claude -pprocess starts for each model turn. - Tool calling is prompt-bridged with
<pi_tool_call>{...}</pi_tool_call>markers, so it is less reliable than native provider tool calling but still keeps execution in Pi. - Image input requires the stream-json transport and is supported for base64 image blocks; availability checks use
claude --version, so real model calls may still fail if local Claude Code auth or account access is not configured.