Introducing a Structured Workflow for Gemini CLI: Safer, More Disciplined, and Surprisingly Capable #12992
mystilleef
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
tldr: After one too many unfortunate events, I wanted to implement a poor man's
READONLY,PLAN, andBUILDmodes forgemini-cli. Let's hope native solutions find their way intogemini-clibefore long.https://github.com/mystilleef/gemini-cli-modes
Why
Like many of you, I sometimes found myself frustrated by the agent's occasional eagerness to modify files or even delete them without explicit, granular permission. This led me to develop a set of custom commands and a structured workflow to bring more discipline and safety to the agent's operations.
The Problem:
Unintended modifications and a lack of clear operational boundaries.
The Solution:
A mode-based workflow that enforces explicit permissions and guides the agent through the
Perceive,Reason,Act, andRefine(PRAR) phases of software engineering.The commands
/readonlyforces the agent into readonly mode by creating a marker/exploreis used to explore ideas, implement features, fix bugs, and draft specifications/planis used to write a detailed plan to implement the ideas/reviewuses different expert perspectives to review the plan/implementdisables readonly mode, then uses a task/todo list to implement the plan/builda token-efficient form of/implement/writeableused to disable readonly modeThe
readonly,explore,plan, andreviewalways lock the agent inreadonlymode.The remaining commands disable
readonlymode.The
explorecommand is the only command that takes an argument, your query.How it Works (in a Nutshell):
The core idea revolves around a
.gemini_readonlymarker file and custom commands that force the agent into specific operational "modes":/readonly), preventing any modifications until explicitly allowed./exploreand/plankeep the agent in read-only states, allowing it to investigate the codebase, understand problems, and formulate detailed strategies without touching any files./reviewcommand enables the agent to critically self-assess its plans before execution./implementor/build. These modes remove the read-only lock and allow the agent to execute changes under strict protocols./writableoffers a direct way to enable write operations without the full PRAR cycle.Workflows
Full PRAR cycle (token-intensive):
In this workflow
planandrevieware optional. Use them to increase your chances of one-shotting tasks at the expense of consuming more tokens.Read-build cycle
This workflow uses significantly less tokens, and is what I use for the vast majority of tasks.
Read-write cycle
I use this to get out of readonly mode (e.g if I want to use a custom command).
The Benefits I've Seen:
Beyond the obvious safety improvements (no more accidental file deletions!), this structured approach has had some surprising positive side effects:
PRARworkflow, flash is no longer useless for complex tasks.Disclaimer:
While incredibly powerful, the more structured workflows (especially the full PRAR cycle) can be more token-intensive due to the detailed planning and review steps. However, the trade-off for safety, discipline, and improved results has been well worth it for me.
Credits:
I can't take credit for any of these ideas. These ideas have been floating around discussion boards and forums, and are already in use by other
CLIagents in one form or another. I just wanted a cohesive workflow forGeminiProject:
The
githubproject has details on how to setup the commands and update yoursettings.jsonto use these modes. I welcome your feedback.https://github.com/mystilleef/gemini-cli-modes
Beta Was this translation helpful? Give feedback.
All reactions