Use when adding new error messages to React, or seeing "unknown error code" warnings.
npx skills add ZhenHuangLab/collaborating-with-gemini-cli
Or install specific skill: npx add-skill https://github.com/ZhenHuangLab/collaborating-with-gemini-cli
# Description
Delegates code review, debugging, and alternative implementation comparisons to Google Gemini CLI (`gemini`) via a JSON bridge script (default model: `gemini-3-pro-preview`). Supports headless one-shot and multi-turn sessions via `SESSION_ID`, with conservative defaults for Gemini effective-context constraints (file-scoped, `--no-full-access` by default) while allowing user override.
# SKILL.md
name: collaborating-with-gemini-cli
description: "Delegates code review, debugging, and alternative implementation comparisons to Google Gemini CLI (gemini) via a JSON bridge script (default model: gemini-3-pro-preview). Supports headless one-shot and multi-turn sessions via SESSION_ID, with conservative defaults for Gemini effective-context constraints (file-scoped, --no-full-access by default) while allowing user override."
Collaborating with Gemini CLI
Use this skill when you want a second model (Gemini) to sanity-check a solution, spot edge cases, propose tests, or suggest an alternative implementation approach.
This skill provides a small JSON bridge script that runs gemini (Gemini CLI) in non-interactive headless mode and returns structured output.
Compared to collaborating-with-claude-code, this skill defaults to read-only and is optimized for file-scoped, one-shot requests to avoid practical effective-context degradation.
Requirements
- Gemini CLI installed (
gemini --version). - Install via npm:
npm i -g @google/gemini-cli - Gemini CLI authenticated (Google account login or API key auth, depending on your local setup).
- Python 3 (to run the bridge script).
Quick start
python scripts/gemini_cli_bridge.py --cd "/path/to/repo" --PROMPT "Review src/auth/login.py for bypasses; propose fixes as a unified diff."
Recommended (explicit file scope, best for effective context):
python scripts/gemini_cli_bridge.py --cd "/path/to/repo" --file "src/auth/login.py" --PROMPT "Review this file for bypasses; propose fixes as a unified diff."
Multi-turn sessions
Always capture the returned SESSION_ID and pass it back on follow-ups:
# Start a new session (one-shot by default)
python scripts/gemini_cli_bridge.py --cd "/repo" --file "src/auth/login.py" --PROMPT "Summarize issues and propose a patch."
# Continue the same session
python scripts/gemini_cli_bridge.py --cd "/repo" --SESSION_ID "uuid-from-response" --PROMPT "Now propose 5 targeted tests for the fix."
Access modes
This skill defaults to --no-full-access (read-only).
- Read-only (default):
--no-full-access→ maps togemini --approval-mode default - Full access (edits allowed):
--full-access→ maps togemini --approval-mode auto_edit - YOLO (auto-approve everything):
--yolo→ maps togemini --approval-mode yolo
Examples:
# Allow edits (auto-approve edit tools)
python scripts/gemini_cli_bridge.py --full-access --cd "/repo" --file "src/foo.py" --PROMPT "Refactor for clarity; keep behavior; apply edits."
# YOLO mode (dangerous): allow any tool calls without confirmation
python scripts/gemini_cli_bridge.py --yolo --cd "/repo" --PROMPT "Run tests, fix failures, and apply edits."
Effective-context guardrails (default ON)
By default the bridge enables conservative guardrails designed for practical effective context:
- Adds a preamble instructing Gemini to stop and ask before reading additional files.
- Strongly encourages file-scoped runs (use
--fileand keep each call small). - Uses
--max-filesas a preference for “how many files per turn” and as a cap for auto-extracted files (only when you did not pass explicit--file).
User override options:
--file PATH(repeatable): explicitly decide the focus file set (recommended; not blocked by--max-files).--max-files N: raise the preferred cap / auto-extraction cap.--no-guardrails: disable guardrails (Gemini may read many files; treat like a normal agent).
Session rotation guidance (effective context)
The bridge exposes Gemini CLI token stats when available:
meta.prompt_tokens: prompt tokens reported by Gemini CLImeta.over_effective_context_limit:truewhenprompt_tokens > --effective-context-tokens
When meta.over_effective_context_limit is true, prefer starting a new session for the next turn (omit --SESSION_ID) and/or reduce the focus scope.
Parameters (bridge script)
--PROMPT(required): Instruction to send to Gemini.--cd(required): Working directory to run Gemini CLI in (typically repo root).--SESSION_ID(optional): Resume an existing Gemini CLI session (uuid).--model(optional): Defaults togemini-3-pro-preview.--full-access/--no-full-access(optional): Defaults to--no-full-access.--yolo(optional): YOLO approval mode (implies full access).--sandbox(optional): Run Gemini CLI in sandbox mode (requires Docker). Default: off.--return-all-messages(optional): Return the full streamed event list (debugging).--file PATH(repeatable): Focus files to prepend as@PATH(recommended).--max-files/--no-guardrails/--effective-context-tokens: Guardrail controls (--max-filesis a preference + auto-extraction cap; it does not block explicit--file).--timeout-s(optional): Defaults to 1800 seconds.
Output format
The bridge prints JSON:
{
"success": true,
"SESSION_ID": "uuid",
"agent_messages": "…Gemini output…",
"all_messages": [],
"meta": {}
}
meta includes the normalized focus file list and (when available) token stats extracted from Gemini CLI output.
# README.md
collaborating-with-gemini-cli
中文 | English
这是 Codex CLI 的一个 skill:通过一个 JSON bridge 脚本,把“代码审查 / 调试 / 方案对比”等任务委托给 Google Gemini CLI(默认模型:gemini-3-pro-preview),并以结构化 JSON 结果返回,便于在多模型协作中使用。
与 collaborating-with-claude-code 相比,由于 gemini-3-pro-preview 的注意力机制以及上下文能力较差,本 skill 的默认策略更保守:
- 默认 只读(
--no-full-access) - 鼓励 one-shot + 文件聚焦(默认建议 5 个文件以内;如确实需要更多文件,应由主 agent / Codex 决定,可显式传多个
--file或调整--max-files/ 关闭 guardrails)
核心入口:
SKILL.md(Codex skill 定义)scripts/gemini_cli_bridge.py(Gemini CLI 桥接脚本)
安装到 ~/.codex/skills/
1) 选择安装目录 ~/.codex/skills (若不存在请创建):
mkdir -p ~/.codex/skills
2) Clone 本仓库到 skills/ 目录下
cd ~/.codex/skills
git clone https://github.com/ZhenHuangLab/collaborating-with-gemini-cli.git collaborating-with-gemini-cli
3) 验证文件结构,保证目录结构至少包含 SKILL.md 和 scripts/:
ls -la ~/.codex/skills/collaborating-with-gemini-cli
完成后,在对话中提到 collaborating-with-gemini-cli(或 $collaborating-with-gemini-cli , 或者表达类似的意思)即可触发使用。
依赖
- Python 3(用于运行 bridge 脚本)。
- Gemini CLI 已安装并可用(确保
gemini --version可运行)。 - 安装:
npm i -g @google/gemini-cli - Gemini CLI 已完成认证(Google 账号登录或 API Key 方式,取决于你的本机配置)。
手动运行(不通过 Codex CLI)
最简单的一次性调用:
python scripts/gemini_cli_bridge.py --cd "/path/to/repo" --PROMPT "Review src/auth/login.py for bypasses; propose fixes as a unified diff."
推荐(明确指定 focus files;默认建议 5 个文件以内,更贴合 effective-context 约束):
python scripts/gemini_cli_bridge.py --cd "/path/to/repo" --file "src/auth/login.py" --PROMPT "Review this file and propose a unified diff."
多轮会话(同一 SESSION_ID):
# Turn 1
python scripts/gemini_cli_bridge.py --cd "/repo" --file "src/auth/login.py" --PROMPT "List risks + propose patch."
# Turn 2 (resume)
python scripts/gemini_cli_bridge.py --cd "/repo" --SESSION_ID "uuid-from-response" --PROMPT "Now propose tests for the patch."
允许改文件(默认 auto_edit;更危险的 YOLO 见 SKILL.md):
python scripts/gemini_cli_bridge.py --full-access --cd "/repo" --file "src/foo.py" --PROMPT "Refactor for clarity; keep behavior; apply edits."
更完整的参数说明、输出格式与 guardrails 见 SKILL.md。
License
MIT License,详见 LICENSE。
# Supported AI Coding Agents
This skill is compatible with the SKILL.md standard and works with all major AI coding agents:
Learn more about the SKILL.md standard and how to use these skills with your preferred AI coding agent.