Agent skill
using-gemini-cli
Run the `gemini` CLI in headless mode for one-off prompts, model-directed Gemini tasks, structured output capture, and follow-up messages against prior Gemini sessions. Use when the user asks to use Gemini CLI, mentions `gemini -p`, wants Gemini in non-interactive mode, wants a `flash` or `pro` Gemini run, needs project-scoped session discovery, or wants to continue an older Gemini session from the terminal instead of the interactive TUI.
Install this agent skill to your Project
npx add-skill https://github.com/shekohex/dotai/tree/main/skills/using-gemini-cli
SKILL.md
Using Gemini CLI
Use gemini through PTY. Prefer headless mode for automation and one-off tasks. Use the interactive TUI only when the user explicitly wants it or when you need the /model picker.
Defaults
- Non-interactive Gemini means
gemini -p "...". - Always run Gemini in PTY so you can read the full output buffer and wait through retries.
- Keep the same
workdirfor-p,--list-sessions, and--resume. Sessions are project-scoped. - Prefer
-o jsonwhen the output will be parsed or resumed later. - Prefer
-o textwhen the user wants the plain answer only. - If stdin is piped, Gemini prepends stdin content and then appends the
-pprompt after it.
Quick Start
One-off text response:
gemini -p "Summarize this repo in 3 bullets" -o text
One-off structured response:
gemini -p "Return JSON with keys name and purpose" -o json
Continue the latest project session:
gemini --resume latest -p "Now make it shorter" -o text
Model Selection
Pass model choice with -m or --model.
Preferred forms:
gemini -m flash -p "..." -o text
gemini -m pro -p "..." -o text
gemini -m flash-lite -p "..." -o text
gemini -m gemini-2.5-flash -p "..." -o text
gemini -m gemini-3.1-pro-preview -p "..." -o text
Use aliases when the user speaks in tiers:
- User says
use flashoruse Gemini flash-> use-m flash - User says
use proorask Gemini pro-> use-m pro - User says
use flash-lite-> use-m flash-lite - User gives an exact model id -> pass it through unchanged with
-m <id>
Observed on Gemini CLI 0.34.0:
-m flashresolved togemini-3-flash-preview-m proresolved togemini-3.1-pro-preview-m gemini-2.5-flashstayed exact
Treat alias resolution as version- and account-dependent. If exact model identity matters, use an explicit model id and prefer -o json so you can confirm the concrete model in stats.models.
How To List Models
There is no dedicated gemini --list-models flag in gemini --help.
Use one of these paths instead:
- Interactive browsing: start
gemini, then run/modelto open the model picker. - Known manual choices: use
flash,pro,flash-lite,auto-gemini-3,auto-gemini-2.5, or an explicit model id. - Verification after a headless run: use
-o jsonand inspectstats.modelsto see which concrete model actually handled the request.
Common Workflows
Fast one-off task:
gemini -p "Explain why this test is flaky" -o text
Frontend fast pass with Flash:
gemini -m flash -p "Review this React component for obvious UX, layout, and accessibility issues. Keep it concise." -o text
Frontend deeper design or architecture pass with Pro:
gemini -m pro -p "Design a responsive landing page architecture for this app. Include component breakdown, spacing system, and interaction notes." -o text
Frontend structured output for automation:
gemini -m pro -p "Return JSON with keys components, design_tokens, and implementation_steps for this dashboard redesign." -o json
Continue an older frontend session:
gemini --list-sessions
gemini --resume latest -m pro -p "Now turn that plan into a Tailwind component checklist." -o text
Resume by exact session id:
gemini --resume 21177875-7869-4ae6-862c-57a138f1cd6d -p "Add edge cases I missed" -o text
Session Workflow
- Start with
gemini -p. - If follow-ups are likely, prefer
-o jsonand capturesession_id. - If the session handle is unknown, run
gemini --list-sessionsin the same project directory. - Resume with
--resume latest,--resume <index>, or--resume <session-uuid>. - Read the full PTY output before concluding; Gemini may print setup noise before the actual answer.
Observed behavior worth relying on:
- Headless
-pruns are persisted as resumable sessions. --list-sessionsshows numeric indexes and UUIDs.--resume latest,--resume <index>, and--resume <uuid>all work for follow-up prompts.
Output Handling
Expect startup noise in PTY output such as cached credential messages, extension loading, MCP warnings, or retry notices. Do not treat the first line as the answer.
When using -o json:
- Read the final JSON object from the PTY buffer.
- Use
responseas the model answer. - Use
session_idfor exact future follow-ups. - Use
stats.modelsto confirm the concrete model that actually ran.
When using -o text:
- The final answer is usually the last meaningful line.
- If the output is ambiguous, confirm with
--list-sessionsor inspect the matching session file under~/.gemini/tmp/<project>/chats/.
Known Pitfalls
- If Gemini complains about saving
~/.gemini/projects.json, ensure~/.gemini/exists before retrying. - Session discovery depends on the current project path. Changing directories can make
latestpoint at a different session set. - Local extensions or MCP servers can add noisy warnings without breaking the actual answer.
- Capacity or quota retries can delay completion; keep reading the PTY until the process exits.
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
write-a-skill
Create new agent skills with proper structure, progressive disclosure, and bundled resources. Use when user wants to create, write, or build a new skill.
memory
Browse and recall OpenCode local memory stored on the user's machine: local sessions, plans, conversations, prompt history, and project context. Use immediately when the user asks to check history, previous sessions, past chats, what did we do before, last time, check plans, session history, recall, memory, remember, prior work, previous context, or have we done this before. Auto-trigger proactively when resuming work, continuing a project, referencing prior decisions, debugging repeated issues, revisiting earlier plans, or any follow-up where earlier OpenCode context may help. This means OpenCode local history/files specifically, not ChatGPT/Claude cloud history, generic web search, or unrelated product memory systems. Do NOT use for fresh tasks with no relevant history, or when current files/git already answer the question.
gsd-oc-select-model
Interactive model selection workflow with paginated navigation. Use when users want to select a model interactively - guides them through provider selection then model selection using the question tool with pagination support for large lists.
brainstorming
Use when creating or developing, before writing code or implementation plans - refines rough ideas into fully-formed designs through collaborative questioning, alternative exploration, and incremental validation. Don't use during clear 'mechanical' processes
test-driven-development
Use when implementing any feature or bugfix, before writing implementation code - write the test first, watch it fail, write minimal code to pass; ensures tests actually verify behavior by requiring failure first
using-superpowers
Use when starting any conversation - establishes mandatory workflows for finding and using skills, including using Skill tool before announcing usage, following brainstorming before coding, and creating TodoWrite todos for checklists
Didn't find tool you were looking for?