This article follows the official documentation. We haven’t tested this tool for a hands-on review.
When a coding agent can run shell commands in a local copy of a GitLab repository, it can use GitLab CLI (glab) to read issues, merge requests, and pipeline information. The CLI sends requests to GitLab through your configured account, so the agent can inspect project data without you copying it into the prompt.
glab is a command-line client, not a coding agent. Install it and sign in, then ask your agent to run specific commands. For example, the agent can list issues in the current project and summarize the work they describe. The GitLab CLI documentation documents its commands and supported GitLab services.
Install and authenticate
On macOS with Homebrew, install glab with:
brew install glab
For other platforms, use the installation options in the CLI repository. GitLab CLI supports GitLab.com, GitLab Dedicated, and GitLab Self-Managed. Check the installed CLI and your GitLab version when a command is unavailable.
Sign in before asking an agent to access private project data:
glab auth login
For GitLab.com, the interactive login can open a browser so you can authorize access. Complete the sign-in yourself in the terminal and browser. Do not put an access token or other credential in an agent prompt. After you configure glab, an agent that runs shell commands can use your sign-in when it runs CLI commands.
List issues from a checkout
You can ask an agent to inspect the current project's issues without changing them. In a terminal, go to a local Git checkout that has a GitLab remote, then run:
glab issue list --per-page 20 --output json
glab contacts GitLab to list issues for the project linked to the checkout. glab detects the GitLab host from the checkout’s remotes when you have signed in to an account for that host. The command reads project data; it does not create or edit issues. The issue-list reference documents --per-page and --output json. This command returns one page of up to 20 open issues. The agent can read the JSON and summarize the relevant titles.
A realistic prompt for this task is:
Run
glab issue list --per-page 20 --output jsonin the current repository. Summarize the issues shown that relate to the failing test suite. Do not create, edit, or close any issues.
The agent runs the shell command, reads GitLab's response, and summarizes the returned issue list. This example does not assume a particular issue exists or claim a specific result.
Keep project and host context clear
glab commands use the form glab <command> <subcommand> [flags]. For example, glab issue list reads issues, while commands under glab mr manage merge requests and commands under glab ci work with pipelines. A command that creates or edits a GitLab object sends a request that changes data on GitLab. The issue-list command above only reads data.
If you work with several GitLab instances, check which host the checkout points to before an agent runs a command. The configuration documentation explains settings for the whole system, a user, a repository, or a host. It also says that environment variables override values in the configuration file and apply across hosts. If you use several GitLab hosts, configure each one in the file instead of relying on an environment variable that applies to all of them.