Gemini → Claude via ACP
Spawn a Claude Code ACP adapter subprocess, send a prompt, stream the response to stdout, and terminate cleanly. No persistent session — one prompt, one response.
When to use
- The task requires complex multi-step agentic coding with MCP tool access
- You want Claude's reasoning on a specific problem
- The user says "ask Claude", "use Claude for this", etc.
- You want a second opinion from a different model
Setup (first use only)
cd ~/.gemini/skills/gemini-use-claude-acp/scripts
pnpm install
This installs @agentclientprotocol/sdk into the local node_modules/. Subsequent runs skip this step.
Usage
CLAUDE_MODEL=claude-sonnet-4-6 \
TARGET_CWD=/path/to/project \
node ~/.gemini/skills/gemini-use-claude-acp/scripts/claude-delegate.mjs \
"Refactor the auth module to use JWT tokens. The code is in src/auth/."
The response streams to stdout as Claude generates it. Capture it:
response=$(node ~/.gemini/skills/gemini-use-claude-acp/scripts/claude-delegate.mjs "your prompt")
Environment variables
| Variable | Default | Description |
|---|---|---|
CLAUDE_MODEL |
claude-sonnet-4-6 |
Model to use (applied via ACP unstable_setSessionModel) |
TARGET_CWD |
current working dir | Working directory passed to the Claude session |
How it works
- Spawns
pnpm dlx @zed-industries/claude-code-acpwith:CLAUDE_CODE_SKIP_PERMISSIONS=1— auto-approves all tool callsTERM=dumb— prevents ANSI escape sequences in outputCLAUDECODEunset — prevents the adapter refusing to start inside another Claude session~/.local/binprepended toPATH— ensures theclaudebinary is found
- Connects via
@agentclientprotocol/sdk'sClientSideConnection+ndJsonStream - Sends
initialize→newSession→unstable_setSessionModel→promptover ACP - Streams
agent_message_chunkdeltas to stdout as they arrive - Terminates the subprocess once the prompt response completes
Prompt construction tips
- Include all relevant context in the prompt string — this is a fresh session with no prior history
- Reference files by absolute path if you want Claude to read/edit them
- Keep prompts focused: one clear task per invocation
- Claude can use its MCP tools (filesystem, shell, etc.) during the session
Error handling
If the script exits non-zero, check stderr for:
pnpm dlxdownload failures (network, auth)- Claude auth errors — ensure
claudeCLI is authenticated CLAUDECODEenvironment variable being set (indicates you're running inside Claude Code; the adapter refuses to nest)- ACP initialization failures
The script does not retry — surface the error to the user and suggest re-running after fixing the root cause.