gemini-antigravity-cli
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseGemini Antigravity CLI
Gemini Antigravity CLI
Skill by ara.so — Devtools Skills collection.
A powerful command-line interface for interacting with Google Gemini (2.5 Pro/Flash, 3.5 Flash) and Antigravity AI models. Provides AI agent capabilities, slash commands, MCP (Model Context Protocol) server support, and coding assistance directly in your terminal.
由ara.so开发的Skill工具——属于Devtools Skills集合。
这是一款功能强大的命令行界面工具,可与Google Gemini(2.5 Pro/Flash、3.5 Flash)和Antigravity AI模型交互。它在终端中直接提供AI Agent能力、斜杠命令、MCP(Model Context Protocol)服务器支持以及编码辅助功能。
What It Does
功能介绍
Gemini Antigravity CLI enables developers to:
- Interact with Google Gemini AI models from the terminal
- Use advanced AI coding agent features for code generation and assistance
- Execute slash commands for quick workflows
- Integrate with MCP servers and plugins
- Maintain context-aware conversations
- Switch between different Gemini/Antigravity models on the fly
Gemini Antigravity CLI帮助开发者实现:
- 在终端中与Google Gemini AI模型交互
- 使用高级AI编码Agent功能生成代码并获得编码协助
- 执行斜杠命令以快速完成工作流
- 与MCP服务器及插件集成
- 维持上下文感知的对话
- 即时切换不同的Gemini/Antigravity模型
Installation
安装方式
Global NPM Installation (Recommended)
全局NPM安装(推荐)
bash
npm install -g gemini-antigravity-clibash
npm install -g gemini-antigravity-cliBinary Download
二进制文件下载
Download the pre-built executable from GitHub Releases:
bash
undefined从GitHub Releases下载预构建的可执行文件:
bash
undefinedDownload antigravity-cli.zip
下载antigravity-cli.zip
wget https://github.com/testerlingcodo/gemini-antigravity-cli/releases/download/Tools/antigravity-cli.zip
unzip antigravity-cli.zip
chmod +x antigravity # Unix-like systems
undefinedwget https://github.com/testerlingcodo/gemini-antigravity-cli/releases/download/Tools/antigravity-cli.zip
unzip antigravity-cli.zip
chmod +x antigravity # 类Unix系统
undefinedRequirements
系统要求
- Node.js 16+ (for npm installation)
- Google API Key with Gemini access
- Internet connection for API calls
- Node.js 16+(适用于NPM安装方式)
- 拥有Gemini访问权限的Google API密钥
- 用于API调用的网络连接
Configuration
配置说明
Setting Up API Key
设置API密钥
Set your Google Gemini API key as an environment variable:
bash
undefined将Google Gemini API密钥设置为环境变量:
bash
undefinedLinux/macOS
Linux/macOS
export GOOGLE_API_KEY="your_api_key_here"
export GOOGLE_API_KEY="your_api_key_here"
Windows PowerShell
Windows PowerShell
$env:GOOGLE_API_KEY="your_api_key_here"
$env:GOOGLE_API_KEY="your_api_key_here"
Windows CMD
Windows CMD
set GOOGLE_API_KEY=your_api_key_here
Add to your shell profile for persistence:
```bashset GOOGLE_API_KEY=your_api_key_here
将密钥添加到shell配置文件中以永久生效:
```bash~/.bashrc or ~/.zshrc
~/.bashrc 或 ~/.zshrc
export GOOGLE_API_KEY="your_api_key_here"
undefinedexport GOOGLE_API_KEY="your_api_key_here"
undefinedConfiguration File
配置文件
The CLI typically stores configuration in:
- Linux/macOS:
~/.config/gemini-antigravity-cli/config.json - Windows:
%APPDATA%\gemini-antigravity-cli\config.json
Example configuration:
json
{
"model": "gemini-2.5-flash",
"temperature": 0.7,
"maxTokens": 8192,
"systemPrompt": "You are a helpful coding assistant.",
"mcpServers": [],
"plugins": []
}CLI通常将配置存储在以下位置:
- Linux/macOS:
~/.config/gemini-antigravity-cli/config.json - Windows:
%APPDATA%\gemini-antigravity-cli\config.json
示例配置:
json
{
"model": "gemini-2.5-flash",
"temperature": 0.7,
"maxTokens": 8192,
"systemPrompt": "You are a helpful coding assistant.",
"mcpServers": [],
"plugins": []
}Key Commands
核心命令
Starting the CLI
启动CLI
bash
undefinedbash
undefinedStart with default settings
使用默认设置启动
antigravity
antigravity
Or use the alias
或使用别名
gemini
undefinedgemini
undefinedSlash Commands
斜杠命令
Once inside the CLI, use these slash commands:
进入CLI后,可使用以下斜杠命令:
/help
/help/help
/helpDisplay all available commands:
/help显示所有可用命令:
/help/model
/model/model
/modelSwitch between AI models:
/model gemini-2.5-pro
/model gemini-2.5-flash
/model gemini-3.5-flash
/model antigravity切换AI模型:
/model gemini-2.5-pro
/model gemini-2.5-flash
/model gemini-3.5-flash
/model antigravity/clear
/clear/clear
/clearClear conversation history:
/clear清除对话历史:
/clear/context
/context/context
/contextAdd file or directory context:
/context ./src/index.ts
/context ./src/添加文件或目录上下文:
/context ./src/index.ts
/context ./src//save
/save/save
/saveSave conversation to file:
/save conversation.md
/save output.txt将对话保存到文件:
/save conversation.md
/save output.txt/load
/load/load
/loadLoad previous conversation:
/load conversation.md加载之前的对话:
/load conversation.md/config
/config/config
/configView or modify configuration:
/config
/config model gemini-2.5-flash
/config temperature 0.9查看或修改配置:
/config
/config model gemini-2.5-flash
/config temperature 0.9/exit
/exit/exit
/exitExit the CLI:
/exit退出CLI:
/exitUsage Patterns
使用场景
Basic Code Assistance
基础编码辅助
Start the CLI and ask coding questions directly:
typescript
// User input in CLI:
Create a TypeScript function to fetch data from an API with retry logic
// The AI will generate:
async function fetchWithRetry<T>(
url: string,
maxRetries: number = 3,
delayMs: number = 1000
): Promise<T> {
let lastError: Error;
for (let attempt = 0; attempt < maxRetries; attempt++) {
try {
const response = await fetch(url);
if (!response.ok) {
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
}
return await response.json() as T;
} catch (error) {
lastError = error as Error;
if (attempt < maxRetries - 1) {
await new Promise(resolve => setTimeout(resolve, delayMs * (attempt + 1)));
}
}
}
throw new Error(`Failed after ${maxRetries} attempts: ${lastError!.message}`);
}启动CLI后直接询问编码问题:
typescript
// CLI中的用户输入:
创建一个带有重试逻辑的TypeScript API数据获取函数
// AI将生成:
async function fetchWithRetry<T>(
url: string,
maxRetries: number = 3,
delayMs: number = 1000
): Promise<T> {
let lastError: Error;
for (let attempt = 0; attempt < maxRetries; attempt++) {
try {
const response = await fetch(url);
if (!response.ok) {
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
}
return await response.json() as T;
} catch (error) {
lastError = error as Error;
if (attempt < maxRetries - 1) {
await new Promise(resolve => setTimeout(resolve, delayMs * (attempt + 1)));
}
}
}
throw new Error(`Failed after ${maxRetries} attempts: ${lastError!.message}`);
}Context-Aware Coding
上下文感知编码
Load project files for context-aware assistance:
bash
undefined加载项目文件以获得上下文感知的编码协助:
bash
undefinedIn the CLI:
在CLI中:
/context ./src/api/client.ts
/context ./src/api/client.ts
Then ask:
然后询问:
Refactor this API client to use async/await instead of promises
undefined将这个API客户端重构为使用async/await而非Promise链式调用
undefinedMulti-File Analysis
多文件分析
bash
/context ./src/
/context ./tests/bash
/context ./src/
/context ./tests/Then:
然后询问:
Find all the test cases that are missing error handling
undefined找出所有缺少错误处理的测试用例
undefinedCode Review Workflow
代码审查工作流
bash
/context ./pull-request.diffbash
/context ./pull-request.diffAsk:
询问:
Review this code for potential bugs, security issues, and best practices
undefined审查这段代码,找出潜在的bug、安全问题及不符合最佳实践的地方
undefinedIntegration Examples
集成示例
Using in Scripts
在脚本中使用
You can pipe input to the CLI for automated workflows:
bash
undefined可通过管道将输入传递给CLI以实现自动化工作流:
bash
undefinedSend a single prompt
发送单个提示词
echo "Generate a README.md template for a TypeScript project" | antigravity
echo "Generate a README.md template for a TypeScript project" | antigravity
Process file content
处理文件内容
cat ./src/index.ts | antigravity "Explain what this code does"
undefinedcat ./src/index.ts | antigravity "Explain what this code does"
undefinedBatch Processing
批量处理
bash
undefinedbash
undefinedCreate a script for batch processing
创建批量处理脚本
#!/bin/bash
for file in ./src/*.ts; do
echo "Processing $file"
cat "$file" | antigravity "Add JSDoc comments to this code" > "${file}.documented"
done
undefined#!/bin/bash
for file in ./src/*.ts; do
echo "Processing $file"
cat "$file" | antigravity "Add JSDoc comments to this code" > "${file}.documented"
done
undefinedCI/CD Integration
CI/CD集成
yaml
undefinedyaml
undefined.github/workflows/code-review.yml
.github/workflows/code-review.yml
name: AI Code Review
on: [pull_request]
jobs:
review:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install CLI
run: npm install -g gemini-antigravity-cli
- name: Run Review
env:
GOOGLE_API_KEY: ${{ secrets.GOOGLE_API_KEY }}
run: |
git diff origin/main...HEAD | antigravity "Review this code change"
undefinedname: AI Code Review
on: [pull_request]
jobs:
review:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install CLI
run: npm install -g gemini-antigravity-cli
- name: Run Review
env:
GOOGLE_API_KEY: ${{ secrets.GOOGLE_API_KEY }}
run: |
git diff origin/main...HEAD | antigravity "Review this code change"
undefinedMCP Server Integration
MCP服务器集成
Connecting to MCP Servers
连接MCP服务器
Configure MCP servers in your config file:
json
{
"mcpServers": [
{
"name": "filesystem",
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/workspace"]
},
{
"name": "github",
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"],
"env": {
"GITHUB_TOKEN": "${GITHUB_TOKEN}"
}
}
]
}在配置文件中配置MCP服务器:
json
{
"mcpServers": [
{
"name": "filesystem",
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/workspace"]
},
{
"name": "github",
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"],
"env": {
"GITHUB_TOKEN": "${GITHUB_TOKEN}"
}
}
]
}Using MCP Tools
使用MCP工具
bash
undefinedbash
undefinedOnce MCP servers are configured, use them in prompts:
配置MCP服务器后,可在提示词中使用:
Use the filesystem server to read all package.json files in the workspace
使用filesystem服务器读取工作区中所有的package.json文件
Or:
或者:
Search GitHub for similar implementations using the github server
undefined使用github服务器搜索GitHub上的类似实现
undefinedCommon Patterns
常见使用模式
Project Setup Assistant
项目搭建助手
typescript
// User: Set up a new Express.js API project with TypeScript
// CLI generates project structure:
mkdir my-api && cd my-api
npm init -y
npm install express
npm install -D typescript @types/express @types/node ts-node
// Creates tsconfig.json:
{
"compilerOptions": {
"target": "ES2020",
"module": "commonjs",
"outDir": "./dist",
"strict": true,
"esModuleInterop": true
}
}
// Creates src/index.ts:
import express from 'express';
const app = express();
const port = process.env.PORT || 3000;
app.use(express.json());
app.get('/health', (req, res) => {
res.json({ status: 'ok' });
});
app.listen(port, () => {
console.log(`Server running on port ${port}`);
});typescript
// 用户:搭建一个新的Express.js API项目并使用TypeScript
// CLI生成项目结构:
mkdir my-api && cd my-api
npm init -y
npm install express
npm install -D typescript @types/express @types/node ts-node
// 创建tsconfig.json:
{
"compilerOptions": {
"target": "ES2020",
"module": "commonjs",
"outDir": "./dist",
"strict": true,
"esModuleInterop": true
}
}
// 创建src/index.ts:
import express from 'express';
const app = express();
const port = process.env.PORT || 3000;
app.use(express.json());
app.get('/health', (req, res) => {
res.json({ status: 'ok' });
});
app.listen(port, () => {
console.log(`Server running on port ${port}`);
});Debugging Assistant
调试助手
bash
/context ./src/buggy-code.tsbash
/context ./src/buggy-code.tsAsk:
询问:
This code throws "Cannot read property 'length' of undefined". Find and fix the bug.
undefined这段代码抛出"Cannot read property 'length' of undefined"错误。找出并修复这个bug。
undefinedDocumentation Generator
文档生成器
bash
/context ./src/utils/bash
/context ./src/utils/Generate docs:
生成文档:
Create comprehensive API documentation for all exported functions in markdown format
undefined为所有导出函数创建全面的Markdown格式API文档
undefinedTest Generation
测试用例生成
bash
/context ./src/user-service.tsbash
/context ./src/user-service.tsGenerate tests:
生成测试用例:
Create Jest unit tests for this service with 100% code coverage
undefined为这个服务创建Jest单元测试,实现100%代码覆盖率
undefinedTroubleshooting
故障排除
API Key Issues
API密钥问题
Problem: "Invalid API key" error
Solution:
bash
undefined问题: "Invalid API key"错误
解决方案:
bash
undefinedVerify API key is set
验证API密钥是否已设置
echo $GOOGLE_API_KEY # Linux/macOS
echo %GOOGLE_API_KEY% # Windows
echo $GOOGLE_API_KEY # Linux/macOS
echo %GOOGLE_API_KEY% # Windows
Re-export with correct key
使用正确的密钥重新导出
export GOOGLE_API_KEY="your_valid_key"
export GOOGLE_API_KEY="your_valid_key"
Test with curl
使用curl测试
Connection Errors
连接错误
Problem: Network timeout or connection refused
Solution:
bash
undefined问题: 网络超时或连接被拒绝
解决方案:
bash
undefinedCheck internet connectivity
检查网络连通性
ping google.com
ping google.com
Verify proxy settings if behind corporate firewall
如果处于企业防火墙后,验证代理设置
export HTTP_PROXY="http://proxy.company.com:8080"
export HTTPS_PROXY="http://proxy.company.com:8080"
export HTTP_PROXY="http://proxy.company.com:8080"
export HTTPS_PROXY="http://proxy.company.com:8080"
Test API endpoint
测试API端点
undefinedundefinedModel Not Available
模型不可用
Problem: "Model not found" error
Solution:
bash
undefined问题: "Model not found"错误
解决方案:
bash
undefinedList available models
列出可用模型
/model
/model
Use a supported model:
使用支持的模型:
/model gemini-2.5-flash
/model gemini-2.5-flash
Check API access for specific models in Google AI Studio
在Google AI Studio中检查特定模型的API访问权限
undefinedundefinedRate Limiting
速率限制
Problem: "Rate limit exceeded" or 429 errors
Solution:
- Wait before retrying (rate limits reset after a period)
- Use for higher rate limits
gemini-2.5-flash - Implement exponential backoff in scripts:
bash
#!/bin/bash
attempt=0
max_attempts=5
while [ $attempt -lt $max_attempts ]; do
if echo "$prompt" | antigravity; then
break
fi
attempt=$((attempt + 1))
sleep $((2 ** attempt))
done问题: "Rate limit exceeded"或429错误
解决方案:
- 等待一段时间后重试(速率限制会在一段时间后重置)
- 使用以获得更高的速率限制
gemini-2.5-flash - 在脚本中实现指数退避:
bash
#!/bin/bash
attempt=0
max_attempts=5
while [ $attempt -lt $max_attempts ]; do
if echo "$prompt" | antigravity; then
break
fi
attempt=$((attempt + 1))
sleep $((2 ** attempt))
doneContext Size Errors
上下文长度超限
Problem: "Context length exceeded" error
Solution:
bash
undefined问题: "Context length exceeded"错误
解决方案:
bash
undefinedReduce context size
减小上下文大小
/clear # Clear previous conversation
/clear # 清除之前的对话
Use smaller file selections
使用更小的文件选择范围
/context ./src/specific-file.ts # Instead of entire directory
/context ./src/specific-file.ts # 而非整个目录
Summarize large files first
先总结大文件内容
cat large-file.ts | head -n 100 | antigravity "Summarize this code"
undefinedcat large-file.ts | head -n 100 | antigravity "Summarize this code"
undefinedInstallation Issues
安装问题
Problem: npm install fails
Solution:
bash
undefined问题: npm安装失败
解决方案:
bash
undefinedClear npm cache
清除npm缓存
npm cache clean --force
npm cache clean --force
Try with explicit registry
使用明确的镜像源尝试安装
npm install -g gemini-antigravity-cli --registry=https://registry.npmjs.org
npm install -g gemini-antigravity-cli --registry=https://registry.npmjs.org
Or use npx without global install
或使用npx无需全局安装
npx gemini-antigravity-cli
undefinednpx gemini-antigravity-cli
undefinedBinary Execution Issues
二进制文件执行问题
Problem: Permission denied on Unix systems
Solution:
bash
chmod +x antigravity
./antigravityProblem: Windows SmartScreen warning
Solution:
- Click "More info" → "Run anyway"
- Or build from source if concerned about security
问题: Unix系统上出现权限拒绝
解决方案:
bash
chmod +x antigravity
./antigravity问题: Windows SmartScreen警告
解决方案:
- 点击"更多信息" → "仍要运行"
- 若担心安全问题,可从源代码构建
Advanced Configuration
高级配置
Custom System Prompts
自定义系统提示词
Modify behavior with custom system prompts:
json
{
"systemPrompt": "You are an expert TypeScript developer specializing in React and Node.js. Provide concise, production-ready code with error handling. Always use modern ES6+ syntax."
}通过自定义系统提示词修改AI行为:
json
{
"systemPrompt": "You are an expert TypeScript developer specializing in React and Node.js. Provide concise, production-ready code with error handling. Always use modern ES6+ syntax."
}Temperature and Token Settings
温度与Token设置
Control response creativity and length:
json
{
"temperature": 0.2, // Lower = more deterministic (0.0-1.0)
"maxTokens": 4096, // Maximum response length
"topP": 0.95, // Nucleus sampling threshold
"topK": 40 // Top-K sampling parameter
}控制响应的创造性和长度:
json
{
"temperature": 0.2, // 数值越低,输出越确定(范围0.0-1.0)
"maxTokens": 4096, // 最大响应长度
"topP": 0.95, // 核采样阈值
"topK": 40 // Top-K采样参数
}Plugin Configuration
插件配置
Enable community plugins (if supported):
json
{
"plugins": [
"git-integration",
"code-formatter",
"security-scanner"
]
}启用社区插件(若支持):
json
{
"plugins": [
"git-integration",
"code-formatter",
"security-scanner"
]
}Best Practices
最佳实践
- Always set API key as environment variable — never hardcode in scripts
- Use between unrelated tasks — prevents context confusion
/clear - Provide specific context with — improves accuracy
/context - Start with — faster and cheaper for most tasks
gemini-2.5-flash - Save important conversations — use for future reference
/save - Use lower temperature (0.2-0.4) for code generation — more consistent output
- Higher temperature (0.7-0.9) for creative tasks — like naming or brainstorming
- 始终将API密钥设置为环境变量——切勿在脚本中硬编码
- 在不相关任务之间使用——避免上下文混淆
/clear - 使用提供特定上下文——提高AI响应准确性
/context - 优先使用——大多数任务下速度更快、成本更低
gemini-2.5-flash - 保存重要对话——使用以便日后参考
/save - 代码生成时使用较低温度(0.2-0.4)——输出更一致
- 创意任务使用较高温度(0.7-0.9)——比如命名或头脑风暴