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.
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.
> 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.
gemini -p "Write a conventional commit message for this diff:
$(git diff --staged)" > .git/COMMIT_EDITMSGCombine with the tools you have
Because it reads stdin and writes stdout, Gemini slots into normal Unix plumbing.
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
-pflag 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.