Editor’s Note: This new feature was made possible by Christopher Beeson, an outstanding open source contributor in the Gemini CLI community. His meticulous work across nine-plus well-crafted pull requests were instrumental in bringing this to fruition.
Context is everything when working with Gemini CLI. Whether you are refactoring a complex codebase or debugging a tricky error, your conversation history contains valuable reasoning, tool outputs, and decisions.
Previously, closing your terminal meant losing that context. Starting over required re-explaining the problem to the model. This is no longer the case, Gemini CLI now automatically saves your sessions and lets you search through your session history to resume right where you left off!
Every time you interact with Gemini CLI, your session is now automatically saved in the background. You don't need to remember to save or export your chat; we handle it for you with our new Session Management system.
We capture the complete state of your work, including:
Crucially, these sessions are project-specific. If you switch directories to a different project, Gemini CLI automatically switches context to that project's session history, ensuring Gemini CLI is always on the same page as you.
We have made it incredibly easy to jump back into a previous workflow, whether you prefer command-line flags or our interactive UI.
Within Gemini CLI, you can simply type /resume to open the new Session Browser.
This interactive interface allows you to:
For those who prefer flags, you can resume sessions right from the start when you launch Gemini CLI.
You can list all available sessions for your current project as well:
gemini --list-sessions
Output example:
Available sessions for this project (3):
1. Fix bug in auth (2 days ago) [a1b2c3d4]
2. Refactor database schema (5 hours ago) [e5f67890]
3. Update documentation (Just now) [abcd1234]
With great power comes great responsibility… or in this case, a lot of history files! We’ve added the tools to help you keep your environment clean.
To prevent your history from growing indefinitely, you can enable automatic cleanup policies in your settings.json configuration file.
{
"general": {
"sessionRetention": {
"enabled": true,
"maxAge": "30d", // Keep sessions for 30 days
"maxCount": 50 // Keep the 50 most recent sessions
}
}
}
With detailed message, thought, tool call, and token usage information being recorded automatically, you can now analyze your Gemini CLI usage. You can use community developed tools like Splitrail, or develop your own!
Session management is available in Gemini CLI and on by default as of v0.20.0+.
All you need to do is update to make sure you can take advantage of the new feature:
npm install -g @google/gemini-cli@latest
Make sure to check out our official documentation on session management for further details.
You can also follow Gemini CLI on X to stay up to date with the latest news and announcements.