From toby-essentials
Delegates coding tasks to Google Gemini CLI agent in the background via bash. Triggers on Gemini delegation phrases, second opinions from Gemini/Google, or parallel Google agent runs.
npx claudepluginhub tobyilee/toby-plugins --plugin toby-essentialsThis skill uses the workspace's default tool permissions.
Delegate tasks to Google Gemini CLI agent running in the background and retrieve results.
Provides decision criteria, execution patterns, and handling for delegating tasks from Claude to Gemini CLI. Use for cross-agent optimization, risky commands, or TUI needs.
Invokes Google Gemini CLI for complex reasoning, research, and AI tasks in headless mode. Supports preview models, fallbacks, and session continuation.
Delegates tasks to Gemini CLI for large-context analysis like broad codebase reviews or long-document processing. Activates on explicit requests such as 'use gemini' or 'delegate to gemini'.
Share bugs, ideas, or general feedback.
Delegate tasks to Google Gemini CLI agent running in the background and retrieve results.
npm install -g @google/gemini-cli (gemini binary available)gemini interactively to set up OAuth if neededBuild a clear, self-contained prompt for Gemini. The prompt must work independently — Gemini has no access to this conversation's context.
Gather context first. Before composing the prompt, collect relevant information to include:
# Context to gather:
- Relevant source files (read key files and include snippets in the prompt)
- Recent git changes: git diff HEAD~3 --stat (if relevant)
- Project structure: a brief tree or file listing
- Build/test commands the agent should use
- Error messages or logs (if debugging)
Compose the prompt with this structure:
Wrap the prompt in single quotes to avoid shell interpolation issues. If the prompt contains single quotes, use a heredoc approach instead.
Generate a unique result file path and execute Gemini using the Bash tool with run_in_background: true:
RESULT_FILE="/tmp/gemini-result-$(date +%s)-$RANDOM.md"
gemini -p '<TASK_PROMPT>' \
-y \
--model gemini-3.1-pro-preview \
--include-directories "<WORKING_DIRECTORY>" \
-o text \
> "$RESULT_FILE" 2>&1
echo "===GEMINI_RESULT_FILE:$RESULT_FILE==="
For prompts containing single quotes, use a heredoc:
RESULT_FILE="/tmp/gemini-result-$(date +%s)-$RANDOM.md"
gemini -p "$(cat <<'PROMPT'
<TASK_PROMPT_WITH_QUOTES>
PROMPT
)" \
-y \
--model gemini-3.1-pro-preview \
--include-directories "<WORKING_DIRECTORY>" \
-o text \
> "$RESULT_FILE" 2>&1
echo "===GEMINI_RESULT_FILE:$RESULT_FILE==="
| Flag | Purpose |
|---|---|
-p <text> | Non-interactive/headless mode (required for background execution) |
-y / --yolo | Auto-approve all tool executions without prompting |
--approval-mode yolo | Equivalent to -y (also accepts auto_edit, plan) |
-o text | Plain text output (-o json for structured output with metadata) |
--include-directories <dir> | Additional directories to include in the workspace |
-m <model> | Override model (optional, uses CLI default if omitted) |
-s / --sandbox | Run in sandboxed mode for safer execution |
> "$RESULT_FILE" | Redirect stdout to file (Gemini outputs to stdout, no file flag) |
After launching, inform the user:
If the task is taking long or the user asks for status, check the background task:
# Check if the process is still running
TaskOutput(task_id="<task_id>", block=false)
# Peek at partial output
tail -20 /tmp/gemini-result-*.md 2>/dev/null
If the task appears stuck (no output for extended time), inform the user and offer to cancel and retry.
When the background task completes:
git diff to show what changedWhen the user wants to compare approaches or get a second opinion, send the same task to both Gemini and Codex simultaneously. Launch both with run_in_background: true in the same turn:
# Launch Gemini
GEMINI_RESULT="/tmp/gemini-result-$(date +%s)-$RANDOM.md"
gemini -p '<TASK>' -y --model gemini-3.1-pro-preview -o text > "$GEMINI_RESULT" 2>&1
# Launch Codex (in a separate Bash call, same turn)
CODEX_RESULT="/tmp/codex-result-$(date +%s)-$RANDOM.md"
codex exec '<TASK>' --full-auto --ephemeral -C "<DIR>" -o "$CODEX_RESULT" 2>&1
When both complete, present a side-by-side comparison highlighting differences in approach, code style, and correctness.
By default, use --model gemini-3.1-pro-preview. Override only when the user explicitly requests a different model:
# Default
gemini -p "task" -y --model gemini-3.1-pro-preview -o text
# Override with specific model
gemini -p "task" -y --model gemini-2.5-pro -o text
| Error | Action |
|---|---|
| Auth failure | Run gemini interactively to re-authenticate via OAuth |
| Empty output | Check stderr from background task output |
| Timeout | Check task status with TaskOutput(block=false); offer to cancel and retry |
| Command not found | Run npm install -g @google/gemini-cli |
| Process stuck | No new output for >2min — inform user, offer cancel |
-y (yolo mode) allows Gemini to execute commands and modify files without approval. This is required for background execution. Use -s (sandbox mode) alongside -y for safer execution when the task doesn't need unrestricted system access.