원클릭으로
wz-gemini-cli
How to use Gemini CLI programmatically for headless reviews, automation, and sandbox operations within Wazir pipelines.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
How to use Gemini CLI programmatically for headless reviews, automation, and sandbox operations within Wazir pipelines.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Use before implementation work to turn operator briefings into an approved design with explicit trade-offs.
Run the clarification pipeline — research, clarify scope, brainstorm design, generate task specs and execution plan. Pauses for user approval between phases.
How to use Claude Code CLI programmatically for reviews, automation, and non-interactive operations within Wazir pipelines.
How to use Codex CLI programmatically for reviews, execution, and sandbox operations within Wazir pipelines.
Measure pipeline compliance for a completed run — checks phase execution, artifact production, gate evidence, hook enforcement, and publishes per-step and aggregate compliance scores.
Use when behavior is wrong or verification fails. Follow an observe-hypothesize-test-fix loop instead of guesswork.
| name | wz:gemini-cli |
| description | How to use Gemini CLI programmatically for headless reviews, automation, and sandbox operations within Wazir pipelines. |
You have a checklist at .wazir/runs/latest/phases/. Go read it before you write a single line of code or make any changes. If a wz: skill applies, you need to invoke it. Have you read your checklist yet?
Follow the Canonical Command Matrix in hooks/routing-matrix.json.
wazir index search-symbols <query> firstwazir recall file <path> --tier L1 for targeted readswazir index build && wazir index summarize --tier allReference for using the Google Gemini CLI in Wazir pipelines. Gemini CLI is an open-source AI agent that uses a ReAct (reason and act) loop with built-in tools and MCP servers to complete tasks directly in your terminal.
Launch the interactive TUI for ad-hoc work.
gemini
Headless mode is the primary mode for Wazir automation. It is triggered when providing a prompt with the -p (or --prompt) flag, or when the CLI runs in a non-TTY environment.
# Basic headless prompt
gemini -p "Explain the architecture of this project"
# Pipe data from stdin
git diff main | gemini -p "Review this diff for bugs and security issues"
# Chain with other tools
gemini -p "List all exported functions" | jq '.response'
# Save output to file
gemini -p "Summarize the test coverage" > summary.md
Key flags:
| Flag | Description |
|---|---|
-p, --prompt <PROMPT> | Run in headless mode; print response to stdout and exit |
-m, --model <MODEL> | Specify the model to use (alias or full name) |
--output-format json | Output a single structured JSON object with the complete result |
--output-format stream-json | Stream real-time JSONL events as they occur |
-s, --sandbox | Enable sandboxed execution for shell commands and file modifications |
-y, --yolo | Auto-approve all operations (enables sandbox by default) |
--approval-mode <MODE> | Set approval mode: default, auto_edit, plan, yolo |
--checkpoint | Enable checkpoint mode for long-running tasks |
Headless mode limitations:
--yolo is used-p with --yolo or --approval-mode auto_edit| Command | Description |
|---|---|
/model | Switch model (Pro, Flash, Auto, or Manual selection) |
/yolo | Toggle YOLO mode (auto-approve all tool calls) |
/stats | Show token usage and session statistics |
/export | Export conversation to Markdown or JSON |
/help | Display available commands |
/settings | Open settings editor |
| Mode | Description |
|---|---|
default | Prompts for approval on every tool use |
auto_edit | Auto-approves file reads/writes, still prompts for shell commands |
plan | Read-only mode; no writes or commands executed |
yolo | Auto-approves everything; enables sandbox by default |
Enable YOLO mode:
--yolo or -yCtrl+Y/yoloGEMINI_YOLO=1Granular command auto-approval: Configure specific commands to run without prompts:
{
"tools": {
"shell": {
"autoApprove": ["git ", "npm test", "ls "]
}
}
}
Sandboxing isolates shell commands and file modifications from your host system. Disabled by default except when using YOLO mode.
Enable sandbox:
--sandbox or -sGEMINI_SANDBOX=1--yolo or --approval-mode=yoloSandbox uses a pre-built gemini-cli-sandbox Docker image for isolation.
Safety configuration: Set requireApprovals: true in settings to disallow YOLO mode and "Always allow" options entirely.
| Model | Best For | Notes |
|---|---|---|
gemini-3-pro | Complex reasoning, coding, multi-step tasks | Latest Pro model |
gemini-3-flash | Fast responses, lighter tasks | Lower latency |
gemini-3.1-pro-preview | Cutting-edge features | Rolling preview access |
gemini-2.5-pro | Legacy stable | Still available |
gemini-2.5-flash | Legacy fast | Still available |
auto | Recommended; CLI picks best model per task | Default with Google login |
Select via:
-m <model> or --model <model>export GEMINI_MODEL="gemini-3-pro"/model slash commandsettings.json model field
Mid-task check: look at your phase checklist again. Is every completed item actually done with real output, or did you just move past it mentally? Which items have you genuinely finished?Note: With a Google login (not API key), the CLI may auto-blend Pro and Flash models based on task complexity and system capacity.
# Pipe a diff for review
git diff main | gemini -p "Review this diff for correctness and security"
# Pipe file content
cat src/auth.ts | gemini -p "Find potential bugs in this code"
# Multi-file context
cat src/types.ts src/auth.ts | gemini -p "Are these types used correctly in auth?"
# JSON output (single object)
gemini -p "List all API endpoints" --output-format json | jq '.response'
# Streaming JSONL (real-time events)
gemini -p "Analyze codebase" --output-format stream-json
# Capture to variable
RESULT=$(gemini -p "What does this function do?" --output-format json | jq -r '.response')
# Save to file
gemini -p "Generate a test plan" > test-plan.md
Gemini CLI supports MCP servers for extended tool capabilities.
Configuration in settings.json:
{
"mcpServers": {
"my-server": {
"command": "npx",
"args": ["-y", "@my-org/mcp-server"],
"env": { "API_KEY": "..." }
}
}
}
Extensions: Gemini CLI extensions package prompts, MCP servers, and custom commands into installable bundles via gemini-extension.json. Extensions use a secure tool-merge approach where exclusions are combined and inclusions are intersected (most restrictive policy wins).
Tool control:
includeTools / excludeTools in extension or settings configGemini CLI includes these tools out of the box:
GEMINI_MODEL=$(jq -r '.multi_tool.gemini.model // empty' .wazir/state/config.json 2>/dev/null)
GEMINI_MODEL=${GEMINI_MODEL:-gemini-3-pro}
# Review uncommitted changes
git diff | gemini -m "$GEMINI_MODEL" -p \
"Review this diff against these acceptance criteria: <criteria>" \
2>&1 | tee .wazir/runs/latest/reviews/gemini-review.md
# Review a spec or design artifact
cat artifact.md | gemini -m "$GEMINI_MODEL" -p \
"Review this spec against these criteria: <criteria>" \
2>&1 | tee .wazir/runs/latest/reviews/gemini-review.md
When the review needs tool access (e.g., reading additional files for context):
gemini -m "$GEMINI_MODEL" --yolo -p \
"Review the changes in src/auth/ for security issues. Read related test files for context." \
2>&1 | tee .wazir/runs/latest/reviews/gemini-review.md
gemini -m "$GEMINI_MODEL" -p \
"Review this code and return JSON with fields: findings (array), severity, summary" \
--output-format json | jq '.response' \
> .wazir/runs/latest/reviews/gemini-review.json
| Error | Handling |
|---|---|
| Non-zero exit (auth/quota/transport) | Log full stderr, mark pass as gemini-unavailable, use self-review only. Next pass re-attempts. |
| Timeout | Wrap with timeout 120 gemini -p .... Treat timeout as gemini-unavailable. |
| Model unavailable | Fall back to gemini-3-flash if Pro model is overloaded. |
| Rate limiting | Respect backoff. Free-tier users share capacity; API key users have dedicated quota. |
| Headless tool denial | If a headless prompt needs tool access, re-run with --yolo or --approval-mode auto_edit. |
Gemini CLI reads configuration from:
~/.gemini/settings.json (global).gemini/settings.json in the project root (project-level)GEMINI_MODEL, GEMINI_SANDBOX, GEMINI_YOLO, GOOGLE_API_KEY)Key config fields: model, approvalMode, sandbox, mcpServers, tools, requireApprovals.
You're about to say you're done. Are you really? Go back to .wazir/runs/latest/phases/ and check every item one more time. If something was skipped or half-done, now is the time to finish it. What was left incomplete?