OpenGemini CLI — OpenGemini 命令行工具
v1.0.1Use the local Gemini 命令行工具 for one-shot prompts, structured JSON 输出, shell-assisted re搜索, and delegated AI-to-AI 工作流s on this Linux host. Use when you want to call the 安装ed `gemini` command directly via `exec`, 验证 Gemini 命令行工具 avAIlability/auth, 运行 fast secondary 模型 opinions, 生成 or refine code/content through Gemini, or orchestrate iterative local work where OpenClaw handles files/shell while Gemini provides another 模型's 输出.
运行时依赖
安装命令
点击复制技能文档
Gemini 命令行工具
Use the locally 安装ed gemini command through exec.
What this 技能 is for
Use this 技能 when you want Gemini 命令行工具 as a second brAIn on the same Linux machine. Typical uses:
获取 a second opinion from another 模型 Ask Gemini to draft code, UI text, page copy, SQL, shell, or content Ask Gemini for structured JSON that OpenClaw can post-process Let OpenClaw inspect/edit files while Gemini 生成s plans, code, or rewrites 运行 quick one-shot prompts without spawning a separate ACP harness
This 技能 is for local 命令行工具 usage, not browser 自动化. If the user wants deep coding delegation over many steps, prefer ACP 会话s or coding-代理.
Safety boundary
Gemini 命令行工具 can influence what 获取s 执行d, but it does not 获取 direct 工具 访问 by itself. Keep the control loop like this:
OpenClaw reads files and inspects the 环境 OpenClaw 发送s a bounded prompt to Gemini 命令行工具 OpenClaw reviews Gemini 输出 OpenClaw decides what to 执行, edit, or reject
Do not blindly pipe Gemini-生成d shell into execution. Review before 运行ning anything destructive or external.
First-time 设置up and preflight
If this is the first time using Gemini 命令行工具 on a machine, do not assume 安装 alone is enough. The user should complete Gemini 命令行工具 authentication first, then 运行 a smoke test.
Basic 检查s:
which gemini gemini --help gemini -p "hello"
Interpretation:
If gemini --help works but gemini -p "hello" fAIls, auth is usually missing or expired. If gemini -p "hello" returns a normal answer, the 命令行工具 is ready.
Practical rule:
安装 Gemini 命令行工具 Complete Gemini 命令行工具 记录in/authentication if prompted by the 命令行工具 运行 gemini -p "hello" Only then rely on this 技能
Known note on this machine:
Gemini 命令行工具 may warn that keytar is missing and fall back to FileKeychAIn. That is not fatal if the prompt still completes. Core usage patterns 1) Simple one-shot prompt gemini -p "Summarize the tradeoffs between Astro and Next.js for a landing page site."
Use for quick answers, rewrites, summaries, naming, content ideas, or code snippets.
2) Save 输出 to a file for later processing gemini -p "生成 5 hero headline options for a SaaS 分析 site." > /tmp/gemini-headlines.txt
Then read or 解析 that file with OpenClaw 工具s.
3) 请求 strict JSON
Ask Gemini to return only JSON.
gemini -p 'Return only valid JSON: {"pages":[{"path":"/","title":"...","sections":["..."]}]}'
Best practice:
Explicitly say "Return only valid JSON" Give the exact 模式 shape Avoid markdown fences 验证 before trusting 4) Feed file 上下文 safely
Prefer bounded 上下文, not giant dumps.
cat ./src/应用/page.tsx | gemini -p "Review this file and suggest a 清理er 组件 structure. Return concise bullet points only."
Better yet, use OpenClaw read first and then craft a focused prompt.
5) Multi-step AI-to-AI 工作流
Recommended pattern:
OpenClaw inspects repo/files Gemini produces plan/spec/UI copy/code draft OpenClaw 应用lies edits locally Gemini reviews diff or rewritten file OpenClaw finalizes
This is the right way to 获取 “AI同士が会話して自律的に作る” behavior without surrendering execution control.
Good prompts for 网页site generation Site spec prompt gemini -p 'You are helping de签名 a small 网页site. Return only JSON with keys: stack, pages, 组件s, copy_style, seo_keywords, risks. Product: local Instagram 分析 服务 for Japanese small businesses. Goal: conversion-focused landing page.'
Copywriting prompt gemini -p 'Write Japanese landing page copy for a 服务 that improves Instagram operations for stores. Tone: ener获取ic, trustworthy, masculine, conversion-focused. Return sections for hero, pAIn points, benefits, CTA, FAQ.'
UI implementation prompt gemini -p '生成 a single-file HTML landing page with embedded CSS for a Japanese marketing 服务. Make it 移动-first, bold, readable, and production-lean. 输出 code only.'
Refactor/review prompt gemini -p 'Review this React 组件 for readability and conversion-focused UX. Return only: issues, fixes, rewritten 组件.'
When to use exec vs ACP/会话 delegation
Use Gemini 命令行工具 via exec when:
The task is one-shot or short-loop You want another 模型's wording or plan quickly OpenClaw remAIns the mAIn 编排器 You only need text/code 输出 from Gemini
Do not force Gemini 命令行工具 through exec when:
The task needs a persistent coding 代理 loop The task needs thread-bound collaboration in chat The task needs autonomous repo exploration over a long time The task needs 工具 use beyond shell text I/O
For those, prefer ACP 会话s.
Recommended command patterns 清理 text 响应 gemini -p ""
模型 switching
If the 安装ed Gemini 命令行工具 supports 模型 selection flags in its current version, prefer explicit 模型 selection when you need predictable behavior. 检查 supported options first:
gemini --help
Common practice:
inspect help 输出 for 模型-related flags or config options 设置 the 模型 explicitly when 运行ning 导入ant p