MarkTechPost@AI 前天 04:15
Getting started with Gemini Command Line Interface (CLI)
index_new5.html
../../../zaker_core/zaker_tpl_static/wap/tpl_guoji1.html

 

Google推出的Gemini CLI是一个强大的命令行工具,旨在利用AI增强开发者的工作流程。无论是在大型代码库中工作、自动化繁琐任务,还是从草图和PDF生成新应用,Gemini CLI都能将多模态智能带到你的终端。本文介绍了Gemini CLI的安装、配置和基本使用方法,包括查询和编辑大型代码库、从视觉输入生成应用、自动化操作工作流程等。通过Gemini CLI,开发者可以更高效地完成日常任务,提升工作效率。

💻 Gemini CLI 允许开发者查询和编辑大型代码库,即使超出标准的100万token上下文窗口。

🖼️ 它支持从PDF或设计草图等视觉输入生成应用程序,简化了应用开发流程。

⚙️ Gemini CLI 能够自动化操作工作流程,例如处理pull request和管理rebase等任务,提高效率。

🔌 开发者可以将Gemini CLI连接到外部工具和MCP服务器,包括Imagen、Veo和Lyria,用于媒体生成。

🔑 用户可以通过两种方式进行身份验证:使用个人Google账号或使用自己的API密钥。个人账号提供慷慨的使用限制,而API密钥允许访问特定的Gemini模型或更高的使用限制。

Google recently released the Gemini CLI, a powerful command-line tool designed to supercharge developer workflows with AI. Whether you’re working across massive codebases, automating tedious tasks, or generating new apps from sketches and PDFs, Gemini CLI brings multimodal intelligence right to your terminal.

With Gemini CLI, you can:

In this tutorial, we’ll walk you through how to install, configure, and start using Gemini CLI to enhance your daily developer tasks.

Installing Node JS

To get started, you’ll need to have Node.js installed on your system:

Installing & using the CLI

To install the Gemini CLI, run the following command:

npm install -g @google/gemini-cli

Once installed, it can be initialized by simple running the following code in the terminal

On the first run, you’ll be prompted to:

You’re now ready to start using Gemini CLI to enhance your development workflow!

If you need access to a specific Gemini model or want higher usage limits, you can use your own API key.

export GEMINI_API_KEY="YOUR_API_KEY"

Replace YOUR_API_KEY with the actual key you generated. This allows Gemini CLI to authenticate using your key instead of your personal Google account.

Querying a GitHub Repo with Gemini

Once everything is configured, we will test it with a Github repo

Run the following command to clone the Marktechpost Github repo containing multiple AI tutorials

git clone https://github.com/Marktechpost/AI-Notebooks.gitcd AI-Notebooks

Once in the AI-Notebooks folder, run the following command to run the CLI

This will launch the CLI

Summarizing the different tutorials in the repository

To get started, let’s try a simple prompt:

Give an overview of the different tutorials in this repository

Gemini CLI will read the README.md file—assuming it contains details about the tutorials—and generate a concise summary based on that information.

Explaining the different files in a sub-folder

To refer to a specific directory or file in your prompt, use the @ symbol followed by the folder or file name. Gemini CLI also supports auto-complete, so when you type @, it will suggest available files and folders automatically.

Let’s test this with the following prompt:

@A2A_Simple_Agent briefly explain the different files in this folder and how they work together to implement the A2A agent. Focus only on the .py files and the README.md file

Executing a git command

Gemini CLI can also execute shell commands directly from your prompts.

How many git commits have been made so far

When running a command like this, Gemini will:

Updating the memory

We can also manage the AI’s instructional context using the /memory command

/memory add This Git repository contains multiple self-contained tutorial projects demonstrating how to use the Gemini CLI and build agent-based systems. Each folder (e.g., A2A_Simple_Agent) focuses on a specific concept like agent communication, tool use, or integration patterns. When asked, summarize or build on individual tutorials while keeping their scope isolated.

Checking the stats

The /stats command in Gemini CLI provides a detailed summary of your current session. It shows key metrics such as total token usage, any savings from cached tokens (when available), and the overall session duration. This is useful for tracking your usage efficiency and understanding how the model is being utilized during your workflow.

Quitting the session

You can end your Gemini CLI session at any time by using the /quit command. Once you exit, the CLI will display a session summary—including total tokens used, session duration, and a breakdown of input and output tokens.

Further reading

To explore the full range of commands, check out the Gemini CLI Commands Guide. There are many powerful commands that make Gemini CLI a versatile tool for developers. In this tutorial, we’ve only scratched the surface to give you a basic overview of its core features. For more details and updates, visit the official Gemini CLI GitHub repository.

The post Getting started with Gemini Command Line Interface (CLI) appeared first on MarkTechPost.

Fish AI Reader

Fish AI Reader

AI辅助创作,多种专业模板,深度分析,高质量内容生成。从观点提取到深度思考,FishAI为您提供全方位的创作支持。新版本引入自定义参数,让您的创作更加个性化和精准。

FishAI

FishAI

鱼阅,AI 时代的下一个智能信息助手,助你摆脱信息焦虑

联系邮箱 441953276@qq.com

相关标签

Gemini CLI Google 命令行工具 AI 开发者工具
相关文章