mcpField
C
claude-use-gemini-acp

claude-use-gemini-acp

github.com/genericserviceAgent workflows037 installsUpdated 23w ago
Repository

About claude-use-gemini-acp

claude-use-gemini-acp is a Claude skill that invokes Gemini CLI through ACP for one prompt and streams its response. It is intended for tasks needing more context, Google Search grounding, or a second model opinion.

Key features

  1. 01Launch Gemini CLI in ACP mode
  2. 02Send a prompt in a fresh session
  3. 03Stream response chunks to stdout
  4. 04Configure model, CLI version, and working directory
  5. 05Terminate the subprocess after completion

Use cases

  1. 01Requesting a second model opinion
  2. 02Delegating a task with more context
  3. 03Asking Gemini for Google Search grounding
  4. 04Running multiple focused prompts sequentially

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/genericservice/claude-skills --skill claude-use-gemini-acp

After installing, type/claude-use-gemini-acpin Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

scripts/
.gitignore
gemini-delegate.mjs
package.json
pnpm-lock.yaml

Details

From the project README

Claude → Gemini via ACP

Spawn a Gemini CLI subprocess in ACP mode, send a prompt, stream the response to stdout, and terminate cleanly. No persistent session — one prompt, one response.

When to use

  • The task requires more context than fits in Claude's window
  • You want real-time Google Search grounding
  • You want a second opinion from a different model
  • The user says "ask Gemini", "use Gemini for this", etc.

Setup (first use only)

cd ~/.claude/skills/claude-use-gemini-acp/scripts
pnpm install

This installs @agentclientprotocol/sdk into the local node_modules/. Subsequent runs skip this step — pnpm caches the result.

Usage

GEMINI_MODEL=gemini-2.5-pro \
TARGET_CWD=/path/to/project \
node ~/.claude/skills/claude-use-gemini-acp/scripts/gemini-delegate.mjs \
  "Summarize the architecture in ARCHITECTURE.md and list the top 3 risks"

The response streams to stdout as Gemini generates it. Capture it for use in your response:

response=$(node ~/.claude/skills/claude-use-gemini-acp/scripts/gemini-delegate.mjs "your prompt")

Environment variables

VariableDefaultDescription
GEMINI_MODELgemini-2.5-proModel to use
GEMINI_CLI_VERSIONnightlygemini-cli package version (nightly or a specific semver)
TARGET_CWDcurrent working dirWorking directory passed to the Gemini session

How it works

  1. Spawns pnpm dlx @google/gemini-cli@<version> --acp --yolo --model <model>
  2. Connects via @agentclientprotocol/sdk's ClientSideConnection + ndJsonStream
  3. Sends initialize → newSession → prompt over the ACP session
  4. Streams agent_message_chunk deltas to stdout as they arrive
  5. Terminates the subprocess once the prompt response completes

The --yolo flag (-y) auto-approves all tool calls inside Gemini's session.

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 Gemini to read them (it can use its filesystem tools)
  • Keep prompts focused: one clear task per invocation
  • For multi-step work, do multiple sequential invocations rather than one sprawling prompt

Error handling

If the script exits non-zero, check stderr for:

  • pnpm dlx download failures (network, auth)
  • Gemini auth errors (gemini auth login may be needed)
  • ACP initialization failures (version mismatch)

The script does not retry — if something fails, surface the error to the user and suggest re-running after fixing the root cause.

Comments

Markdown supported