00:00In this video, we're going to deep dive into Gemini CLI
00:01We'll look into how we can get started with Gemini CLI, then examine some CLI command options to understand what options we can provide when starting Gemini
00:12Next, we'll explore how to configure it— for example, using the Gemini MD file or the agents.md file
00:20We'll review these different configurations, and then wrap up with some hands-on practice
00:27We'll see how Gemini can analyze an existing project, and towards the end, let's get ambitious and try giving it one big prompt to see if we can one-shot an application and build it completely end-to-end
00:41So, let's get started
00:43All that we need to do is npx and give the GitHub URL link, or we can do npm and run this command
00:51This is all assuming that you already have Node.js installed on your machine
00:55So, I've got it installed on my machine, so I can go straight to the terminal
00:56I'm going to copy this command, open the terminal, and type it: npm install Google Gemini CLI
01:06We can see that it's installing already
01:08And there you go, it seems to have installed successfully
01:12To start Gemini, all I have to do is type Gemini, and of course, we have Gemini up and running
01:18Then, we have the option to choose different themes
01:22For example, it could be NC Dark, Atom One Dark, or the default one
01:25I quite like the..
01:28Atom one
01:31So, I'm just going to choose that, and then it's asking me to log into Google
01:33We all have personal accounts, so we can simply log in with our personal account
01:41I'm going to click on "Log in with Google," and choose my personal account to log into it
01:44Once we are logged in, it says Gemini Code Assist and the Gemini CLI are now authorized to access your account
01:53We are logged in here and ready to go
01:55Some tips it mentions are: ask questions, edit files, and run commands
01:59Be specific for the best results, and create a Gemini Markdown file to customize your interaction with Gemini
02:03Use /help for more information
02:07For now, I'm just going to type "help" and see what it shows
02:11It shows a bunch of keyboard shortcuts and also a list of commands that we can try out and get familiarized with
02:20So, we'll probably run some of these commands to get accustomed to it, and we'll also familiarize ourselves with the keyboard shortcuts
02:26To begin with, if I press Ctrl+C, I'm just going to quit the application
02:31So, I'll do Ctrl+C and come out of it, and it says 'Agent powering down, goodbye,' and the performance is summarized straight away
02:40Just for typing 'Gemini,' we have quite a few options
02:42For example, if we do 'Gemini help,' it will show us that we can change the model
02:46By default, it's set to Gemini 2.5 Pro
02:50And if we specify '-prompt,' then we can directly write a prompt, such as how you..
02:55You would interact with a chatbot, and the most interesting feature is the sandbox
02:58If you want to run a sandbox without affecting anything locally, you can do so by providing a sandbox configuration
03:06For example, if you have a Docker image, you can specify the sandbox image and provide the image URI for the Docker image, and you should be able to run that image and do everything with Gemini inside of it
03:16If you want Gemini to show the memory usage, you can pass this option
03:20For example, if I run "Gemini show memory usage" and then start it, on the bottom right, we can see that the amount of memory usage keeps varying depending on what we type
03:29I can always quit and come out of it, and if you want to run the command..
03:36Automatically accept all the actions that Gemini takes by passing a hyphen y
03:40If you want to tweak any telemetry consent, you can always do that
03:45You can also checkpoint the files that are edited, and allow specific MCP servers and Restic access to some of the MCP servers
03:54You can also extend the capabilities of Gemini CLI using the hyphen E extensions command, and you can always list the available extensions
04:06Lastly, you can check the installed version and also ask for help
04:10Having said that, let's start Gemini in the default mode
04:15Over here, we seem to have three different commands: one is the at-symbol, the next one is the exclamation mark
04:21And the other one is the forward slash
04:24So, let's look into each of the three
04:27Now, if we do a forward slash, we can see that that's clear
04:29This is equivalent to running 'clear' on the terminal
04:32It's going to clear the Gemini screen
04:35And there's 'help', 'memory'
04:36So, memory is interesting because if we do 'memory' space, we can see that it shows the memory
04:41We can add to the memory and we can refresh the memory
04:45And if we look at the documentation, the memory is to manage the AI's instructional context
04:49The hierarchical memory is loaded from Gemini.md
04:53So, there's something called Gemini.md, which we can define at three levels
04:58One is the global level, and the next one is the project or ancestor level, and the next one is..
05:02The subdirectory level
05:05At each of these levels, we can define gemini.md, and the memory is pulled from this gemini.md file
05:13By simply adding to this file, we can include some context to the memory that's pulled from gemini.md
05:18Then we have the theme; obviously, we can change the theme that we set when we originally started Gemini
05:24Next is the editor, which could be your VS Code or any other editor you prefer, but we need to set an external editor preference
05:34Then, the stats on the current session that you're running: this lists the MCP server that you have configured
05:40Similarly, we can list the extensions available with Gemini, and we can also list the tools that are available
05:47There's also this chat, and this chat again is interesting because we can manage the conversation history
05:54And for managing it, all that we have to do is chat list
06:00Currently, we don't have any saved conversations, but we can actually save it by running chat save and then giving it a name; we can save a conversation
06:08So, in the documentation, it says, "Save and resume conversation history for branching conversation state interactively or resume a previous state from a later session." So, basically, we can branch off and go to a completely different conversation, and then get back to it
06:25We can resume it, or we can save the current conversation
06:28It's similar to how you deal with your GitHub repositories
06:31And then..
06:35There's another feature called Compress, which compresses the context by replacing it with a summary
06:38So, if the context is pretty large and you want to understand what it is, you can simply call Compress, and it will show a condensed summary
06:46Since we don't have much conversation here, it's not doing much currently
06:50Next, comes the "at" symbol
06:52With @, we can pass any file
06:54For example, I'm going to pass this cake.jpeg, and I’ll ask, "What's going on in this image?" It will explain to me what's happening
07:01This is a food photograph of a cake
07:03The cake is on a wooden serving platter, which is on a dark tablecloth
07:08So, there is the image it’s describing
07:11There’s a dark..
07:13Tablecloth
07:16In the background, there's a white vase with some greenery, a container with utensils
07:18So it's pretty much explaining what's going on in that file
07:21So that's the usage of 'at'
07:23And the next one is very interesting: the exclamation mark
07:27When we hit the exclamation mark, it switches to shell mode, and shell mode is enabled
07:32This is quite handy
07:33For example, if you want to do 'ls -l', it will list all the files available, and you can execute whatever shell commands you want
07:42To toggle it off, you need to hit the exclamation mark again, and we return to Gemini mode
07:48In this mode, we won't be able to run terminal commands; for example, if I do 'ls -l', it will start..
07:53Thinking, it says it's analyzing the details, and so quickly checking in terminal mode is quite handy
08:00But if I do an exclamation mark and then do an ls, then it's going to list all the files that are available
08:07Now let's move on to how we can do Gemini CLI configuration
08:09For the configuration, there are different layers at which we can do it
08:14For example, there are six layers available, and the default values are the hard-coded defaults within the application
08:20The lower numbers are overridden by the higher numbers, so whatever you define at the higher number is going to take precedence over the lower numbers
08:27The degree of control is such that you know you have default values, and then you can have user-level settings
08:35Project-level settings, system-level settings, and you can set environment variables through a `.env` file
08:40You can also use command-line arguments when launching Gemini CLI, and the settings typically go in the `settings.json` file
08:48When I install Gemini, the `gemini/settings.json` file gets created automatically in my home directory
08:56If I go to my home directory and type `cat gemini/settings.json`, we can see that the theme I chose is set here
09:07I opted for the Atom One theme when I installed Gemini
09:09There's also a default option called `OType`, which defaults to `OPersonal`
09:14These are the two settings at the user level
09:16Then, at the project level, you can define the `gemini/settings.json` within your project directory
09:23The project's root directory
09:30You can have system-level settings, for example, in Linux, you can do /etc/gemini_cli/settings.json, and for macOS, obviously, it's located in Library/Application Support/Gemini_CLI/settings.json
09:37So, what goes on in the Gemini_settings.json? One of the things is the context file name
09:43For example, you can have a gemini.md where you specify instruction-level context and that configuration, such as what that file is—whether it's agents.md or gemini.md—that goes in the context file name
09:58Similarly, you can have a buck command that overrides the default URL for the buck command
10:02And then there's file filtering, and code tools allows you to specify the list of code tools that should be… Made available to the model
10:11So, if you want to restrict the model to only a set of tools, then you can specify this as an array of strings
10:17For example, the code tools are ReadFile tool, Globe tool, and Shell tool
10:22If you want to find out what the tools that are available are, you could do `/tools`, and it will tell you what the available tools are, which include ReadFolder, ReadFile, and all of these, including Google Search
10:33The Google Search is enabled by default
10:35You can also use the exclude tool, where you can give an array of tools that you need to exclude
10:42For example, run shell command and find files, and you can similarly specify allow MCP server, exclude MCP server, enable auto-accept, and set the theme, which..
10:53We just saw
10:54With that overview of what can go into settings.json, let's look at an example
10:59We can see that in the settings.json file, we have the theme sandbox set as Docker, and we have the list of MCP services
11:05The telemetry consent, for example, is enabled, and usage statistics are also enabled
11:11These are typically what go into the settings.json file
11:16The next thing that Gemini CLI handles is environment variables, which are managed through .env files
11:22It's become a common practice to store API keys, like the Gemini API key or Google API key, in a .env file
11:28So, if you're working from any directory, it looks for the .env file in the current working directory
11:37If it's not found, then it searches the parent directories
11:39Parent directory until it finds the YAML file, until it reaches the project root
11:44And if it's still not able to find it, then it's going to look in your home directory
11:47Once it finds that this API key is required, the Gemini API key is required, and the rest of the options are optional
11:57For example, you can have the Gemini model, Google API key, Google Cloud project, and all those details there
12:03So after the YAML file, come the context files, which are the hierarchical instructional context
12:11These context files are crucial for configuring the instructional context
12:15This instructional context is also referred to as memory, and it's provided to the Gemini model
12:21This feature allows you to give project-specific instructions
12:27Coding style guide or any other relevant background information for the AI
12:29So, basically, these are details that cut across the entire project
12:33By default, this file is going to be a Gemini.md file
12:38They have provided an example of what goes into this file
12:41We can include the general instructions, such as, for example, if this is a TypeScript library, to follow the existing coding style when generating new TypeScript code
12:54You might specify that the functional programming paradigm should be preferred when appropriate
13:00All code should be compatible with TypeScript 5.0 and Node.js 20
13:02For the coding style, you might specify to use two spaces for indentation and so on
13:10Coding style details, and you're also providing specific components—for example, for the client.ts file, which handles all outbound API requests
13:19Whenever adding a new API call, ensure they include robust error handling and logging
13:24See how we can provide project-level coding style instructions; we can give general instructions as well as be very specific about what goes into each specific file
13:35Once we include all these details in gemini.md or your agent.md file, the generated code will be much more sophisticated and tailored to your use case
13:46Next comes sandboxing; it's quite possible that Gemini will go ahead and execute potentially unsafe operations
13:54In that case, when you start Gemini, you need..
13:56To say sandbox, you need to provide the sandbox option
13:59We can just say Gemini - S, and that creates a sandbox for you, or we can set the Gemini sandbox environment variable
14:09Note that if you want to run in YOLO mode, which means you're going to approve of whatever action the Gemini CLI takes, then you need to have Docker enabled, because it's going to use the Gemini CLI sandbox Docker image by default for project-specific sandboxes
14:24You can create your custom Docker file at gemini/sandbox.docker file, and you can include all your custom details there, similar to the standard contents of a Docker file
14:35That pretty much covers what we need to know about configuring the Gemini CLI
14:41With that, let's move on to doing some hands-on
14:44Here's a simple application that I have created
14:46It's just a drag-and-drop image processor
14:48If you drag and drop an image, it will blur the image
14:50It's as simple as that
14:53So, to start, I’m just going to drag and drop this image and click on "Apply Blur." Now, it has blurred this image
14:56 Next, let's find out what Gemini tells us about this project
14:58So, I go to the terminal
15:01It's an image processor
15:03I’m just going to type "gemini" and see what happens
15:05It's started
15:08I’m going to ask it to explain what’s going on in this project
15:10So, it’s running with Gemini 2.5 Pro, and it’s not running in any sandbox environment
15:15It has started analyzing the project components
15:18It says the project appears to be a web application
15:20With a React front end and the Python back end
15:24The front end is built with React and TypeScript, with Tailwind CSS
15:25That's all fine
15:28Then, this Python FastAPI application seems to be set up for image processing, given the inclusion of libraries like OpenCV and Pillow
15:35That all looks good, and it says I'll now examine the main application logic, which is there in app.tsx and main.py
15:44And then it comes up with this explanation: the front end provides a user interface for uploading images, allows users to select images from their computer or drag and drop into the application, and displays the original and blurred versions
15:58So it all looks good to me
16:00Eventually, it says, in short, this is a full stack application
16:03That lets us upload an image, blur it, and then download the result
16:07It also has features to convert images to SVG
16:11Next, let's move on to one-shorting and creating an entire app with a single prompt
16:17But we're going to switch to Gemini 2.5 Flash because we ran out of tokens
16:23We hit the rate limit on Gemini 2.5 Pro, so I'm going to choose Gemini 2.5 Flash and start it
16:29You can see that we have started with Gemini 2.5 Flash, and I'm going to give my entire prompt, which is to build a full-stack app for task management
16:37I want to be able to create new tasks, edit and delete existing tasks, and I should be able to organize them in Kanban style with columns for To-Do, In Progress, and Done
16:49Archive, and it's the standard user interface
16:51Basically, I'm just trying to create a task management app
16:55So, let me hit enter on that and see what it comes up with
16:57It's trying to do npm create task-manager-app, and it's using a React TypeScript template
17:04I'm just going to say yes to allow, yes for execution, and it started installing the necessary dependencies
17:07Yes, allow
17:10It is prioritizing task management
17:12It has updated app.tsx to handle login state
17:14That's updated
17:17It's now creating KanbanBoard.tsx, so it's working on the user interface, constructing the Card component, KanbanBoard.tsx, and then there's TaskCard.tsx
17:27It's generating all these React components, as we can see here, exporting those components
17:31This task
17:33and then it's writing all the files to run the application
17:35It says navigate to the task manager app and then do `cd task-manager-app` and then run `npm run dev`
17:42So I'm just going to do that, or actually, let's ask it to start the application now because we are not inside it
17:50So I'm going to do an exclamation mark
17:52If I do `ls`, we can see that there's a task manager app
17:55So if I do an exclamation mark and then `cd task-manager-app`, I understand that I will leave the current directory and then I will run the command to start the app
17:58Let's see what it does
18:01Yes
18:04Hello once
18:07So it seems to be struggling to just start the application
18:09So I'm just going to press escape and come out of it, then do an exclamation mark to switch to terminal mode and then run `npm run dev`
18:17So, it has some errors
18:21So, I'm going to go back to Gemini mode and I'm just going to paste the error
18:25It's going to give the error, and let's see what it does
18:27So, it's refining the solution, accepting edits
18:32You can see the little dots here, which indicate that it's running
18:36Eventually, I had to come out of Gemini altogether and then type `npm run dev` in order to start the app
18:41We can see now that the app is running, and if we go to the user interface, it's got the registration form
18:48Not the best-looking user interface
18:50I'm just going to create a username and password 1 2 3 4 5 6, and I'm going to register
18:55User already exists because I tried creating it
18:58That's great
19:00So, I'm going to click on login, and I'm going to log in
19:01So, it allowed me to
19:04Login—that's great
19:08But again, in the user interface, it's quite basic, and there's a significant lack of any CSS whatsoever
19:11But let's see if it's functional
19:13I'm going to add a task asking to publish a video
19:15Add task
19:17So, it has added a task to the to-do list
19:18If I move forward, it's moving it under in progress
19:27And if I move it forward again, it's moving it under done
19:30And if I move forward again, it's moving it to archive, which is all
19:34If I move it backwards, it's moving it back to done, which is all great
19:39If I click on Edit, I'm now able to edit the task, and I can add "publish video on Google Gemini CLI." And if I click on Save, that's getting saved, too
19:43So, it's functional, but for some reason, it's completely lacking the CSS
19:45That was the..
19:47We tried out a different project as well
19:50The UI was completely lacking any CSS
19:52So that was a quick run-through of Gemini CLI, guys
19:55We looked into how we can get started with it, and we also explored the command options, how to configure Gemini CLI, and then we did some quick hands-on work to understand an existing project
20:02That went fine
20:10We also did some one-shot prompts, trying to create a task app, which lacked some CSS and styling, but it produced a functional app
20:17So with that, I'm signing off, and I will see you in my next video
20:22Until then, take care.