2025-12-01 11:38:48 -08:00
# Gemini CLI extensions
2025-06-10 15:48:39 -07:00
2025-09-09 16:59:18 -04:00
_This documentation is up-to-date with the v0.4.0 release._
2025-06-10 15:48:39 -07:00
2026-01-16 11:37:28 -08:00
Gemini CLI extensions package prompts, MCP servers, Agent Skills, and custom
commands into a familiar and user-friendly format. With extensions, you can
expand the capabilities of Gemini CLI and share those capabilities with others.
They're designed to be easily installable and shareable.
2025-09-09 16:59:18 -04:00
2025-10-15 00:29:21 -07:00
To see examples of extensions, you can browse a gallery of
[Gemini CLI extensions ](https://geminicli.com/extensions/browse/ ).
2025-10-09 08:17:37 -04:00
See [getting started docs ](getting-started-extensions.md ) for a guide on
creating your first extension.
2025-10-06 20:12:56 -04:00
2025-10-09 08:17:37 -04:00
See [releasing docs ](extension-releasing.md ) for an advanced guide on setting up
GitHub releases.
2025-10-06 20:12:56 -04:00
2025-09-09 16:59:18 -04:00
## Extension management
2025-10-09 08:17:37 -04:00
We offer a suite of extension management tools using `gemini extensions`
commands.
2025-09-09 16:59:18 -04:00
2025-10-09 08:17:37 -04:00
Note that these commands are not supported from within the CLI, although you can
list installed extensions using the `/extensions list` subcommand.
2025-09-09 16:59:18 -04:00
2025-10-09 08:17:37 -04:00
Note that all of these commands will only be reflected in active CLI sessions on
restart.
2025-09-09 16:59:18 -04:00
### Installing an extension
2025-10-09 08:17:37 -04:00
You can install an extension using `gemini extensions install` with either a
GitHub URL or a local path.
2025-09-09 16:59:18 -04:00
2025-10-09 08:17:37 -04:00
Note that we create a copy of the installed extension, so you will need to run
`gemini extensions update` to pull in changes from both locally-defined
extensions and those on GitHub.
2025-09-09 16:59:18 -04:00
2025-10-09 08:17:37 -04:00
NOTE: If you are installing an extension from GitHub, you'll need to have `git`
installed on your machine. See
[git installation instructions ](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git )
for help.
2025-10-06 20:12:56 -04:00
2025-09-09 16:59:18 -04:00
```
2025-11-02 09:59:03 -08:00
gemini extensions install <source> [--ref <ref>] [--auto-update] [--pre-release] [--consent]
2025-09-09 16:59:18 -04:00
```
2025-11-02 09:59:03 -08:00
- `<source>` : The github URL or local path of the extension to install.
- `--ref` : The git ref to install from.
- `--auto-update` : Enable auto-update for this extension.
- `--pre-release` : Enable pre-release versions for this extension.
- `--consent` : Acknowledge the security risks of installing an extension and
skip the confirmation prompt.
2025-09-09 16:59:18 -04:00
### Uninstalling an extension
2025-11-21 23:08:59 +05:30
To uninstall one or more extensions, run
`gemini extensions uninstall <name...>` :
2025-09-09 16:59:18 -04:00
```
2025-11-21 23:08:59 +05:30
gemini extensions uninstall gemini-cli-security gemini-cli-another-extension
2025-09-09 16:59:18 -04:00
```
### Disabling an extension
2025-10-09 08:17:37 -04:00
Extensions are, by default, enabled across all workspaces. You can disable an
extension entirely or for specific workspace.
2025-09-09 16:59:18 -04:00
2025-11-02 09:59:03 -08:00
```
gemini extensions disable <name> [--scope <scope>]
```
- `<name>` : The name of the extension to disable.
- `--scope` : The scope to disable the extension in (`user` or `workspace` ).
2025-09-09 16:59:18 -04:00
### Enabling an extension
2025-06-10 15:48:39 -07:00
2025-11-02 09:59:03 -08:00
You can enable extensions using `gemini extensions enable <name>` . You can also
enable an extension for a specific workspace using
`gemini extensions enable <name> --scope=workspace` from within that workspace.
```
gemini extensions enable <name> [--scope <scope>]
```
2025-09-19 11:43:39 -04:00
2025-11-02 09:59:03 -08:00
- `<name>` : The name of the extension to enable.
- `--scope` : The scope to enable the extension in (`user` or `workspace` ).
2025-06-10 15:48:39 -07:00
2025-09-09 16:59:18 -04:00
### Updating an extension
2025-10-09 08:17:37 -04:00
For extensions installed from a local path or a git repository, you can
explicitly update to the latest version (as reflected in the
2025-11-02 09:59:03 -08:00
`gemini-extension.json` `version` field) with `gemini extensions update <name>` .
2025-09-09 16:59:18 -04:00
You can update all extensions with:
```
gemini extensions update --all
```
### Create a boilerplate extension
2025-10-09 08:17:37 -04:00
We offer several example extensions `context` , `custom-commands` ,
`exclude-tools` and `mcp-server` . You can view these examples
[here ](https://github.com/google-gemini/gemini-cli/tree/main/packages/cli/src/commands/extensions/examples ).
2025-09-09 16:59:18 -04:00
2025-10-09 08:17:37 -04:00
To copy one of these examples into a development directory using the type of
your choosing, run:
2025-09-09 16:59:18 -04:00
```
2025-11-02 09:59:03 -08:00
gemini extensions new <path> [template]
2025-09-09 16:59:18 -04:00
```
2025-11-02 09:59:03 -08:00
- `<path>` : The path to create the extension in.
- `[template]` : The boilerplate template to use.
2025-09-09 16:59:18 -04:00
### Link a local extension
2025-10-09 08:17:37 -04:00
The `gemini extensions link` command will create a symbolic link from the
extension installation directory to the development path.
2025-09-09 16:59:18 -04:00
2025-10-09 08:17:37 -04:00
This is useful so you don't have to run `gemini extensions update` every time
you make changes you'd like to test.
2025-09-09 16:59:18 -04:00
```
2025-11-02 09:59:03 -08:00
gemini extensions link <path>
2025-09-09 16:59:18 -04:00
```
2025-11-02 09:59:03 -08:00
- `<path>` : The path of the extension to link.
2025-09-09 16:59:18 -04:00
## How it works
2025-06-10 15:48:39 -07:00
2025-09-09 16:59:18 -04:00
On startup, Gemini CLI looks for extensions in `<home>/.gemini/extensions`
2025-06-10 15:48:39 -07:00
2025-10-09 08:17:37 -04:00
Extensions exist as a directory that contains a `gemini-extension.json` file.
For example:
2025-06-13 13:57:00 -07:00
2025-09-09 16:59:18 -04:00
`<home>/.gemini/extensions/my-extension/gemini-extension.json`
2025-06-10 15:48:39 -07:00
### `gemini-extension.json`
2025-10-09 08:17:37 -04:00
The `gemini-extension.json` file contains the configuration for the extension.
The file has the following structure:
2025-06-10 15:48:39 -07:00
```json
{
"name": "my-extension",
"version": "1.0.0",
"mcpServers": {
"my-server": {
"command": "node my-server.js"
}
},
2025-07-01 16:13:46 -07:00
"contextFileName": "GEMINI.md",
"excludeTools": ["run_shell_command"]
2025-06-10 15:48:39 -07:00
}
```
2025-10-09 08:17:37 -04:00
- `name` : The name of the extension. This is used to uniquely identify the
extension and for conflict resolution when extension commands have the same
name as user or project commands. The name should be lowercase or numbers and
use dashes instead of underscores or spaces. This is how users will refer to
your extension in the CLI. Note that we expect this name to match the
extension directory name.
2025-06-10 15:48:39 -07:00
- `version` : The version of the extension.
2025-12-03 19:16:16 -05:00
- `mcpServers` : A map of MCP servers to settings. The key is the name of the
2025-10-09 08:17:37 -04:00
server, and the value is the server configuration. These servers will be
2026-01-08 13:59:23 -05:00
loaded on startup just like MCP servers settings in a
2025-10-09 08:17:37 -04:00
[`settings.json` file ](../get-started/configuration.md ). If both an extension
2025-12-03 19:16:16 -05:00
and a `settings.json` file settings an MCP server with the same name, the
2025-10-09 08:17:37 -04:00
server defined in the `settings.json` file takes precedence.
- Note that all MCP server configuration options are supported except for
`trust` .
- `contextFileName` : The name of the file that contains the context for the
extension. This will be used to load the context from the extension directory.
If this property is not used but a `GEMINI.md` file is present in your
extension directory, then that file will be loaded.
- `excludeTools` : An array of tool names to exclude from the model. You can also
specify command-specific restrictions for tools that support it, like the
`run_shell_command` tool. For example,
`"excludeTools": ["run_shell_command(rm -rf)"]` will block the `rm -rf`
command. Note that this differs from the MCP server `excludeTools`
functionality, which can be listed in the MCP server config.
When Gemini CLI starts, it loads all the extensions and merges their
configurations. If there are any conflicts, the workspace configuration takes
precedence.
2025-07-28 18:40:47 -07:00
2025-10-23 11:47:08 -04:00
### Settings
2025-11-06 12:55:20 -08:00
_Note: This is an experimental feature. We do not yet recommend extension
authors introduce settings as part of their core flows._
2025-10-23 11:47:08 -04:00
Extensions can define settings that the user will be prompted to provide upon
installation. This is useful for things like API keys, URLs, or other
configuration that the extension needs to function.
To define settings, add a `settings` array to your `gemini-extension.json` file.
Each object in the array should have the following properties:
- `name` : A user-friendly name for the setting.
- `description` : A description of the setting and what it's used for.
- `envVar` : The name of the environment variable that the setting will be stored
as.
2025-10-28 14:48:50 -04:00
- `sensitive` : Optional boolean. If true, obfuscates the input the user provides
and stores the secret in keychain storage. **Example **
2025-10-23 11:47:08 -04:00
```json
{
"name": "my-api-extension",
"version": "1.0.0",
"settings": [
{
"name": "API Key",
"description": "Your API key for the service.",
"envVar": "MY_API_KEY"
}
]
}
```
When a user installs this extension, they will be prompted to enter their API
key. The value will be saved to a `.env` file in the extension's directory
(e.g., `<home>/.gemini/extensions/my-api-extension/.env` ).
2025-12-03 19:16:16 -05:00
You can view a list of an extension's settings by running:
```
2026-01-07 11:23:07 -05:00
gemini extensions list
2025-12-03 19:16:16 -05:00
```
and you can update a given setting using:
```
2026-01-07 11:23:07 -05:00
gemini extensions config <extension name> [setting name] [--scope <scope>]
2025-12-03 19:16:16 -05:00
```
2025-12-08 17:51:26 -05:00
- `--scope` : The scope to set the setting in (`user` or `workspace` ). This is
optional and will default to `user` .
2025-09-09 16:59:18 -04:00
### Custom commands
2025-07-28 18:40:47 -07:00
2025-10-09 08:17:37 -04:00
Extensions can provide [custom commands ](../cli/custom-commands.md ) by placing
TOML files in a `commands/` subdirectory within the extension directory. These
commands follow the same format as user and project custom commands and use
standard naming conventions.
2025-07-28 18:40:47 -07:00
2025-09-09 16:59:18 -04:00
**Example**
2025-07-28 18:40:47 -07:00
An extension named `gcp` with the following structure:
```
.gemini/extensions/gcp/
├── gemini-extension.json
└── commands/
├── deploy.toml
└── gcs/
└── sync.toml
```
Would provide these commands:
- `/deploy` - Shows as `[gcp] Custom command from deploy.toml` in help
- `/gcs:sync` - Shows as `[gcp] Custom command from sync.toml` in help
2026-01-16 11:37:28 -08:00
### Agent Skills
_Note: This is an experimental feature enabled via `experimental.skills` ._
Extensions can bundle [Agent Skills ](../cli/skills.md ) to provide on-demand
expertise and specialized workflows. To include skills in your extension, place
them in a `skills/` subdirectory within the extension directory. Each skill must
follow the [Agent Skills structure ](../cli/skills.md#folder-structure ),
including a `SKILL.md` file.
**Example**
An extension named `security-toolkit` with the following structure:
```
.gemini/extensions/security-toolkit/
├── gemini-extension.json
└── skills/
├── audit/
│ ├── SKILL.md
│ └── scripts/
│ └── scan.py
└── hardening/
└── SKILL.md
```
Upon installation, these skills will be discovered by Gemini CLI and can be
activated during a session when the model identifies a task matching their
descriptions.
Extension skills have the lowest precedence and will be overridden by user or
workspace skills of the same name. They can be viewed and managed (enabled or
disabled) using the [`/skills` command ](../cli/skills.md#managing-skills ).
2026-01-07 15:46:44 -05:00
### Hooks
Extensions can provide [hooks ](../hooks/index.md ) to intercept and customize
Gemini CLI behavior at specific lifecycle events. Hooks provided by an extension
must be defined in a `hooks/hooks.json` file within the extension directory.
> [!IMPORTANT] Hooks are not defined directly in `gemini-extension.json`. The
> CLI specifically looks for the `hooks/hooks.json` file.
#### Directory structure
```
.gemini/extensions/my-extension/
├── gemini-extension.json
└── hooks/
└── hooks.json
```
#### `hooks/hooks.json` format
The `hooks.json` file contains a `hooks` object where keys are
[event names ](../hooks/reference.md#supported-events ) and values are arrays of
[hook definitions ](../hooks/reference.md#hook-definition ).
```json
{
"hooks": {
2026-01-25 18:33:12 -05:00
"BeforeAgent": [
2026-01-07 15:46:44 -05:00
{
"hooks": [
{
"type": "command",
"command": "node ${extensionPath}/scripts/setup.js",
"name": "Extension Setup"
}
]
}
]
}
}
```
#### Supported variables
Just like `gemini-extension.json` , the `hooks/hooks.json` file supports
[variable substitution ](#variables ). This is particularly useful for referencing
scripts within the extension directory using `${extensionPath}` .
2025-09-09 16:59:18 -04:00
### Conflict resolution
2025-07-28 18:40:47 -07:00
2025-10-09 08:17:37 -04:00
Extension commands have the lowest precedence. When a conflict occurs with user
or project commands:
2025-07-28 18:40:47 -07:00
1. **No conflict ** : Extension command uses its natural name (e.g., `/deploy` )
2025-10-09 08:17:37 -04:00
2. **With conflict ** : Extension command is renamed with the extension prefix
(e.g., `/gcp.deploy` )
2025-07-28 18:40:47 -07:00
For example, if both a user and the `gcp` extension define a `deploy` command:
- `/deploy` - Executes the user's deploy command
2025-10-09 08:17:37 -04:00
- `/gcp.deploy` - Executes the extension's deploy command (marked with `[gcp]`
tag)
2025-08-25 17:02:10 +00:00
2026-01-07 15:46:44 -05:00
### Variables
2025-08-26 02:13:16 +00:00
2026-01-07 15:46:44 -05:00
Gemini CLI extensions allow variable substitution in both
`gemini-extension.json` and `hooks/hooks.json` . This can be useful if e.g., you
need the current directory to run an MCP server or hook script using
`"cwd": "${extensionPath}${/}run.ts"` .
2025-08-26 02:13:16 +00:00
**Supported variables:**
| variable | description |
| -------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `${extensionPath}` | The fully-qualified path of the extension in the user's filesystem e.g., '/Users/username/.gemini/extensions/example-extension'. This will not unwrap symlinks. |
2025-09-17 04:23:12 +00:00
| `${workspacePath}` | The fully-qualified path of the current workspace. |
2025-08-26 02:13:16 +00:00
| `${/} or ${pathSeparator}` | The path separator (differs per OS). |
2026-01-07 15:46:44 -05:00
| `${process.execPath}` | The path to the Node.js binary executing the CLI. |