Unlock the Power of Gemini CLI: Commands and Settings Guide
The Gemini Command Line Interface (CLI) offers a rich set of built-in commands that streamline your workflow and allow for deep customization. This guide will walk you through understanding and utilizing these commands, from basic chat management to fine-tuning your CLI experience through settings.
What You’ll Learn
In this tutorial, you will discover how to:
- Identify and execute built-in Gemini CLI commands.
- Manage chat sessions, including saving, listing, and resuming conversations.
- Utilize helpful commands like `help`, `docs`, `copy`, and `clear`.
- Understand and modify the CLI’s behavior using global and workspace settings.
- Explore advanced features like managing directories and refreshing agent memory.
Understanding Gemini CLI Commands
In Gemini CLI, as with other agentic CLI tools, commands are identified by a forward slash (/) prefix. Typing a single forward slash into the chat input will reveal a comprehensive list of all available built-in commands, each with a brief description.
Accessing the Command List
To see all available commands, simply type
/into the chat input and press Enter. You can navigate through the list using the up and down arrow keys.Running a Command
Once you’ve selected a command (e.g., by navigating to it and pressing Enter), it will be inserted into the chat input. To execute the command, you need to press Enter again.
Key Built-in Commands and Their Uses
1. The help Command
The help command provides hints, information, and details about other commands and shortcuts. Execute it by typing /help and pressing Enter twice.
2. Managing Chat Sessions with the chat Command
The chat command is your tool for managing conversations with Gemini.
Viewing Subcommands
Type
/chatand press Enter to see a list of subcommands such aslist,save,resume,delete, andshare.Listing Saved Conversations
To see your saved chat sessions, select the
listsubcommand: type/chat listand press Enter.Saving the Current Conversation
To save your current chat session, you need to provide a name (a “tag”).
- Type
/chat save. - Add a descriptive tag, for example:
initial project setup. The full command would look like/chat save initial project setup. - Press Enter twice to execute. This saves the conversation at its current point, allowing you to resume later.
Expert Note: The
savecommand requires a tag. Without it, you’ll receive an error indicating a missing argument.- Type
Resuming a Conversation
To resume a previously saved conversation, you would use the
resumesubcommand followed by the tag you used when saving it (e.g.,/chat resume initial project setup).
3. Other Useful Commands
/orth: Used for changing authentication methods. This will be relevant when setting up API tokens./bug: Report bugs directly within the CLI./clear: Clears the entire chat history for the current session./copy: Copies the most recent model output to your system clipboard./docs: Opens the Gemini CLI documentation in your default web browser./directory: Manages workspace directories. You can add directories to your project, allowing Gemini to analyze and work within multiple project folders simultaneously./quit: Exits the current Gemini CLI session./model: Allows you to switch between different AI models. The default isauto, which selects the best model for the task. (Note: Gemini 3 might require an API key if not yet rolled out to your account.)/stats: Displays current model and tool usage statistics, including API requests and token consumption./theme: Change the visual color theme of the Gemini CLI. Navigate the options and press Enter to select. Press Esc to exit the theme selection.
4. Managing Agent Memory with the memory Command
The memory command allows you to influence what the Gemini agent remembers.
Refreshing Memory
Use the
refreshsubcommand (/memory refresh) to make the agent rescan for new Gemini configuration files (.mdfiles) in your project and global configuration directories.Adding Global Instructions
You can add instructions that apply across all your projects.
- Type
/memory addfollowed by your instruction. For example:/memory add I prefer using shard CN as a UI component library where possible. - Press Enter. This instruction is saved to your global
.gemini/config.jsonfile, affecting all future sessions.
Warning: Changes made via
/memory addusing the global scope affect all your projects. Be mindful of the scope when adding instructions.- Type
Listing Memory Files
To see which configuration files are currently being used for memory, use the
listsubcommand:/memory list.Showing Combined Instructions
The
showsubcommand (/memory show) displays all instructions aggregated from the currently active configuration files.
Customizing Gemini CLI with Settings
The settings command allows you to fine-tune various aspects of the Gemini CLI’s behavior.
Accessing and Modifying Settings
Opening the Settings Menu
Type
/settingsand press Enter. This opens a menu with numerous options you can toggle.Understanding Setting Scopes
At the bottom of the settings menu, you’ll see options to apply changes to different scopes:
- User Settings (Global): These are stored in
~/.gemini/settings.jsonand apply to all your Gemini CLI sessions across all projects. - Workspace Settings (Local): These apply only to the current project.
- User Settings (Global): These are stored in
Changing the Scope
To switch between scopes, use the Tab key. Focus will move to the scope selection menu. Navigate with arrow keys and press Enter to select.
Toggling Settings
Navigate to the desired setting in the top menu (e.g.,
hide bannerorshow model info in chat) and press Enter to toggle its value (e.g., betweentrueandfalse).
Example: Setting Workspace-Specific Options
Ensure your scope is set to Workspace Settings (use Tab to switch if necessary).
Navigate to the
show model info in chatsetting.Press Enter to toggle it to
true.
When you apply a setting to the workspace scope, Gemini CLI automatically creates a .gemini folder in your project’s root directory and adds a settings.json file within it. This file will only contain the settings that differ from their default values. This ensures that your project-specific configurations do not interfere with your global preferences.
Understanding Setting Cascading
Settings are applied in a hierarchical manner. Global settings form the base, and workspace settings can override them. If a setting is configured both globally and locally, the local (workspace) setting takes precedence. You can also manually edit these settings.json files to add or modify settings.
Exiting Command Menus
To exit most command menus or selections and return to the standard chat input, press the Esc key.
By mastering these commands and settings, you can significantly enhance your productivity and tailor the Gemini CLI to your specific development needs.
Source: Gemini CLI Tutorial #4 – Commands & Settings (YouTube)