Enhance Your Firebase Studio Workflow with Gemini CLI

We recently launched Gemini CLI, which integrates the robust capabilities of Google’s Gemini AI model directly into your command-line interface. We’re excited to announce Gemini CLI is now preinstalled in Firebase Studio! Gemini CLI offers you a powerful tool for a wide range of tasks beyond just code, including content generation and research. It includes generous usage tiers, advanced AI features, integrated Google Search for real-time context, and an open-source architecture for customization and contributions.

Who should use Gemini CLI?

Both Gemini in Firebase and Gemini CLI can perform similar tasks, but we recommend trying out Gemini CLI if you spend a significant amount of time in the terminal for tasks like code generation, debugging, executing commands, or managing project files. Gemini CLI provides a seamless, AI-powered experience without the need to switch contexts to a separate chat window.

Get started in Firebase Studio

To access Gemini CLI in Firebase Studio:

  1. Swap to Code view: If you’re working in Prototyper mode, swap to Code view.
  2. Access the terminal: Click the menu icon > Terminal > New Terminal (Shift+Ctrl/Cmd+C).
  3. Open Gemini CLI: In the terminal, enter the following command:
    gemini
  4. Customize: Pick a color theme by using the arrow keys on your keyboard, then press Enter.
  5. Authenticate: Select an authentication method. For more information about authentication, check out this guide. To receive the free Gemini Code Assist license with an allowance of 60 model requests per minute and 1,000 requests per day at no charge, choose Login with Google.

Gemini CLI is ready to go! In the future, all you need to do is enter gemini in the terminal to access it.

Alternatively, you can run Gemini CLI in non-interactive mode, which is useful for scripting and automation. In this mode, Gemini CLI automatically exits after executing the command you enter. To use this mode, use the --prompt or -p flag. For example: gemini -p "Create a markdown file that explains my app’s architecture"

Customize Gemini CLI

  • Settings: Edit .gemini/settings.json to change the theme, enable or disable the collection of usage statistics, adjust which tools Gemini CLI has access to, configure the checkpointing feature, and much more.
  • Environment variables: Gemini CLI automatically loads environment variables from the .env file, which is where you should store your GEMINI_API_KEY (required). Optionally, you can include which GEMINI_MODEL to use, your GOOGLE_CLOUD_PROJECT, and more.
  • Instructions: To adjust the context that Gemini CLI uses when following instructions, create a GEMINI.md file. This lets you give project-specific instructions, coding style guides, or relevant background information to Gemini, making its responses more tailored and accurate to your needs. You can use GEMINI.md to customize both Gemini CLI and Gemini in Firebase, unless you create a .idx/airules.md file as well (in which case Gemini CLI would use GEMINI.md, and Gemini in Firebase would use airules.md).

For more information and examples on how to adjust the settings, environment variables, and instructions, check out the documentation.

Commands to explore

You can chat with Gemini CLI with questions or requests. You could ask it:

  • explain [file_name.js]: If you encounter unfamiliar code, use this command to request an explanation. Replace [file_name.js] with the relevant file path or paste the code directly into the prompt.
  • refactor [code_snippet]: Enhance your code’s structure or efficiency by prompting Gemini to suggest refactoring improvements.
  • debug "Error: Module not found: 'firebase-admin'": When facing errors, provide the error message to Gemini for insights and potential solutions.
  • summarize "Key features of Firebase Realtime Database": Employ Gemini for rapid research and concise content summarization.

It also supports several built-in commands to help manage your session, customize the interface, and control its behavior, such as:

  • /help: View a comprehensive list of available commands and options, which serves as an excellent starting point for exploration.
  • /chat: Save and resume conversation history in order to create branching conversations, or resume a previous state from a later session.
  • /tools: Display a list of tools that are currently available within Gemini CLI.
  • /restore: Restore project files to the state they were in just before a tool was executed. This is particularly useful for undoing file edits made by a tool.

For a full list of commands, check out the documentation.

Try it out!

Integrating Gemini CLI into your Firebase Studio workflow provides an intelligent assistant directly within your development environment. Check it out and let us know if it speeds up your workflow!