← All articles
AI Tools1 min read

Gemini CLI in Action: Example Workflows

With the Gemini CLI set up, here are three real workflows — exploring a repo, generating code with a scoped prompt, and piping it into scripts.

S

Swapnika Voora

Author

The Gemini CLI is at its best when it can see your whole project. After setup, you can explore code, generate changes, and even fold it into shell pipelines. Here are the workflows worth learning first.

Explore a codebase

Open the CLI in your repo and ask about the code. Gemini reads files as needed and can pull in large context.

explore.sh
cd my-service
gemini
> Trace how a request to /api/orders flows from controller to database.

Generate with a focused prompt

Be explicit about scope and constraints so the generated change stays tight.

prompt
> Add a Caffeine cache to ProductService.findById with a 10-minute TTL.
> Update only ProductService and CacheConfig, and keep existing tests passing.

Gemini shows its plan and proposed edits; you approve them before they're written to disk.

Use it non-interactively

Pass a prompt as an argument to run one shot and exit — handy inside scripts and CI.

commit-msg.sh
gemini -p "Write a conventional commit message for this diff:
$(git diff --staged)" > .git/COMMIT_EDITMSG

Combine with the tools you have

Because it reads stdin and writes stdout, Gemini slots into normal Unix plumbing.

explain.sh
kubectl logs my-pod | gemini -p "Summarize the errors in these logs."

Takeaways

  • Interactive mode is ideal for exploring and iterating on changes.
  • Name the files and constraints so generated edits stay scoped.
  • The -p flag plus stdin/stdout makes Gemini composable in scripts.

As always, run it against a clean git tree and review every diff — the agent is a fast collaborator, not a substitute for reviewing your own commits.

#gemini#google#cli#example

More in AI Tools