Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

gemini

無料枠

Gemini CLI は無料枠として1日あたり1,000リクエストまで可能。Google AI Pro プランなら 1,500 まで。

Gemini CLI の主な機能

  • ファイルとシステムの操作: ローカルファイルやディレクトリの管理、および system コマンドの安全な実行が可能です。
  • タスク計画と自動化: TODOを利用した複雑なワークフローの計画や、タスクの自動化が行えます。複雑な変更を計画するための安全な読み取り専用モードである「Plan mode」も提供されています。
  • コンテキストとメモリの管理: プロジェクトの文脈や、永続的な指示・事実(メモリ)を管理できます。
  • セッション管理: 会話の再開や管理、セッションの自動スナップショット(チェックポイント)、巻き戻し(Rewind)などに対応しています。
  • ウェブ検索: ウェブ上からコンテンツを検索し、取得することができます。
  • エージェントとMCPの活用: 特定のタスクに特化した「Agent Skills」や「Subagents」を利用したり、リモートエージェントに接続するためのMCPサーバーをセットアップすることができます。
  • カスタマイズと拡張: 拡張機能(Extensions)による新機能の追加、スクリプトを用いた動作のカスタマイズ(Hooks)、およびカスタムコマンドの設定が可能です。
  • 各種連携: お気に入りのIDEとの統合や、プログラムから利用するためのヘッドレスモードもサポートされています。
  • モデルの選択と最適化: ニーズに合わせたモデルの選択や、自動フォールバック機能(Model routing)、パフォーマンス最適化のためのトークンキャッシングが利用できます。

GEMINI.md

ワークスペースコンテキストファイル。Antigravity 2.0 から GEMINI.md および AGENTS.md を読む。

.geminiignore

Gemini CLI に無視させるファイル。Git を使っているなら .gitignore も参照する。

Agent skills

.gemini/skills ディレクトリを参照します。もしくは .agents/skills も参照。

[!INFO] Antigravity 2.0 から .agents/skills が既定。

Built-in Skills (Tools)

> /tools
Available Gemini CLI tools:

  - Activate Skill (activate_skill)
  - Ask User (ask_user)
  - Edit (replace)
  - Enter Plan Mode (enter_plan_mode)
  - FindFiles (glob)
  - GoogleSearch (google_web_search)
  - Invoke Subagent (invoke_agent)
  - List Background Processes (list_background_processes)
  - Read Background Output (read_background_output)
  - ReadFile (read_file)
  - ReadFolder (list_directory)
  - SearchText (grep_search)
  - Shell (run_shell_command)
  - Update Topic Context (update_topic)
  - WebFetch (web_fetch)
  - WriteFile (write_file)
SkillDescription
File Read/Writeファイルの読み込み・書き込み
Terminal/Shell Executionコマンドの実行
Grep / Searchコードベースからの検索
Directory Managementディレクトリ構造の確認や作成
Google Web SearchWeb検索
CodeBase Investigator大規模プロジェクトの解析
Save Memory長期記憶

Stats

現在の状況は /stats で確認できる。

Google AI Pro

サブスクの場合、アカウントと紐づける。/auth コマンドを使用してアカウントを使用。 Google Cloud のアカウント(API)を使う場合、/auth で API KEY を選択。

プロンプトで改行

Ctrl+Enter で改行可能。

Quick Reference

# use specific model
gemini --model[-m] "gemini-2.5-flash-latest"

# non-interactive
gemini -p <prompt>

Interactive Mode

# clear
/clear

# save conversations
/chat save <tag>
/chat resume <tag>
/chat list

# memory
/memory show
/memory refresh
/memory add <...>

# MCP
/mcp

# file
@<file>
@<directory>/

# shell
!<shell>

.gemini/settings.json

外部ツールへの接続方法など、CLIの構成を制御します。

GEMINI.md

ディレクトリのルートに GEMINI.md ファイルを用意しておくと、システムプロンプトを設定できます. Gemini はこのファイルに記述されている指示に対応します.

Goサンプル

# Go Development Guidelines
All code contributed to this project must adhere to the following principles.

## 1. Formatting
All Go code **must** be formatted with `gofmt` before being submitted.

## 2. Naming Conventions
- **Packages:** Use short, concise, all-lowercase names.
- **Variables, Functions, and Methods:** Use `camelCase` for unexported identifiers and `PascalCase` for exported identifiers.
- **Interfaces:** Name interfaces for what they do (e.g., `io.Reader`), not with a prefix like `I`.

## 3. Error Handling
- Errors are values. Do not discard them.
- Handle errors explicitly using the `if err != nil` pattern.
- Provide context to errors using `fmt.Errorf("context: %w", err)`.

## 4. Simplicity and Clarity
- "Clear is better than clever." Write code that is easy to understand.
- Avoid unnecessary complexity and abstractions.
- Prefer returning concrete types, not interfaces.

## 5. Documentation
- All exported identifiers (`PascalCase`) **must** have a doc comment.
- Comments should explain the *why*, not the *what*.

## 6. Project structure
- cmd/ contains source code for target binaries (e.g. server, client)
- internal/ contains source code for packages not meant to be exported (e.g. internal/tools/hello)
- bin/ contains the compiled binaries
- At the root place README.md, go.mod and go.sum

Custom Commands

YAML形式で記述。プロジェクトルートに .gemini/commands に作成。 グローバルなら ~/.gemini/commands に作成。 たとえば、.gemini/commands/dev/diff.toml ファイルを作成した場合、コマンドは /dev:diff で呼び出せる。

Usage

gemini [options]

Gemini CLI - Launch an interactive CLI, use -p/--prompt for non-interactive mode

Options:
  -m, --model                     Model  [string] [default: "gemini-2.5-pro"]
  -p, --prompt                    Prompt. Appended to input on stdin (if any).  [string]
  -i, --prompt-interactive        Execute the provided prompt and continue in interactive mode  [string]
  -s, --sandbox                   Run in sandbox?  [boolean]
      --sandbox-image             Sandbox image URI.  [string]
  -d, --debug                     Run in debug mode?  [boolean] [default: false]
  -a, --all-files                 Include ALL files in context?  [boolean] [default: false]
      --all_files                 Include ALL files in context?  [deprecated: Use --all-files instead. We will be removing --all_files in the coming weeks.] [boolean] [default: false]
      --show-memory-usage         Show memory usage in status bar  [boolean] [default: false]
      --show_memory_usage         Show memory usage in status bar  [deprecated: Use --show-memory-usage instead. We will be removing --show_memory_usage in the coming weeks.] [boolean] [default: false]
  -y, --yolo                      Automatically accept all actions (aka YOLO mode, see https://www.youtube.com/watch?v=xvFZjo5PgG0 for more details)?  [boolean] [default: false]
      --telemetry                 Enable telemetry? This flag specifically controls if telemetry is sent. Other --telemetry-* flags set specific values but do not enable telemetry on their own.  [boolean]
      --telemetry-target          Set the telemetry target (local or gcp). Overrides settings files.  [string] [choices: "local", "gcp"]
      --telemetry-otlp-endpoint   Set the OTLP endpoint for telemetry. Overrides environment variables and settings files.  [string]
      --telemetry-log-prompts     Enable or disable logging of user prompts for telemetry. Overrides settings files.  [boolean]
  -c, --checkpointing             Enables checkpointing of file edits  [boolean] [default: false]
      --allowed-mcp-server-names  Allowed MCP server names  [array]
  -e, --extensions                A list of extensions to use. If not provided, all extensions are used.  [array]
  -l, --list-extensions           List all available extensions and exit.  [boolean]
  -v, --version                   Show version number  [boolean]
  -h, --help                      Show help  [boolean]