doc/user/gitlab_duo_cli/_index.md
{{< details >}}
{{< /details >}}
{{< collapsible title="Model information" >}}
{{< /collapsible >}}
{{< history >}}
glab 1.87.0, during the GitLab 18.9 release.{{< /history >}}
The GitLab Duo CLI is a command-line interface tool that brings GitLab Duo Agentic Chat to your terminal. Available for use with any operating system and editor, use the CLI to ask complex questions about your codebase and to autonomously perform actions on your behalf.
The GitLab Duo CLI can help you:
The GitLab Duo CLI offers two modes:
It also supports custom instructions set for
the GitLab Duo Agent Platform, including chat-rules.md, AGENTS.md, and SKILL.md files.
You can use the GitLab Duo CLI through the GitLab CLI (glab). With the GitLab CLI, you get access to other GitLab features and you only need to authenticate once, using OAuth and or a personal access token.
Alternatively, you can install and use the GitLab Duo CLI (duo) as a standalone AI tool, authenticating
separately with a personal access token.
Both setups support interactive and headless modes, along with all GitLab Duo CLI options, commands and functionality.
Prerequisites:
To set up the GitLab Duo CLI for use through the GitLab CLI:
Run the glab command for the GitLab Duo CLI:
glab duo cli
Follow the prompts to install the GitLab Duo CLI binary.
The GitLab CLI automatically handles authentication, so you can start using the GitLab Duo CLI immediately.
To use the GitLab Duo CLI as a standalone tool, install it and then authenticate.
Install the GitLab Duo CLI as an npm package or compiled binary.
{{< tabs >}}
{{< tab title="npm package" >}}
Prerequisites:
To install the GitLab Duo CLI as an npm package, run:
npm install --global @gitlab/duo-cli
{{< /tab >}}
{{< tab title="Compiled binary" >}}
To install the GitLab Duo CLI as a compiled binary, download and run the install script.
On macOS and Linux:
bash <(curl --fail --silent --show-error --location "https://gitlab.com/gitlab-org/editor-extensions/gitlab-lsp/-/raw/main/packages/cli/scripts/install_duo_cli.sh")
On Windows:
irm "https://gitlab.com/gitlab-org/editor-extensions/gitlab-lsp/-/raw/main/packages/cli/scripts/install_duo_cli.ps1" | iex
{{< /tab >}}
{{< /tabs >}}
[!note] If
glabis already installed and authenticated on your system when you first runduo,duoautomatically usesglabas a credential helper. You do not need to authenticate separately. This requiresglab1.85.2 or later andduo8.68.0 or later.If you authenticated
duobefore this feature was available and want to useglabas a credential helper instead, delete your authentication settings from~/.gitlab/storage.json.
Prerequisites:
api permissions.To authenticate:
duo in your terminal. The first time you run the GitLab Duo CLI, a configuration screen
appears.https://gitlab.com.duo in your terminal.To modify the configuration after initial setup, use duo config edit.
Prerequisites:
api permissions.To authenticate with environment variables:
Set GITLAB_TOKEN or GITLAB_OAUTH_TOKEN to your personal access token.
export GITLAB_TOKEN="<your-personal-access-token>"
Optional. Set GITLAB_BASE_URL or GITLAB_URL to your custom GitLab instance URL, for example https://gitlab.example.com. The default is https://gitlab.com.
export GITLAB_BASE_URL="<your-instance-url>"
This method is useful for headless mode, CI/CD pipelines, and scripted workflows where interactive authentication is not possible.
Prerequisites:
To use the GitLab Duo CLI in interactive mode:
Based on your setup, enter the command to start interactive mode:
{{< tabs >}}
{{< tab title="glab" >}}
glab duo cli
{{< /tab >}}
{{< tab title="duo" >}}
duo
{{< /tab >}}
{{< /tabs >}}
The prompt > appears in your terminal window. After the prompt, enter your question or
request and press <kbd>Enter</kbd>.
For example:
What is this repository about?
Which issues need my attention?
Help me implement issue 15.
The pipelines in MR 23 are failing. Please help me fix them.
To cancel a response while the GitLab Duo CLI is working, press <kbd>Escape</kbd>. The GitLab Duo CLI stops the current operation and returns to the prompt.
Use the <kbd>↑</kbd> key to view your prompt history, or <kbd>Control</kbd>+<kbd>R</kbd> to search it.
In interactive mode, you can switch the GitLab Duo CLI between two modes as you work:
| Mode | Permissions | How it works |
|---|---|---|
| Build mode (default) | Read-write | GitLab Duo can execute tasks and make changes to your project. |
| Plan mode | Read-only | GitLab Duo can analyze your project and create plans without making changes. |
For example, start by discussing a problem with GitLab Duo in plan mode. When you're ready, switch to build mode and instruct GitLab Duo to implement the plan.
The GitLab Duo CLI displays the current mode under the > prompt. To switch between modes, press
<kbd>Tab</kbd>.
In interactive mode, use slash commands to configure the GitLab Duo CLI and perform actions. Enter a slash command at the prompt and press <kbd>Enter</kbd>.
The following slash commands are available:
| Command | Description |
|---|---|
/copy | Copy the last GitLab Duo response to the clipboard. |
/feedback | Submit a bug report or feature request. |
/help | Display a list of available slash commands. |
/model | Switch the AI model for the current session. |
/new | Start a new chat session. |
/sessions | Browse, search, and switch sessions. |
[!caution] Use headless mode with caution and in a controlled sandbox environment.
To run a workflow in non-interactive mode, use the command for your setup:
{{< tabs >}}
{{< tab title="glab" >}}
Use glab duo cli run:
glab duo cli run --goal "Your goal or prompt here"
For example, you can run an ESLint command and pipe errors to the GitLab Duo CLI to resolve:
glab duo cli run --goal "Fix these errors: $eslint_output"
{{< /tab >}}
{{< tab title="duo" >}}
Use duo run:
duo run --goal "Your goal or prompt here"
For example, you can run an ESLint command and pipe errors to the GitLab Duo CLI to resolve:
duo run --goal "Fix these errors: $eslint_output"
{{< /tab >}}
{{< /tabs >}}
When you use headless mode, the GitLab Duo CLI:
run command.You can select a model for interactive mode or headless mode.
The model you select persists across sessions, and you can switch models mid-conversation without losing context.
Prerequisites:
To select a model for interactive mode:
/model and press <kbd>Enter</kbd>.The model you select does not persist across sessions.
Prerequisites:
To select a model for headless mode:
Find the gitlab_identifier for the model.
When you run the GitLab Duo CLI, set the --model option or the GITLAB_DUO_MODEL environment
variable to the gitlab_identifier value.
{{< tabs >}}
{{< tab title="glab" >}}
Use the --model option:
glab duo cli --model <gitlab_identifier_for_the_model>
Use the GITLAB_DUO_MODEL environment variable:
GITLAB_DUO_MODEL=<gitlab_identifier_for_the_model> glab duo cli
For example, to use GPT-5-Codex - OpenAI:
glab duo cli --model gpt_5_codex
GITLAB_DUO_MODEL=gpt_5_codex glab duo cli
{{< /tab >}}
{{< tab title="duo" >}}
Use the --model option:
duo --model <gitlab_identifier_for_the_model>
Use the GITLAB_DUO_MODEL environment variable:
GITLAB_DUO_MODEL=<gitlab_identifier_for_the_model> duo
For example, to use GPT-5-Codex - OpenAI:
duo --model gpt_5_codex
GITLAB_DUO_MODEL=gpt_5_codex duo
{{< /tab >}}
{{< /tabs >}}
GitLab Duo Chat sessions store your conversation history and workflow data, and are shared across the GitLab Duo CLI, the GitLab UI, and editor extensions.
For example, you can start a conversation in your browser and continue it in your terminal.
To browse and switch to a session:
/sessions and press <kbd>Enter</kbd>.To switch to a session in headless mode, use the --existing-session-id option.
To connect the GitLab Duo CLI to local or remote MCP servers, use the same MCP configuration as the GitLab IDE extensions. For instructions, see configure MCP servers.
The GitLab Duo CLI supports these options:
-C, --cwd <path>: Change the working directory.-h, --help : Display help for the GitLab Duo CLI or a specific command. For example, duo --help or
duo run --help.--log-level <level>: Set the logging level (debug, info, warn, error).-v, --version: Display version information.--model <model>: Select the AI model to use for the session.Additional options for headless mode:
--ai-context-items <contextItems>: JSON-encoded array of additional context items for reference.--existing-session-id <sessionId>: ID of an existing session to resume.--gitlab-auth-token <token>: Authentication token for a GitLab instance.--gitlab-base-url <url>: Base URL of a GitLab instance (default: https://gitlab.com).The following commands are available for each setup:
{{< tabs >}}
{{< tab title="glab" >}}
glab duo cli: Start interactive mode.glab duo cli log: View and manage logs.
glab duo cli log last: Open the last log file.glab duo cli log list: List all log files.glab duo cli log tail <args...>: Display the tail of the last log file.
Supports standard tail arguments.glab duo cli log clear: Remove all existing log files.glab duo cli run: Start headless mode.{{< /tab >}}
{{< tab title="duo" >}}
duo: Start interactive mode.duo config: Manage the configuration and authentication settings.duo log: View and manage logs.
duo log last: Open the last log file.duo log list: List all log files.duo log tail <args...>: Display the tail of the last log file.
Supports standard tail arguments.duo log clear: Remove all existing log files.duo run: Start headless mode.{{< /tab >}}
{{< /tabs >}}
You can configure the GitLab Duo CLI using environment variables:
DUO_WORKFLOW_GIT_HTTP_PASSWORD: Git HTTP authentication password.DUO_WORKFLOW_GIT_HTTP_USER: Git HTTP authentication username.GITLAB_BASE_URL or GITLAB_URL: GitLab instance URL.GITLAB_DUO_MODEL: AI model to use for the session.GITLAB_OAUTH_TOKEN or GITLAB_TOKEN: Authentication token.LOG_LEVEL: Logging level.If your network uses an HTTPS-intercepting proxy or requires custom SSL certificates, you might need additional configuration.
The GitLab Duo CLI respects standard proxy environment variables:
HTTP_PROXY or http_proxy: Proxy URL for HTTP requests.HTTPS_PROXY or https_proxy: Proxy URL for HTTPS requests.NO_PROXY or no_proxy: Comma-separated list of hosts to exclude from proxying.If your organization uses a custom Certificate Authority (CA), for an HTTPS-intercepting proxy or similar, you might encounter certificate errors.
Error: unable to verify the first certificate
Error: self-signed certificate in certificate chain
To resolve certificate errors, use one of the following methods:
Use the system certificate store (recommended):
export NODE_OPTIONS="--use-system-ca"
Specify a CA certificate file:
export NODE_EXTRA_CA_CERTS=/path/to/custom-ca.pem
If you still encounter certificate errors, you can disable certificate verification.
[!warning] Disabling certificate verification is a security risk. You should not disable verification in production environments.
Certificate errors alert you to potential security breaches, so you should disable certificate verification only when you are confident that it is safe to do so.
Prerequisites:
To disable certificate verification:
export NODE_TLS_REJECT_UNAUTHORIZED=0
To manually update the GitLab Duo CLI to the latest version, run the command for your setup:
{{< tabs >}}
{{< tab title="glab" >}}
glab duo cli --update
{{< /tab >}}
{{< tab title="duo" >}}
npm install --global @gitlab/duo-cli@latest
{{< /tab >}}
{{< /tabs >}}
For information on contributing to the GitLab Duo CLI, see the development guide.