SecDevOps.comSecDevOps.com
Coding With the Gemini CLI Tool

Coding With the Gemini CLI Tool

The New Stack(3 days ago)Updated 3 days ago

Some time ago, Google released the Gemini CLI (Command Line Interface) tool that is pretty impressive. Unlike many AI tools, the Gemini CLI app is installed locally, so you don’t have to worry about...

Some time ago, Google released the Gemini CLI (Command Line Interface) tool that is pretty impressive. Unlike many AI tools, the Gemini CLI app is installed locally, so you don’t have to worry about your queries (or the results thereof) being used for any nefarious purposes. Currently, Gemini CLI features: Fully open source, allowing users to inspect and contribute to the code. Powered by Gemini 2.5 Pro. Free tier allows 60 requests per minute and 1,000 requests per day with a personal Google account. Includes tools for Google Search, file operations, and shell commands for enhanced functionality. Supports custom integrations and enhances the AI’s ability to understand context. As you’ve probably assumed, based on the name, Gemini CLI is a command-line-only tool, so there’s no GUI. If you’re not comfortable using the command line, then Gemini CLI is not for you. If, on the other hand, you’re at home in a terminal window, Gemini CLI can easily become yet another tool for your programming journey. You can use Gemini CLI to help you learn how to use a new programming language, how to up your skills with a certain language, and much more. Let’s find out how to install this handy tool and then how to use it to learn a little something about JavaScript. Shall we? What You’ll Need To make this work, you’ll need any operating system that supports Node.js and NPM. I’ll be demonstrating the installation on Zorin OS, which is based on Ubuntu Linux. On Linux, you’ll also need a user with sudo privileges. Let’s get busy. Installing the Prerequisites Before you can install Gemini CLI, you have to first install Node.js and NPM. To do that, we’ll run the following commands: Once that’s taken care of, you’re ready to install Gemini CLI. Installing Gemini CLI You can install Gemini CLI with a single command: It’ll take a minute or two to finish, but it should go off without a hitch. You’re not done yet. You have to authenticate Gemini CLI with your personal Google account. To do that, open your default web browser and make sure you’re logged into your Google account. Once you’ve done that, go back to the terminal window and issue the command: If you receive an error, it means your distribution installed an older version of Node.js. To resolve that issue, do the following: Once you’ve taken care of that, re-run the gemini command. You will then be prompted to select an authentication method (Figure 1). Make sure Login with Google is selected and hit Enter on your keyboard. Figure 1: If you’d prefer, you can authenticate with a Gemini API key or Vertex AI. When your default web browser opens, if you’ve not already logged into your Google account, do so now. When prompted, click Sign In, and you’ll be informed that the authentication was successful, at which point you can close the browser to find that Gemini CLI is ready for your first query. Don’t query yet. Close Gemini by hitting the Ctrl+c key combination twice. Let’s Learn Something About JavaScript Using the terminal window, create a new project directory with the command: Change into that directory with: Now, run the gemini command again. The difference this time is that you’re working in a specific directory (as opposed to your home directory). From the main Gemini window (Figure 2), let’s issue the following query: Figure 2: Gemini CLI is ready for your first query. Hit Enter, and Gemini will go to work. As it works, it’ll most likely prompt you to okay certain tasks, or it’ll prompt you to allow it to create files (Figure 3). Figure 3: Resistance is futile, so give it permission to create the files. Continue allowing Gemini to do what it needs as it does what we’ve asked of it. After a few minutes, Gemini informed me to open the file index.html with my web browser to see the drop-downs in action (Figure 4). Figure 4: Our example drop-downs were successfully created. Okay, but how do we learn from this? Well, if you go back to your JS_PROJECT directory, you’ll see three files: index.html script.js style.css Or, you could run a follow-up like this: Gemini CLI will then walk you through what it did (Figure 5); either that, or it’ll inform you that you’ve either exhausted the resources of your free tier or the service is too busy. If that’s the case, run the query again and see if it works. Figure 5: Let Gemini CLI explain to you how it created the drop-downs. Fun times. And that, my friends, is how you can install and use the Gemini CLI tool to learn something new or hone your current skills. The post Coding With the Gemini CLI Tool appeared first on The New Stack.

Source: This article was originally published on The New Stack

Read full article on source →

Related Articles