CodeVetter · Repo Unpack · Feature catalog
google-gemini/gemini-cli
User-facing surface is broad: a yargs-driven CLI with subcommands (mcp, extensions, skills, hooks, gemma) plus ~45 built-in slash commands, custom TOML commands, and MCP-prompt commands. The agent can call ~20 built-in tools (file IO, shell, grep/glob/ripgrep, web fetch/search, todos, plan mode, tracker tasks, skills, subagents incl. a browser agent). Auth supports Google OAuth, Gemini API key, Vertex AI, compute ADC, and gateway modes. Features include session resume/checkpointing/rewind, GEMINI.md hierarchical memory, hooks, policies, extensions, skills, ACP editor mode, A2A server, voice mode, IDE integration, worktrees, and multiple output formats (text/json/stream-json).
- CLI flags are defined with yargs in parseArguments: --model, --prompt/-p (headless), --prompt-interactive/-i, --sandbox, --yolo, --approval-mode, --policy, --admin-policy, --acp, --allowed-tools, --allowed-mcp-server-names, --extensions, --resume, --session-id, --session-file, --list-sessions, --delete-session, --include-directories, --output-format, --fake-responses, --record-responses, --raw-output, plus positional query.
- Five yargs subcommands are registered alongside the default '$0 [query..]' launcher: mcpCommand, extensionsCommand, skillsCommand, hooksCommand, gemmaCommand.
- BuiltinCommandLoader registers ~45 slash commands (/about /agents /auth /bug /chat /clear /compress /copy /directory /docs /editor /extensions /help /hooks /ide /init /mcp /memory /model /permissions /plan /policies /privacy /quit /restore /resume /stats /theme /tools /skills /settings /tasks /vim /rewind ...), many gated by config flags such as isAgentsEnabled, isPlanEnabled, isSkillsSupportEnabled, getFolderTrust, or nightly/dev builds.
- Config.createToolRegistry registers the built-in tool set conditionally via maybeRegister (honoring the coreTools allowlist): UpdateTopic, LS, ReadFile, RipGrep-or-Grep fallback, Glob, ActivateSkill, Edit, WriteFile, WebFetch, ReadMcpResource, ListMcpResources, Shell, background-process tools, WebSearch, AskUser, WriteTodos, Enter/ExitPlanMode, Tracker* tools, and AgentTool.
- Six AuthType values are supported (oauth-personal LOGIN_WITH_GOOGLE, gemini-api-key, vertex-ai, legacy cloud-shell, compute-default-credentials, gateway); getAuthTypeFromEnv auto-detects via GOOGLE_GENAI_USE_GCA, GOOGLE_GENAI_USE_VERTEXAI, GOOGLE_GEMINI_BASE_URL, GEMINI_API_KEY, CLOUD_SHELL/GEMINI_CLI_USE_COMPUTE_ADC.
- Sessions are recorded as JSONL files named session-<ts>-<id>.jsonl under the project's temp 'chats' dir; they can be resumed via --resume/--session-id, imported via --session-file (filtering to user/gemini messages), listed via --list-sessions, and deleted via --delete-session.
- Custom slash commands are user-defined TOML files (required 'prompt', optional 'description' per TomlCommandDefSchema) scanned from user, project, and extension command dirs by FileCommandLoader, with !{...} shell injection and @file injection prompt processors that can require confirmation.
- MCP servers from settings/extensions are connected by McpClientManager during Config._initialize; MCP prompts become slash commands via McpPromptLoader and MCP tools enter the ToolRegistry as DiscoveredMCPTool instances.
- An extension system (ExtensionManager) installs/loads extensions from git clones or GitHub releases, hydrates variables, manages consent and per-extension settings/env files, contributes MCP servers, commands, agents, skills, hooks, themes, and TOML policies, and enforces admin allowlists and integrity checks.
- A hook system (HookSystem/HookRegistry/HookRunner/HookAggregator/HookPlanner) fires lifecycle events — SessionStart/End, Before/AfterAgent, Before/AfterModel, BeforeToolSelection, Before/AfterTool — whose outputs can inject context, block/stop execution, synthesize model responses, or modify tool/config.
- Subagents are a feature: AgentRegistry loads local agent definitions (built-ins include CodebaseInvestigatorAgent, CliHelpAgent, GeneralistAgent, BrowserAgentDefinition) plus remote A2A agents, exposes them through AgentTool, and supports hot reload with new/updated/deleted summaries.
- ACP mode (--acp) runs the CLI as an Agent Client Protocol stdio server via runAcpClient with session management, RPC dispatch, and a filesystem bridge for editor clients such as Zed.
- Headless mode supports three output formats — TEXT (ANSI-stripped via stripAnsi unless --raw-output), JSON (JsonFormatter with stats), and STREAM_JSON (StreamJsonFormatter emitting INIT/MESSAGE/TOOL_USE/TOOL_RESULT/ERROR/RESULT events).
- Hierarchical memory loads GEMINI.md-style context files discovered upward/downward from the project (memoryDiscovery), surfaced through MemoryContextManager and the /memory command, with a memoryTool letting the model save facts.
- Additional user-facing features include git worktree startup (--worktree via setupWorktree which chdirs before config load), checkpointing/rewind via GitService, a local Gemma model router (LiteRtServerManager, user-scope-only binary path), voice mode transcription providers, and IDE context sharing with the VS Code companion.