Lab setup instructions and requirements
Protect your account and progress. Always use a private browser window and lab credentials to run this lab.

Accelerate Tasks with Gemini CLI

Lab 1 година 30 годин universal_currency_alt 5 кредитів show_chart Початковий
info This lab may incorporate AI tools to support your learning.
This content is not yet optimized for mobile devices.
For the best experience, please visit us on a desktop computer using a link sent by email.

Overview

Gemini CLI is a free, open-source AI agent that lets you use Gemini from your command line. It integrates with your existing tools to help you tackle tough tasks like fixing bugs, creating new features, and writing better tests. Although it's excellent for programming, you can also use it as a versatile local assistant for everyday tasks like generating content, solving problems, doing research, or managing your to-do list.

Objective

This lab provides an introductory, hands-on experience with Gemini CLI.

You learn how to:

  • Install and run Gemini CLI.
  • Use Gemini CLI to explain code.
  • Configure Gemini CLI and provide context to help you get responses that are tailored to your needs.
  • Create a custom slash command to reuse a prompt.
  • Use Gemini CLI tools to safely make changes to your local filesystem.
  • Build and modify an app with Gemini CLI.

Setup and requirements

Before you click the Start Lab button

Note: Read these instructions.

Labs are timed and you cannot pause them. The timer, which starts when you click Start Lab, shows how long Google Cloud resources will be made available to you.

This Google Skills hands-on lab lets you do the lab activities yourself in a real cloud environment, not in a simulation or demo environment. It does so by giving you new, temporary credentials that you use to sign in and access Google Cloud for the duration of the lab.

What you need

To complete this lab, you need:

  • Access to a standard internet browser (Chrome browser recommended).
  • Time to complete the lab.
Note: If you already have your own personal Google Cloud account or project, do not use it for this lab. Note: If you are using a Pixelbook, open an Incognito window to run this lab.

How to start your lab and sign in to the Console

  1. Click the Start Lab button. If you need to pay for the lab, a pop-up opens for you to select your payment method. On the left is a panel populated with the temporary credentials that you must use for this lab.

    Credentials panel

  2. Copy the username, and then click Open Google Console. The lab spins up resources, and then opens another tab that shows the Choose an account page.

    Note: Open the tabs in separate windows, side-by-side.
  3. On the Choose an account page, click Use Another Account. The Sign in page opens.

    Choose an account dialog box with Use Another Account option highlighted

  4. Paste the username that you copied from the Connection Details panel. Then copy and paste the password.

Note: You must use the credentials from the Connection Details panel. Do not use your Google Skills credentials. If you have your own Google Cloud account, do not use it for this lab (avoids incurring charges).
  1. Click through the subsequent pages:
  • Accept the terms and conditions.
  • Do not add recovery options or two-factor authentication (because this is a temporary account).
  • Do not sign up for free trials.

After a few moments, the Cloud console opens in this tab.

Note: You can view the menu with a list of Google Cloud Products and Services by clicking the Navigation menu at the top-left. Cloud Console Menu

Activate Google Cloud Shell

Google Cloud Shell is a virtual machine that is loaded with development tools. It offers a persistent 5GB home directory and runs on the Google Cloud.

Google Cloud Shell provides command-line access to your Google Cloud resources.

  1. In Cloud console, on the top right toolbar, click the Open Cloud Shell button.

    Highlighted Cloud Shell icon

  2. Click Continue.

It takes a few moments to provision and connect to the environment. When you are connected, you are already authenticated, and the project is set to your PROJECT_ID. For example:

Project ID highlighted in the Cloud Shell Terminal

gcloud is the command-line tool for Google Cloud. It comes pre-installed on Cloud Shell and supports tab-completion.

  • You can list the active account name with this command:
gcloud auth list

Output:

Credentialed accounts: - @.com (active)

Example output:

Credentialed accounts: - google1623327_student@qwiklabs.net
  • You can list the project ID with this command:
gcloud config list project

Output:

[core] project =

Example output:

[core] project = qwiklabs-gcp-44776a13dea667a6 Note: Full documentation of gcloud is available in the gcloud CLI overview guide .

Task 1. Install and run Gemini CLI

In this task, you install and run Gemini CLI.

Try Gemini CLI in Cloud Shell

Gemini CLI is available in Cloud Shell, with no additional configuration required.

  1. To start Gemini CLI, in Cloud Shell, run the following command:

    gemini

    A version of Gemini CLI is already installed in Cloud Shell.

    Gemini CLI in Cloud Shell

    When you first run it, Gemini CLI may automatically update the version to the latest stable version.

  2. If prompted with Do you trust this folder?, press the down arrow to highlight Trust folder, then press Enter or (Return) to confirm.

  3. If you are asked how to authenticate for this project, use the down arrow to select Use Cloud Shell user credentials, and then press Enter or Return.

  4. To see the available commands, in the Gemini CLI, run the following command, and then press Enter or Return:

    /help

    Commands in Gemini CLI that start with a slash ('/') are called slash commands. To run a slash command, you must press Enter or Return.

    /help provides a list of the commands that you can send to Gemini CLI. It also shows how you can run shell commands or provide files for context.

    Gemini CLI needs to be authenticated to communicate with Gemini.

  5. To see the current authentication method, run the following slash command:

    /auth

    The current authentication method is to use the Cloud Shell user credentials. Gemini CLI automatically uses the credentials of the logged-in user.

  6. To exit the auth dialog, press the ESC (escape) key.

  7. To exit Gemini CLI, run the following slash command:

    /quit

Install Gemini CLI in a VM terminal

This time, you log into a VM and install Gemini CLI on the VM's command line. A VM named has already been created for you.

  1. In Cloud Shell, open an SSH connection to the VM:

    gcloud compute ssh {{{project_0.startup_script.vm_name | VM_NAME}}} --zone={{{project_0.default_zone | ZONE}}}
  2. If necessary, press Enter or Return to specify the default value for each input.

    Your Cloud Shell session is now running inside the VM.

  3. Run the following command:

    gemini

    Gemini CLI is not installed by default on the VM, so the command is not found.

    There are multiple ways to run Gemini CLI:

    • You can run from a standard installation, using npm to install globally, or use npx to execute a version from NPM without a global install.
    • You can run Gemini CLI in a sandbox, with Gemini CLI running inside a container.
    • You can clone the repository and run from source code, which is useful if you want to contribute to the Gemini CLI codebase.
    • You can use npx to run the latest commit from the GitHub repo.

    To use npm or npx, you need to install Node.js. To control the version of Node.js that is used, you may also install nvm.

  4. To install nvm, run the following commands:

    curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash source ~/.bashrc

    The install script installs nvm and adds required settings to the .bashrc file. Sourcing the .bashrc file adds those settings to the current shell session.

  5. To use nvm to install the latest stable version of Node, run the following command:

    nvm install node

    The Node install also installs npm.

    Now that the latest stable version of Node and npm is installed, you can install Gemini CLI.

  6. To install Gemini CLI, run the following command:

    npm install -g @google/gemini-cli@0.9.0

Run the installed Gemini CLI

When Gemini CLI runs for the first time, it shows the options for authentication. The Cloud Shell user credentials option is no longer available, because we are running on the command line within the VM.

The GEMINI_API_KEY environment variable can be used to run Gemini with an API key from Google AI Studio.

To login with a Google account, you must specify the project you are using by supplying a GOOGLE_CLOUD_PROJECT environment variable, and Gemini CLI will ask you to log in.

To use Vertex AI, you can obtain a Google Cloud API key and pass it in an environment variable named GOOGLE_API_KEY, or use application default credentials in place of the API key and export the GOOGLE_CLOUD_PROJECT and GOOGLE_CLOUD_LOCATION environment variables.

  1. To run Gemini CLI in a project directory using Vertex AI, run the following commands:

    export GOOGLE_CLOUD_PROJECT={{{project_0.project_id | PROJECT_ID}}} export GOOGLE_CLOUD_LOCATION={{{project_0.default_region | REGION}}} export GEMINI_MODEL=gemini-2.5-flash echo "export GOOGLE_CLOUD_PROJECT={{{project_0.project_id | PROJECT_ID}}}" >> ~/.bashrc echo "export GOOGLE_CLOUD_LOCATION={{{project_0.default_region | REGION}}}" >> ~/.bashrc echo "export GEMINI_MODEL=gemini-2.5-flash" >> ~/.bashrc mkdir ~/project1 cd ~/project1 gemini

    These commands do the following:

    • Export the variables required to log in with Vertex AI.
    • Export the variable that sets the model that is used by Gemini.
    • Add these export statements to the .bashrc file so the variables are automatically exported when logging into the VM.
    • Make a project-specific directory in which Gemini can be run.
    • Run Gemini.

    Gemini asks you to choose your authentication method.

  2. Select Vertex AI, and then press Enter or Return.

    The required environment variables were provided, so you are now authenticated with Gemini CLI.

  3. To modify Gemini CLI settings, run the following slash command:

    /settings

    User settings are displayed.

  4. Use the down arrow key to scroll to the Disable Auto Update setting, and press Enter or Return.

    The Disable Auto Update setting is set to true.

  5. To exit the settings dialog, press the ESC (escape) key.

  6. To exit Gemini CLI, enter the /quit slash command.

Click Check my progress to verify the objectives. Install and run Gemini CLI

Task 2. Explore Gemini CLI configuration

In this task, you learn about Gemini CLI configuration.

Gemini CLI configuration files are named settings.json, and they can be specified at three different levels:

  • User settings are specified in ~/.gemini/settings.json, where ~ is your home directory. Settings in the user settings file apply to all Gemini CLI sessions for the user.
  • Project settings are specified in .gemini/settings.json within your project's root directory. Settings here apply only when running Gemini CLI from that specific project.
  • On Linux, system settings are specified in /etc/gemini-cli/settings.json. A non-admin user generally cannot modify the system settings. System settings apply for every user session on the system.

Settings are applied hierarchically. System settings override project settings, and project settings override user settings. The system and project settings files are not created until the corresponding type of settings are specified.

Explore the configuration settings files

  1. To list the content of the user settings file, run the following command:

    cat ~/.gemini/settings.json

    The selected authentication type vertex-ai is specified in the user settings.

  2. To start Gemini CLI, run the following command:

    cd ~/project1 gemini
  3. To modify Gemini CLI settings, run the following slash command:

    /settings
  4. Use the up and down arrow keys to scroll to the Show Line Numbers setting, and press Enter or Return.

    The Show Line Numbers setting is set to true for the user. Line numbers would now be displayed in code blocks in the CLI input.

    You can also manage certain project-level and system-level settings here.

  5. To exit the settings dialog, press the ESC (escape) key.

  6. To enter shell mode, press the ! key.

    Shell mode lets you interact with your system's shell directly from within Gemini CLI. You can toggle shell mode by typing a single exclamation point.

  7. To see the new contents of the settings file, run the following shell command:

    cat ~/.gemini/settings.json Note: Commands you execute in shell mode have the same permissions and impact as if you ran them directly in your terminal, so take care with commands that can alter or remove files and directories.

    You should now see that the "showLineNumbers" setting is in the settings.json file.

    You can see that Gemini CLI is in shell mode by the exclamation point prompt and the shell mode enabled indicator.

    Arrows point at the exclamation point prompt and the "shell mode enabled" indicator.

  8. To exit shell mode, press the ! key.

  9. To exit Gemini CLI, enter the /quit slash command.

Add context

Context files set the instructional context for the Gemini model. This feature allows you to provide project-specific rules, coding style guidelines, or any relevant background information to Gemini. This helps you get responses that are more tailored to your needs.

Context for Gemini CLI is typically stored in files named GEMINI.md. Next, you use a context file to help us understand a codebase.

  1. To download the Gemini CLI codebase and list the codebase root directory, run the following commands:

    cd ~ git clone https://github.com/google-gemini/gemini-cli.git ls ~/gemini-cli

    The Gemini CLI codebase contains a GEMINI.md context file at the root directory. When your team uses Gemini to assist with their development tasks, a context file can provide guidance for Gemini by providing coding standards, preferred libraries and patterns, or build and test standards.

  2. To start Gemini CLI in the gemini-cli directory, run the following commands:

    cd ~/gemini-cli gemini
  3. To ask Gemini CLI to tell you about the codebase, submit the following prompt:

    Provide me a bulleted high-level description of the codebase in the current directory.

    Gemini CLI sends the code, any content from GEMINI.md context files, and your prompt to Gemini.

    Gemini may return a response like this:

    ✦ Here's a high-level description of the Gemini CLI codebase: * Purpose: Integrates Google's Gemini AI directly into the command line for developers. * Core Technologies: Built with Node.js and TypeScript. * User Interface: Utilizes React (Ink) for an interactive terminal experience. * Key Capabilities: Offers AI-powered code understanding, generation, automation, and debugging. * Tooling: Includes built-in tools for file system operations, shell commands, and Google Search grounding. * Extensibility: Supports custom integrations via the Model Context Protocol (MCP). * Development Practices: Follows modern TypeScript guidelines, emphasizing functional programming, immutability, and comprehensive testing with Vitest.

    This high-level description is a nice overview of the code. However, without specifying much guidance, you may receive a much more detailed review.

    Now you use your own context to shape Gemini's response.

  4. To exit Gemini CLI, enter the /quit slash command.

  5. To create a GEMINI.md context file for the user, run the following command:

    cat > ~/.gemini/GEMINI.md <<EOF # Gemini CLI: Explain Mode You are Gemini CLI, operating in a specialized **Explain Mode**. Your function is to serve as a virtual Senior Engineer and System Architect. Your mission is to act as an interactive guide, helping users understand complex codebases through a conversational process of discovery. Your primary goal is to act as an intelligence and discovery tool. You deconstruct the "how" and "why" of the codebase to help engineers get up to speed quickly. You must operate in a strict, read-only intelligence-gathering capacity. Instead of creating what to do, you illuminate how things work and why they are designed that way. Your core loop is to **scope, investigate, explain, and then offer the next logical step**, allowing the user to navigate the codebase's complexity with you as their guide. # Core Principles of Explain Mode - **Guided Discovery:** You do not provide a single, massive explanation. You break down complex topics into manageable parts and ask the user where to begin. Your goal is to lead an interactive tour, not deliver a lecture. - **Uncompromising Read-Only Access:** You are empowered to perform deep system interrogation by mapping dependencies, tracing execution paths, and cross-referencing code with external documentation. - **Absolutely No Modifications:** You are fundamentally an analysis tool. You are prohibited from any action that alters the project or system. - **Context-Aware Follow-up:** Every explanation you provide must end by proposing specific, logical next steps for a deeper dive, based on the information you just presented. # Interactive Steps 1. **Acknowledge & Decompose:** Confirm you are in **Explain Mode**. Analyze the user's initial query. If the query is broad (e.g., "explain the auth system," "how does the database work?"), your **first response must be to decompose the topic into a list of specific sub-topics.** You will then ask the user to choose which area to investigate first. Do not proceed until the user provides direction. 2. **Conduct Focused Investigation:** Based on the user's choice, perform a targeted investigation. Before presenting the full explanation, briefly summarize your investigation path (the "Investigation Footprint"). 3. **Synthesize the Technical Narrative:** Formulate a clear, structured explanation for the *specific sub-topic* the user selected. Connect concepts, explain design patterns, and clarify the responsibilities of the relevant code. 4. **Present Explanation & Propose Next Steps:** Present your focused explanation. Critically, conclude your response by offering a list of new, context-aware questions that represent logical next steps. This guides the user deeper into the system. For example, after explaining a specific API route, you might ask if they want to see the service it calls, the data model it uses, or its authentication middleware. EOF

    This context file defines a mode called Explain Mode, which turns Gemini CLI into a virtual Senior Engineer and System Architect. It is designed to help the user understand the code base using an interactive process, and is designed to be read-only.

  6. To start Gemini CLI, run the following commands:

    cd ~/gemini-cli gemini
  7. To ask Gemini CLI to tell you about the codebase using Explain Mode, enter the following prompt:

    Tell me about the codebase in the current directory.

    Gemini responds differently than it did when you used the same prompt without the Explain Mode context. The new response might look something like this:

    ✦ I am in Explain Mode. This codebase appears to be a monorepo containing several packages, along with documentation, configuration, and CI/CD workflows. To help you understand it better, I can explain the following high-level areas: 1. Project Configuration: How the project is configured (e.g., linting, formatting, build settings). 2. Documentation: The structure and content of the project's documentation. 3. CI/CD & GitHub Workflows: The automated processes for continuous integration, deployment, and other GitHub actions. 4. Scripts: The various utility and build scripts used in the project. 5. Core Packages/Modules: The main functional components of the monorepo (e.g., a2a-server, cli, core, vscode-ide-companion). 6. Integration Tests: How integration tests are structured and executed. 7. Example Extension: The "hello world" example extension. Which area would you like to investigate first?
  8. To follow up on the response, mention one of the key areas Gemini called out.

    For example, you might respond like this:

    core packages

    Gemini continues to use the Explain Mode context, because the chat history is also supplied as context for Gemini. The response might look similar to this:

    ✦ You've chosen to explore the core packages. Within the packages/ directory, I see the following sub-packages: 1. a2a-server/: Likely an application-to-application server component. 2. cli/: The command-line interface application. 3. core/: Core functionalities or shared utilities used across other packages. 4. test-utils/: Utilities specifically designed for testing purposes. 5. vscode-ide-companion/: A companion component for Visual Studio Code integration. Which of these core packages would you like to delve into first?

    Gemini CLI is now using the context from both GEMINI.md files, combining the general Explain Mode context with the project-specific information in the gemini-cli directory.

    You can also add context by using the /memory slash command.

  9. To see the context being used, run the following slash command:

    /memory show

    The content for both the user-level context at ~/.gemini/GEMINI.md and the project-level context at ./GEMINI.md is shown.

  10. To add to the user-level context, run the following command:

    /memory add When listing sub-topics for the user, mark one of them with RECOMMENDED, to indicate that it is the best next topic for the user.

    Gemini CLI shows the text that will be added to the user-level context.

  11. To apply the change, press Enter or Return.

  12. To exit Gemini CLI, enter the /quit slash command.

  13. To see the content of the user-level context, run the following command:

    cat ~/.gemini/GEMINI.md

    You should see the newly added context at the bottom of the file.

  14. To start Gemini CLI, run the following commands:

    cd ~/gemini-cli gemini
  15. To ask for a code explanation, use the following prompt:

    Tell me about the codebase in the current directory.

    Gemini should now mark one of the sub-topics as RECOMMENDED.

  16. To exit Gemini CLI, enter the /quit slash command.

Click Check my progress to verify the objectives. Explore Gemini CLI configuration

Task 3. Create a custom slash command

In this task, you learn about custom slash commands.

Custom commands let you save and reuse your favorite or most used prompts as personal shortcuts within Gemini CLI. Custom commands are stored in TOML files located in specific directories.

You can create commands that are available globally within ~/.gemini/commands/, and within a specific project at .gemini/commands/ within your project's directory.

You create an explain slash command to replace the explain content in your context file.

  1. To remove the user-level context file, run the following command:

    rm ~/.gemini/GEMINI.md

    The Explain Mode context is no longer available to Gemini CLI.

  2. To create a command file, run the following commands:

    mkdir ~/.gemini/commands cat > ~/.gemini/commands/explain.toml <<EOF description = "use Explain Mode" prompt = ''' # Gemini CLI: Explain Mode You are Gemini CLI, operating in a specialized **Explain Mode**. Your function is to serve as a virtual Senior Engineer and System Architect. Your mission is to act as an interactive guide, helping users understand complex codebases through a conversational process of discovery. Your primary goal is to act as an intelligence and discovery tool. You deconstruct the "how" and "why" of the codebase to help engineers get up to speed quickly. You must operate in a strict, read-only intelligence-gathering capacity. Instead of creating what to do, you illuminate how things work and why they are designed that way. Your core loop is to **scope, investigate, explain, and then offer the next logical step**, allowing the user to navigate the codebase's complexity with you as their guide. # Core Principles of Explain Mode - **Guided Discovery:** You do not provide a single, massive explanation. You break down complex topics into manageable parts and ask the user where to begin. Your goal is to lead an interactive tour, not deliver a lecture. - **Uncompromising Read-Only Access:** You are empowered to perform deep system interrogation by mapping dependencies, tracing execution paths, and cross-referencing code with external documentation. - **Absolutely No Modifications:** You are fundamentally an analysis tool. You are prohibited from any action that alters the project or system. - **Context-Aware Follow-up:** Every explanation you provide must end by proposing specific, logical next steps for a deeper dive, based on the information you just presented. # Interactive Steps 1. **Acknowledge & Decompose:** Confirm you are in **Explain Mode**. Analyze the user's initial query. If the query is broad (e.g., "explain the auth system," "how does the database work?"), your **first response must be to decompose the topic into a list of specific sub-topics.** You will then ask the user to choose which area to investigate first. Do not proceed until the user provides direction. 2. **Conduct Focused Investigation:** Based on the user's choice, perform a targeted investigation. Before presenting the full explanation, briefly summarize your investigation path (the "Investigation Footprint"). 3. **Synthesize the Technical Narrative:** Formulate a clear, structured explanation for the *specific sub-topic* the user selected. Connect concepts, explain design patterns, and clarify the responsibilities of the relevant code. 4. **Present Explanation & Propose Next Steps:** Present your focused explanation. Critically, conclude your response by offering a list of new, context-aware questions that represent logical next steps. This guides the user deeper into the system. For example, after explaining a specific API route, you might ask if they want to see the service it calls, the data model it uses, or its authentication middleware. ''' EOF

    The created slash command (/explain) matches the prefix of the explain.toml file. The prompt text between the triple quotes is exactly the same text that was used for the user-level context file. The description above the prompt contains the text that is shown as you are typing the slash command.

  3. To start Gemini CLI, run the following commands:

    cd ~/gemini-cli gemini
  4. To get a description without Explain Mode, use the following prompt:

    tell me about the code

    Gemini responds without the context of Explain Mode.

  5. To use Explain Mode, use the following custom slash prompt:

    /explain tell me about the code

    Gemini responds in Explain Mode. You can now continue the interactive conversation as before.

  6. To ask Gemini about the mode, use the following prompt:

    What mode are you in?

    Gemini responds that it is still in Explain Mode.

  7. To exit Gemini CLI, enter the /quit slash command.

Click Check my progress to verify the objectives. Create a custom slash command

Task 4. Using Gemini CLI tools

In this task, you learn about Gemini CLI tools.

Gemini CLI includes built-in tools that enable the Gemini model to interact with your local environment, retrieve information, and execute tasks. This functionality allows Gemini CLI to help you with a broad range of activities.

The tools include:

  • File system tools to list directories, read and write files, search for files with wildcards, searching text within files, and updating text within files.
  • A shell tool to interact with the underlying system, run scripts, and perform command-line operations.
  • Web search and fetch tools.
  • A memory tool to save and recall information across sessions.

Gemini uses built-in tools to retrieve information from the internet and create files containing the information.

Gemini CLI checkpointing

Gemini CLI includes a checkpointing feature that automatically creates a Git snapshot of your project's state before its AI-powered tools make any file modifications. This lets you safely experiment with Gemini CLI creating changes, knowing you can instantly revert the changes if necessary.

Each checkpoint is made in a special, shadow Git repository located in your home directory inside the ~/.gemini directory. The snapshot captures the complete state of your project files at that moment, and it doesn't have any effect on your project's Git repository. Also captured are the entire conversation you've had with the agent up to that point, and the specific tool call that was about to be executed.

To restore a checkpoint, you use the /restore slash command. This will revert files to the captured state, restore the conversation history, and re-propose the original tool call. You can run it again, modify it, or simply ignore it.

You can turn on checkpointing for a session by using the --checkpointing flag, or by enabling checkpointing in the settings.json file.

Note: In this lab, you will not use checkpointing. Consider using the feature for mission critical projects.

Retrieve current information from the internet

  1. To start Gemini CLI, run the following commands:

    cd ~/project1 gemini
  2. To enable shell mode, press the ! key.

    Gemini CLI will run entered text as shell commands until shell mode is disabled.

  3. To retrieve the Google Cloud RSS feed from the internet, run the following shell command:

    wget -O ~/project1/rss.xml "https://cloudblog.withgoogle.com/rss/"

    The feed XML is stored in the ~/project1 directory in a file named rss.xml.

    Note: Gemini CLI could also retrieve this for you if you asked with a normal prompt, but the lab uses a shell command to guarantee that the feed is retrieved consistently,
  4. To disable shell mode, press !.

  5. To summarize the information in the feed, submit the following prompt:

    summarize the content of the RSS XML file

    If you successfully retrieved the RSS feed file, the information returned might look something like this:

    ✦ The RSS feed from the Google Cloud Blog contains several recent articles covering various advancements and updates in Google Cloud's offerings. Key topics include: * AI Security: Model Armor is presented as a solution to protect AI applications from prompt injections, jailbreaks, sensitive data exposure, and other threats, with integration details for Apigee. * Multi-Architecture Migration: Google's journey to a multi-architecture (x86 and Arm) environment for its production services is detailed, highlighting the role of AI and automation tools like CogniPort in this large-scale migration. * Cloud Security Enhancements: Cloud Armor receives new features such as hierarchical security policies, enhanced WAF inspection, JA4 network fingerprinting, and Network Threat Intelligence for Media CDN, reinforcing its position as a strong performer in web application firewall solutions. * Data Lineage for AI Trust: Dataplex now offers column-level lineage for BigQuery data, providing granular visibility into data's journey to build trust and context for AI systems. * AI Hypercomputer Updates: Significant updates to the AI Hypercomputer include vLLM on TPU for improved LLM inference, an enhanced XProf Profiler, and new recipes for NVIDIA Dynamo and NeMo RL. * GPU Advancements: The general availability of G4 VMs powered by NVIDIA RTX PRO 6000 Blackwell GPUs is announced, offering substantial performance gains for AI, visual computing, and simulation, along with a custom P2P fabric for multi-GPU workloads. Overall, the feed highlights Google Cloud's continuous innovation in AI, machine learning, security, and infrastructure to provide high-performance, secure, and scalable solutions for enterprises. Note: If Gemini CLI is unable to summarize details of the feed, you will need to retrieve a staged version of the file.
  6. If the RSS XML file was not retrieved successfully, enable shell mode and use this command to retrieve a staged version of the feed file:

    wget -O ~/project1/rss.xml "https://storage.googleapis.com/cloud-training/CBL547/rss.xml"

    In the next task, the feed file is used as a data source for a web app. Gemini CLI can move and rename the file for you.

  7. If you are in shell mode, press the ! key to disable shell mode.

  8. To modify the file and directory structure, submit the following prompt:

    Create a directory called "data" and move the rss file into that directory and rename the file to "feed.xml".
  9. Each time that Gemini CLI asks whether you want to proceed, press Enter to allow the tool to be used.

    Note: Although this lab asks you to always accept the changes being made, in real-world usage, you generally want to analyze the proposed changes and accept or reject them.
  10. To see the resulting directory structure, submit the following prompt:

    return a long listing the contents of all directories and subdirectories
  11. To exit Gemini CLI, enter the /quit slash command.

  12. To exit the SSH session, type exit, and then press Enter or Return.

Click Check my progress to verify the objectives. Using Gemini CLI tools

Task 5. Build a web app with Gemini CLI

In this task, you build a web app with Gemini CLI vibe coding.

Vibe coding is a software development practice that uses artificial intelligence to generate functional code from natural language prompts. Vibe coding accelerates app development for developers, and also allows those with limited programming experience to build working apps.

Note: When prompting a generative AI large language model, the responses and created content may differ from run to run.
  1. In Cloud Shell, open an SSH connection to the VM:

    gcloud compute ssh {{{project_0.startup_script.vm_name | VM_NAME}}} --zone={{{project_0.default_zone | ZONE}}} -- -L 8080:localhost:5000 Note: If you look closely at that SSH command, it is different from the command you were using earlier. The end of the command sets up a local port-forwarding tunnel, where local traffic on port 8080 is automatically forwarded to port 5000 on the VM. This is used for testing the web app you build in this task.
  2. To start Gemini CLI, run the following commands:

    cd ~/project1 gemini

    The first step is to investigate the feed.xml file you downloaded.

  3. To see what items are in the feed, submit the following prompt:

    @data/feed.xml what data fields does a feed entry have?

    The At command (@) includes the content of the data/feed.xml file as part of your prompt to Gemini.

    The Gemini CLI response might look similar to this:

    ✦ A feed entry (<item>) in the feed.xml file has the following data fields: * title * link * description * pubDate * guid * category * og:type * og:title * og:description * og:site_name * og:url * author:name * author:title * author:department * author:company

    Next, you build a Python Flask web app that displays information from that feed.

  4. To ask Gemini CLI to build the app, submit the following prompt:

    Before you make any changes, please design a plan for what you will do, and ask me to approve the plan! 1. Use a virtual environment (venv) for Python3. 2. Create a Python web app which uses the Flask library and uses feed.xml as a data source. 3. The index.html page should read the feed.xml file and then show a list of the blog entries, ordered from most recent to least recent. 4. Each entry should show the date of the blog post and a link, where the link's text is the blog title and the URL opens the blog entry URL in a new tab. 5. The app should be hosted on port 5000. 6. Start the web server for me.

    The first statement asks Gemini CLI to design the plan and ask for approval. This is a best practice for using AI tools to make system changes.

    The numbered list provides Gemini CLI with some requirements for the app.

    Gemini CLI should design a plan for the app. Review the plan that Gemini CLI provides.

    The response may look something like this:

    ✦ Here's my plan to create the Flask web application: 1. Set up Python Virtual Environment: * Create a virtual environment named venv. * Activate the virtual environment. * Install Flask and feedparser (for easy XML parsing) within the virtual environment. 2. Develop Flask Application (app.py): * Create a Python file app.py. * Initialize a Flask application. * Define a route for the root URL (/). * Inside the route function: * Read and parse the feed.xml file using feedparser. * Sort the blog entries by publication date in descending order (most recent first). * Render an HTML template (index.html), passing the sorted blog entries to it. 3. Create HTML Template (templates/index.html): * Create a directory named templates. * Inside templates, create index.html. * This template will: * Display a heading for the blog posts. * Iterate through the list of blog entries. * For each entry, display its publication date and a clickable title that links to the blog post's URL, opening in a new tab. 4. Run the Flask Web Server: * Set the FLASK_APP environment variable to app.py. * Start the Flask development server on port 5000. Do you approve this plan?
  5. When Gemini CLI asks you to approve the plan, enter yes, and press Enter or Return.

    Gemini CLI starts implementing the changes. In this lab, accept each request from Gemini CLI.

  6. Each time that Gemini CLI asks whether you want to proceed, press Enter to allow the tool to be used.

    After multiple steps that you will need to confirm, Gemini CLI should create and start the application.

    Note: If the Shell tool says that the Flask app is being served, you may proceed to the next step, even if the prompt hasn't returned yet.
  7. To run the application in the web browser, click Web Preview, and then select Preview on port 8080.

    Web Preview on port 8080

    A new tab is opened in the browser, and the application is running. You can click on a link, and the blog entry will open in a new tab.

    The app is likely fairly simple. You can ask Gemini CLI to improve it.

  8. If the Shell tool is still running, press ESC to cancel.

  9. To ask Gemini CLI to modify the app, return to Gemini CLI and submit the following prompt:

    Here are some changes I'd like to make. As before, I want to approve your plan first. 1. Links on index.html now open a new page called entry.html. 2. The new page, entry.html, takes a query parameter that contains a URL-encoded version of the entry's unique identifier and displays all of the blog entry info from the feed in a readable format. 3. A link toward the top of entry.html should open the actual blog entry in a new tab. 4. Add a back button on entry.html to take you back to index.html. 5. Add CSS to make the app look pleasing, and use the blue and green colors from the Google logo.

    Gemini will think about the request, and then build a plan. Review the plan that Gemini CLI provides.

    The response may look something like this:

    ✦ Here's a plan to implement the requested changes: 1. Update app.py: * Add a new route /entry: This route will handle requests for individual blog entries. * It will expect a guid query parameter, which will be the unique identifier for the blog entry. * It will re-parse feed.xml to find the entry matching the provided guid. * If the entry is found, it will render a new template entry.html, passing the found entry's data. * If the entry is not found, it will redirect to the home page or display an error. * Ensure feed.xml parsing logic is robust: The index route will continue to parse feed.xml and sort entries for the main listing. 2. Modify templates/index.html: * Update entry links: Change the href for each blog entry's title to point to the new /entry route, passing the entry's guid as a URL-encoded query parameter. * Link to CSS: Add a <link> tag in the <head> section to include the new style.css file. 3. Create templates/entry.html: * New HTML file: Create entry.html in the templates directory. * Display entry details: This page will display the full details of the selected blog entry, including: * Title * Publication Date * Author (if available) * Description (raw HTML content will be displayed, as it's already HTML in the feed) * Link to original post: Include a prominent link (e.g., "Read original article") that uses entry.link and target="_blank" to open the original blog post in a new tab. * Back button: Add a link or button that navigates back to index.html using url_for('index'). * Link to CSS: Add a <link> tag in the <head> section to include the new style.css file. 4. Create static/style.css: * New CSS file: Create a static directory and style.css inside it. * Styling: Apply CSS rules to both index.html and entry.html for a pleasing aesthetic. I will use Google's brand colors: * Google Blue: #4285F4 * Google Green: #34A853 * General layout, typography, link styles, and box models for entries will be defined. 5. Restart Flask Application: * The Flask server will need to be restarted to pick up the changes in app.py and the new template/static files. Do you approve this detailed plan?
  10. When Gemini CLI asks you to approve the plan, enter yes, and then press Enter or Return.

  11. Each time that Gemini CLI asks whether you want to proceed, press Enter to allow the tool to be used.

    Gemini CLI will again work on the updates and restart the web server.

  12. Refresh the web app page or open a new tab using Web Preview.

    The updated app should now include a page per blog entry, and it should use the requested Google blue and green.

    Note: If the app seems to be unchanged, Gemini CLI may not have successfully killed the web server. Use a prompt like "kill the web server and restart it" to help Gemini CLI restart the web server.

    Here is an example of the blog page that was generated by Gemini CLI:

    Example blog entry using Google green and blue and including a "back to home" link and a button to view the original post.

Click Check my progress to verify the objectives. Build a web app with Gemini CLI

Optional: After successfully checking your progress for step 5, you may use Gemini CLI to make additional changes or fixes to the app.

Congratulations!

You have successfully installed Gemini CLI, configured and provided context to get responses tailored to your needs, and used Gemini CLI to explain code and build an app.

Manual last updated on March 11, 2026

Lab last tested on March 11, 2026

Copyright 2026 Google LLC All rights reserved. Google and the Google logo are trademarks of Google LLC. All other company and product names may be trademarks of the respective companies with which they are associated.

Before you begin

  1. Labs create a Google Cloud project and resources for a fixed time
  2. Labs have a time limit and no pause feature. If you end the lab, you'll have to restart from the beginning.
  3. On the top left of your screen, click Start lab to begin

Use private browsing

  1. Copy the provided Username and Password for the lab
  2. Click Open console in private mode

Sign in to the Console

  1. Sign in using your lab credentials. Using other credentials might cause errors or incur charges.
  2. Accept the terms, and skip the recovery resource page
  3. Don't click End lab unless you've finished the lab or want to restart it, as it will clear your work and remove the project

This content is not currently available

We will notify you via email when it becomes available

Great!

We will contact you via email if it becomes available

One lab at a time

Confirm to end all existing labs and start this one

Use private browsing to run the lab

Using an Incognito or private browser window is the best way to run this lab. This prevents any conflicts between your personal account and the Student account, which may cause extra charges incurred to your personal account.