Skip to content
Agents tracked: 258 Downloads (7d): 219M up 6.1% GitHub stars: 5.5M VS Code installs: 148M Releases (7d): 293 Agent pull requests (last week): 937K Updated Oct 7, 2026
Recipe

Script Gemini CLI in your terminal: explain logs, write commits, document files

Gemini CLI's headless mode takes piped input and returns plain text or JSON. That makes it usable inside shell scripts, aliases and CI jobs.

The problem

Copying logs and diffs into a chat window is slow and can't be repeated reliably. Calling the agent as a normal Unix command lets you automate log explanations, commit messages and batch documentation.

Steps

  1. Install and sign in to Gemini CLI.
  2. Run one-off prompts with the -p flag, so no interactive session opens.
  3. Pipe in context, such as an error log or the output of git diff.
  4. Add --output-format json and parse .response with jq when another tool needs the result.
  5. Loop over files in a script, or wrap a diff-to-commit prompt in a shell alias.

From the official docs

cat error.log | gemini -p "Explain why this failed"
git diff | gemini -p "Write a commit message for these changes"

Results

  • Explanations of failures from piped logs, and commit messages generated from staged diffs.
  • Batch Markdown documentation for a folder of Python scripts.
  • Exit codes your scripts can check, such as 53 when the turn limit is exceeded.

As reported by the source (Gemini CLI docs); AgentGid did not measure these figures.

Takeaway. Treat the agent as one more Unix command and pipe context into it.
AgentGid's take

Suits anyone comfortable with shell scripting, pipes and jq, from solo developers to CI owners. The thing to watch is billing: AgentGid's data shows Gemini CLI's free individual tier ended on 2026-06-18, so scripted loops now run on pay-as-you-go API keys or a paid license. Pi is free and MIT-licensed (Free (OSS)), though you still pay your model provider.

The agent used here

Similar use cases

Guides