# GitLab Duo CLI (experimental)

GitLab Duo for your command line. An AI-powered CLI tool that brings
[GitLab Duo Chat (Agentic)](https://docs.gitlab.com/user/gitlab_duo_chat/agentic_chat/) to your
terminal.

The GitLab Duo CLI can help you:

- Understand your codebase structure, cross-file functionality, and individual code snippets.
- Build, modify, refactor, and modernize code.
- Troubleshoot errors and fix code issues.
- Automate CI/CD configuration, troubleshoot pipeline errors, and optimize pipelines.
- Perform multi-step development tasks autonomously.

This tool is [experimental](https://docs.gitlab.com/policy/development_stages_support/#experiment)
and some features might not work as expected.

## Installation

Prerequisites:

- Node.js 22 or later.
- A [personal access token](https://docs.gitlab.com/user/profile/personal_access_tokens/) with `api`
  scope.

To install the GitLab Duo CLI globally, run:

```shell
npm install -g @gitlab/duo-cli
```

### Alternative: Install using installation script

You can use the installation script to install the GitLab Duo CLI without Node.js:

#### macOS and Linux

```shell
bash <(curl -fsSL "https://gitlab.com/gitlab-org/editor-extensions/gitlab-lsp/-/raw/main/packages/cli/scripts/install_duo_cli.sh")
```

#### Windows

```shell
irm "https://gitlab.com/gitlab-org/editor-extensions/gitlab-lsp/-/raw/main/packages/cli/scripts/install_duo_cli.ps1" | iex
```

This script will:

1. Detect your platform (OS and architecture)
1. Download the appropriate GitLab Duo CLI binary
1. Install it to `~/.local/bin/duo`
1. Update your PATH if needed

For non-interactive installation (useful for CI/CD):

```shell
curl -fsSL https://gitlab.com/gitlab-org/editor-extensions/gitlab-lsp/-/raw/main/packages/cli/scripts/install_duo_cli.sh | bash -s -- -y
```

To install a specific version:

```shell
curl -fsSL https://gitlab.com/gitlab-org/editor-extensions/gitlab-lsp/-/raw/main/packages/cli/scripts/install_duo_cli.sh | bash -s -- --version 1.2.3
```

After installation, you can run the GitLab Duo CLI using the `duo` command.

### Updating

To update to the latest version:

```shell
npm install -g @gitlab/duo-cli@latest
```

## Usage

### Interactive Mode (TUI)

Start the interactive terminal UI:

```shell
duo
```

Alternatively, you can run the GitLab Duo CLI without installing:

```shell
npx -y @gitlab/duo-cli
```

To run a workflow in headless mode, use the command `duo run`:

> [!warning]
> Headless mode bypasses manual tool approval. Use this mode with caution and in a controlled
> sandbox environment.

```shell
duo run --goal "Your goal or prompt here"
```

## Documentation

For detailed setup, usage, troubleshooting, and configuration instructions, see the
[GitLab Duo CLI documentation](https://docs.gitlab.com/user/gitlab_duo_cli/).

## Contributing

See [Development Guide](./docs/development.md) for information on contributing to this project.

## License

See the [License](../../LICENSE) for details.
