home / skills / renocrypt / latex-arxiv-skill / collaborating-with-gemini

collaborating-with-gemini skill

/.codex/skills/collaborating-with-gemini

This skill helps you collaborate with Gemini via a bridge script to delegate prototyping, debugging, and code review tasks while preserving final control.

npx playbooks add skill renocrypt/latex-arxiv-skill --skill collaborating-with-gemini

Review the files below or copy the command above to add this skill to your agents.

Files (4)
SKILL.md
4.3 KB
---
name: collaborating-with-gemini
description: Use the Gemini CLI to consult Gemini and delegate coding tasks for prototyping, debugging, and code review. Supports multi-turn sessions via SESSION_ID. Optimized for low-token, file/line-based handoff.
metadata:
  short-description: Delegate to Gemini CLI
---

# Collaborating with Gemini (Codex)

Use Gemini CLI as a collaborator while keeping Codex as the primary implementer.

This skill provides a lightweight bridge script that returns structured JSON and supports multi-turn sessions via `SESSION_ID`.

## Core rules
- Gemini is a collaborator; you own the final result and must verify changes locally.
- Do not invoke `gemini` directly; always use the bridge script (`scripts/gemini_bridge.py`) so output/session handling stays consistent.
- Prefer file/line references over pasting snippets. Run the bridge with `--cd` set to the repo root (it sets the `gemini` process working directory). Use `--cd "."` only if your CWD is the repo root.
- For code changes, request **Unified Diff Patch ONLY** and forbid direct file modification.
- Always capture `SESSION_ID` and reuse it for follow-ups to keep the collaboration conversation-aware.
- Keep a short **Collaboration State Capsule** updated while this skill is active.
- Default timeout: when invoking via the Codex command runner, set `timeout_ms` to **600000 (10 minutes)** unless a shorter/longer timeout is explicitly required.
- Optional: pass `--sandbox` to run Gemini in sandbox mode.

## Quick start (shell-safe)

⚠️ If your prompt contains Markdown backticks (`` `like/this` ``), do **not** pass it directly via `--PROMPT "..."` (your shell may treat backticks as command substitution). Use a heredoc instead; see `references/shell-quoting.md`.

```bash
PROMPT="$(cat <<'EOF'
Review src/auth.py around login() and propose fixes.
OUTPUT: Unified Diff Patch ONLY.
EOF
)"
python3 .codex/skills/collaborating-with-gemini/scripts/gemini_bridge.py --cd "." --PROMPT "$PROMPT"
```

**Output:** JSON with `success`, `SESSION_ID`, `agent_messages`, and optional `error` / `all_messages`.

## Multi-turn sessions

```bash
# Start a session
PROMPT="$(cat <<'EOF'
Analyze the bug in foo(). Keep it short.
EOF
)"
python3 .codex/skills/collaborating-with-gemini/scripts/gemini_bridge.py --cd "." --PROMPT "$PROMPT"

# Continue the same session
PROMPT="$(cat <<'EOF'
Now propose a minimal fix as Unified Diff Patch ONLY.
EOF
)"
python3 .codex/skills/collaborating-with-gemini/scripts/gemini_bridge.py --cd "." --SESSION_ID "<SESSION_ID>" --PROMPT "$PROMPT"
```

## Prompting patterns (token efficient)

Use `assets/prompt-template.md` as a starter when crafting `--PROMPT`.

### 1) Ask Gemini to open files itself
Provide:
- Entry file(s) and approximate line numbers
- Objective and constraints
- Output format (diff vs analysis)

Avoid:
- Pasting large code blocks
- Multiple competing objectives in one request

### 2) Enforce safe output for code changes
Append this to prompts when requesting code:
- `OUTPUT: Unified Diff Patch ONLY. Strictly prohibit any actual modifications.`

### 3) Use Gemini for what it’s good at
- Alternative solution paths and edge cases
- UI/UX and readability feedback
- Review of a proposed patch (risk spotting, missing tests)

### 4) Sharing clipboard screenshots with Gemini

Gemini can only read files inside the workspace root (`--cd`). Codex saves clipboard PNGs into the OS temp directory (e.g. `${TMPDIR:-/tmp}`), which Gemini can’t access, and it may refuse ignored paths (e.g. `tmp/`). Copy the image into `.codex_uploads/`, then reference that path in your prompt. Delete screenshots when done. **Do not add `.codex_uploads/` to `.gitignore`**—Gemini refuses to read ignored paths.

```bash
mkdir -p .codex_uploads && cp "${TMPDIR:-/tmp}"/codex-clipboard-<id>.png .codex_uploads/
```

## Advanced flags
- `--sandbox`: Run Gemini in sandbox mode.
- `--model <name>`: Override the default Gemini model.
- `--return-all-messages`: Include all raw messages (tool calls, traces) in output JSON.

## Collaboration State Capsule
Keep this short block updated near the end of your reply while collaborating:

```text
[Gemini Collaboration Capsule]
Goal:
Gemini SESSION_ID:
Files/lines handed off:
Last ask:
Gemini summary:
Next ask:
```

## References
- `assets/prompt-template.md` (prompt patterns)
- `references/shell-quoting.md` (shell quoting/backticks)

Overview

This skill enables a tight collaboration workflow with Gemini via a bridge script so you can delegate prototyping, debugging, and code review while retaining final control. It optimizes for low-token, file-and-line-based handoffs and supports multi-turn sessions using SESSION_ID. The interface returns structured JSON for safe automation and repeatable interactions.

How this skill works

Run the provided bridge script to send prompts to Gemini; the script returns structured JSON including success, SESSION_ID, and agent messages. Prefer file/line references instead of pasting large snippets; request Unified Diff Patch ONLY for code changes to avoid direct file modification. Reuse SESSION_ID for follow-ups so Gemini remains context-aware across turns.

When to use it

  • Prototyping a small feature or API sketch and wanting quick diffs
  • Debugging a localized bug by pointing to exact file/line ranges
  • Requesting a concise code review or security/risk spot-check
  • Generating minimal, reviewable Unified Diff patches for integration
  • Running iterative multi-turn conversations with persistent context

Best practices

  • Always run Gemini through the bridge script to ensure consistent session handling
  • Use --cd to set the workspace root and give file paths relative to that root
  • Request 'OUTPUT: Unified Diff Patch ONLY.' when asking for code changes
  • Capture and reuse SESSION_ID for follow-ups to preserve context
  • Keep a short Collaboration State Capsule updated between turns
  • Set timeout_ms to 600000 (10 minutes) by default unless you need a different timeout

Example use cases

  • Start a session to analyze a failing test in src/model.tex and then request a minimal patch
  • Ask Gemini to propose alternative LaTeX scaffolding for an arXiv review section and return a diff
  • Run a focused security/style review on a BibTeX workflow and get a risk list plus diffs
  • Iteratively refine a citation verification script by reusing SESSION_ID across turns
  • Hand off a screenshot saved to .codex_uploads/ for UX feedback while keeping workspace-restricted files accessible

FAQ

Can Gemini modify files directly?

No. Always request Unified Diff Patch ONLY and apply changes locally after review.

What if I need Gemini to see an image or clipboard screenshot?

Copy the image into .codex_uploads/ and reference that path; avoid ignored paths so Gemini can access the file.