pi-claude-bridge

Pi extension that uses Claude Code (via Agent SDK) as a model provider and adds an AskClaude tool.

Package details

extension

Install pi-claude-bridge from npm and Pi will load the resources declared by the package manifest.

$ pi install npm:pi-claude-bridge
Package
pi-claude-bridge
Version
0.3.1
Published
Apr 18, 2026
Downloads
1,918/mo · 257/wk
Author
elidickinson
License
MIT
Types
extension
Size
253.3 KB
Dependencies
4 dependencies · 2 peers
Pi manifest JSON
{
  "extensions": [
    "./index.ts"
  ]
}

Security note

Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.

README

pi-claude-bridge

npm version

Pi extension that integrates Claude Code via the Agent SDK.

Built on claude-agent-sdk-pi by Prateek Sunal — the provider skeleton, tool name mapping, and settings loading originate from that project. This fork adds streaming, MCP tool bridging, custom pi tool bridging, session resume/persistence, context sync, thinking support, skills forwarding, and the AskClaude tool.

  1. Provider — Use Opus/Sonnet/Haiku as models in pi, with all tool calls flowing through pi's TUI
  2. AskClaude tool — Delegate tasks or questions to Claude Code when using another provider

Uses your Claude Max/Pro subscription. I believe this is compliant with Anthropic's terms because only the real Claude Code is touching the API and it's to enable local development not to steal API calls for some other commerical purpose. That said, obviously this extension is not endorsed or supported by Anthropic.

Install

pi install npm:pi-claude-bridge

Provider

Use /model to select claude-bridge/claude-opus-4-7, claude-bridge/claude-opus-4-6, claude-bridge/claude-sonnet-4-6, or claude-bridge/claude-haiku-4-5.

Behind the scenes, pi's tools are bridged to Claude Code but it should all work like normal in pi. Bash commands get a 120-second default timeout (matching Claude Code's default) since pi's bash has no timeout by default. Skills in pi are copied over to Claude Code's system prompt so should work as they would with any other pi provider.

AskClaude Tool

Available when using any non-claude-bridge provider. Pi's LLM can delegate tasks to Claude Code and wait for it to answer a question or perform a task. Examples of how to use:

  • "Ask Claude to plan a fix"
  • "If you get stuck, ask claude for help"
  • "Ask claude to review the plan in @foo.md, implement it, then ask an isolated=true claude to review the implementation"
  • "Ask claude to poke holes in this theory"
  • "Find all the places in the codebase that handle auth"

You could also create skills or add something to AGENTS.md to e.g. "Always call Ask Claude to review complicated feature implementations before considering the task complete."

Parameters

  • prompt — the question or task for Claude Code
  • moderead (default, read files and search/fetch on web), none, or full (read+write+bash, disable this mode with allowFullMode: false in config)
  • modelopus (default), sonnet, haiku, or a full model ID
  • thinking — effort level: off, minimal, low, medium, high, xhigh
  • isolated — when true, Claude gets a clean session with no conversation history (default: false)

Configuration

Config: ~/.pi/agent/claude-bridge.json (global) or .pi/claude-bridge.json (project).

{
  "askClaude": {
    "enabled": true,
    "allowFullMode": true,
    "defaultIsolated": false,
    "description": "Custom tool description override"
  }
}

Tests

npm run test:unit for offline tests (tests/unit-*.mjs: queue, import, skills).

npm test for the full suite, which adds integration tests that hit APIs (tests/int-*.{sh,mjs}: smoke, multi-turn, cache, session-resume, session-rebuild, tool-message). Set CLAUDE_BRIDGE_TESTING_ALT_MODEL in .env.test for the alt-provider smoke test (e.g. openrouter/z-ai/glm-4.7-flash).

Debugging

Set CLAUDE_BRIDGE_DEBUG=1 to enable debug output:

  • Bridge log at ~/.pi/agent/claude-bridge.log — every provider call, session sync decision, tool result delivery, and CC's stderr. Override location with CLAUDE_BRIDGE_DEBUG_PATH.
  • Per-query Claude Code CLI logs at ~/.pi/agent/cc-cli-logs/<timestamp>-<tag>-<seq>.log — the CC subprocess's own debug stream, one file per query() call. Tags are provider (main turn), continuation (steer replay), or askclaude (sub-delegation). Useful when a resume fails or CC misbehaves internally — shows the CLI's own view of session loading, API requests, and tool calls.

When filing a bug about a session-resume failure (e.g. "No conversation found"), the most useful attachments are the syncResult: lines from the bridge log plus the matching cc-cli-logs/ file for the failing query.

Maintenance

After updating Claude Code or the Agent SDK, check for new built-in tools that may need adding to DISALLOWED_BUILTIN_TOOLS in index.ts. Unrecognized CC tools leak through to pi as tool calls it can't handle. Symptoms: "Tool X not found" errors in pi.