Back to Skills

gemini-cli-execution

verified

Expert guide for executing the Google Gemini CLI in non-interactive and headless modes. Covers command syntax, piping input, output handling, and automation patterns. Use when running gemini commands, piping context to Gemini, scripting Gemini workflows, or using interactive shell mode. Delegates to gemini-cli-docs for official command references.

View on GitHub

Marketplace

melodic-software

melodic-software/claude-code-plugins

Plugin

google-ecosystem

Repository
Verified Org

melodic-software/claude-code-plugins
13stars

plugins/google-ecosystem/skills/gemini-cli-execution/SKILL.md

Last Verified

January 21, 2026

Install Skill

Select agents to install to:

Scope:
npx add-skill https://github.com/melodic-software/claude-code-plugins/blob/main/plugins/google-ecosystem/skills/gemini-cli-execution/SKILL.md -a claude-code --skill gemini-cli-execution

Installation paths:

Claude
.claude/skills/gemini-cli-execution/
Powered by add-skill CLI

Instructions

# Gemini CLI Execution

## 🚨 MANDATORY: Invoke gemini-cli-docs First

> **STOP - Before executing ANY Gemini CLI command:**
>
> 1. **INVOKE** `gemini-cli-docs` skill
> 2. **QUERY** for the specific CLI command syntax (e.g., "headless mode", "piping input")
> 3. **BASE** all execution patterns EXCLUSIVELY on official documentation loaded

## Overview

This skill provides the operational knowledge to execute the `gemini` binary effectively within scripts, sub-agents, and automation workflows. It focuses on **non-interactive** usage.

## Command Syntax (v0.18+)

**IMPORTANT**: Gemini CLI uses **positional prompts**, not subcommands.

```bash
# Correct syntax (positional prompt):
gemini "Your prompt here"

# With options:
gemini "Your prompt" --output-format json -m gemini-2.5-flash

# DEPRECATED (will be removed):
gemini -p "Your prompt"  # -p flag is deprecated

# WRONG (no 'query' subcommand exists):
gemini query "Your prompt"  # This does NOT work
```

## When to Use This Skill

**Keywords:** run gemini, execute gemini, gemini cli command, headless gemini, pipe to gemini, automated planning, gemini prompt, interactive shell

**Use this skill when:**

- Invoking Gemini CLI from an agent (e.g., `gemini-planner`)
- Running one-off queries: `gemini "prompt"`
- Piping context: `cat file.js | gemini "refactor this"`
- Using **Interactive Shell** for tools like `vim` or `top`
- Scripting complex workflows involving Gemini

## Execution Patterns

### 1. Single Shot Query (Non-Interactive)

Use positional prompt for direct queries:

```bash
gemini "Create a plan for a React app"

# With JSON output for parsing:
gemini "Create a plan for a React app" --output-format json
```

### 2. Piping Context

Pass file content or logs via stdin:

```bash
cat logs.txt | gemini "Analyze these error logs"

# With model selection:
cat src/*.ts | gemini "Review this code" -m gemini-2.5-flash
```

### 3. JSON Output for Automation

Always use `--output-format json` for scripting:

```bash
re

Validation Details

Front Matter
Required Fields
Valid Name Format
Valid Description
Has Sections
Allowed Tools
Instruction Length:
5346 chars