GitLab Duo CLI: the glab commands I use for code review
My June 2026 Duo CLI review workflow, with an October 8 update covering versions, namespace access, model identifiers, Credits billing, and headless tool approvals.
Contents
Disclosure: I'm a GitLab Community Contributor and had a Duo Enterprise seat through the contributor program. I'm not a GitLab employee. This post keeps my June 2026 experience and updates the operating and billing notes as of October 8, 2026; the source of my seat does not mean every reader needs that add-on.
It Started with an Accidental Discovery
For a long time I only used GitLab Duo Chat on the web. The chat box on MR pages, asking it "what does this code do" or "write me a commit message." Useful enough, but nothing special.
Then one day I needed to review several modules at once, and clicking through the web UI one question at a time was painfully slow. I dug through the glab docs and found glab duo cli run. Tried it. Immediately thought: this is how it's meant to be used.
The biggest difference from the web version? You can script it. AI analysis becomes a repeatable process, so you stop sitting in front of a browser going back and forth.
CLI and web sessions are synced, which I did not expect. You can start a conversation on the web, then pick it up in the terminal with the /sessions command. Or the other way around. IDE extensions too. Three entry points, one conversation.
Your First Duo CLI Command
October 8, 2026 update: versions and namespace
The current setup guide requires glab 1.107.0 or later and authentication with glab auth login. Duo CLI is generally available on GitLab 19.2 and later; instances on 18.11 through 19.1 need beta and experimental features enabled. The first glab duo cli launch prompts you to install the Duo CLI binary. The two tools have separate versions.
Access follows the Agent Platform prerequisites: enable GitLab Duo and the Agent Platform, and enable Duo Core if you do not have Duo Pro or Enterprise. Self-Managed and Dedicated instances must also allow Duo CLI access. The CLI setup page currently lists Premium and Ultimate; support for some Agent Platform features on Free is not proof that the CLI is available on every tier.
Set a default GitLab Duo namespace in Preferences → Behavior → Default GitLab Duo group, or start from a project with Duo access. The CLI checks the project remote's namespace before your personal default. If the first resolved namespace lacks access or Credits, it does not fall back to the next one. -C changes the working directory; it does not grant access.
The examples below have been updated from official documentation. This refresh did not run tasks that consume Credits.
Interactive and headless modes
Once those prerequisites are met, Duo CLI has two modes:
Interactive mode opens an AI chat session in your terminal:
glab duo cli
Once inside, just type your questions. Use /model to switch models, /sessions to list previous conversations (including ones from the web UI or IDE), /new to start fresh.
Headless mode is for scripts and runs to completion:
glab duo cli run -C ~/my-project --goal "Summarize the architecture of this project in three sentences"
-C points to the repo. --goal is your instruction. It runs, prints the result, done.
My first reaction: "Oh, this is what I wanted." Output right in the terminal, ready to pipe, redirect, or feed into other tools. And since sessions sync to the web, I can always continue asking follow-up questions in the GitLab UI afterward without starting over.
Switching Models Changed Everything
When I used web Chat then, I rarely checked the underlying model. The CLI's --model flag got me fixing the model and comparing the same task. Web Agentic Chat now also supports model selection; that capability is no longer unique to the CLI.
This seems minor. It's not.
The original post records a review task run against 9 models. These are a few of those results. It does not record the test date, complete prompt, or each run's output, so this is not a ranking of today's models:
- Claude Opus 4.6 returned 10.2 KB: the most thorough, covering every angle. Great when you want the full picture.
- Claude Opus 4.7 returned 5.9 KB: concise and focused on key points. Good when you roughly know the situation and just want confirmation.
- Gemini 3.5 Flash returned 4.4 KB: fastest response, but shallower. Good for a quick scan.
- GPT 5.4 returned 0.3 KB and refused on that run; GPT 5.5 answered the same task. One refusal does not establish how the model's safety settings behave in general.
The listed non-refusal outputs range from 4.4 KB to 10.2 KB, about 2.3x; the 0.3 KB refusal is excluded from that comparison. Output length is not finding accuracy, and one task cannot establish model quality.
My habit then was to run at least two models for an important review, cross-compare, and verify each finding. That adds calls. Being billed in Credits does not make those calls cost the same.
The --model value must be GitLab's gitlab_identifier, not a provider API model name. These identifiers come from the official model registry, checked on October 8, 2026. Availability still depends on your instance and group settings; /model shows the choices in interactive mode.
# Same task, different models
glab duo cli run -C ~/project --goal "review error handling" --model claude_opus_4_6_20260205
glab duo cli run -C ~/project --goal "review error handling" --model claude_opus_4_7
glab duo cli run -C ~/project --goal "review error handling" --model gemini_3_5_flash_vertex
My Daily Workflow
The daily workflow recorded in the original post combined several AI CLI tools:
Duo CLI was my breadth tool. Multi-model switching was convenient, and the usage allocation I had then made batch screening practical for me. I split a large repo into modules and analyzed each, often with different models for cross-validation. Those were my access conditions, not evidence that an Enterprise seat makes it cheaper than other tools.
Claude Code is my depth tool. When Duo flags something as "this might be an issue," I hand it to Claude Code for deep analysis. It has cross-session memory, which helps for problems that need several rounds of back-and-forth.
Neither one replaces the other. They cover different ground. Duo CLI scans the landscape and flags suspicious spots. Claude Code digs into those spots. One does breadth, the other does depth.
A Trick That Made a Real Difference
Asking AI to "review this repo" cold isn't great. It'll wander through the file tree and git history on its own, not knowing what matters and what doesn't.
What I do instead: run git log first to find relevant commits, then feed the results into the prompt:
# Find relevant commits first
git log --all --grep='refactor\|fix\|validate' \
--regexp-ignore-case --name-only \
--format='%H %cs %s' > anchors.txt
# Feed commit history as context
glab duo cli run -C ~/project \
--goal "Here's the recent commit history related to this area:
$(cat anchors.txt)
Based on these commits, is the refactoring direction consistent?
Are any modules being left behind?"
Why does this work so well? Because the AI now has concrete anchors: it knows which files changed, when, and why. Analysis stays focused on meaningful scope instead of wandering aimlessly.
This technique works especially well for tech debt assessment. Grep for TODOs, FIXMEs, and HACKs in your commit history, feed it to Duo, and ask it to analyze the distribution and severity. Way more precise than letting the AI hunt on its own.
Teaching the AI to Filter Its Own Noise
A common pain point with AI analysis: it reports a ton of findings, most of which are noise. You spend time running the analysis, then spend even more time manually filtering.
A simple fix I've learned: append validation criteria to your prompt so the AI self-screens before reporting.
glab duo cli run -C ~/project \
--goal "Check the error handling in this module.
Before reporting each finding, self-check:
1. Does this issue exist under default configuration?
2. Is there already an existing mechanism handling this?
3. Does the impact extend beyond normal usage?
Mark anything that fails as 'not applicable' with an explanation."
The original post records one task that went from 21 findings to 2 after adding validation criteria. That is about a 90% reduction in report count, not a 90% reduction in false positives. Removed findings could include misses, and the 2 remaining findings still need verification. This update did not rerun that comparison.
Things I've Learned the Hard Way
Headless runs are fresh sessions. Each glab duo cli run starts clean. But you can use --existing-session-id to continue a previous session, or switch to interactive mode and use /sessions to find prior conversations. You can also inject files as context with --ai-context-items.
October 8, 2026 update: separate Credits from seats. The billing guide separates Agent Platform usage billing from the seat-based Duo Pro and Enterprise features. Models have different credit multipliers, and a task can make multiple LLM calls. Community subscriptions do not receive included credits. Before a batch, check the namespace balance, usage caps, and on-demand settings; my contributor access does not predict your cost.
Model quality varies wildly. Same task, same prompt, and responses can differ by more than 2x. Don't draw conclusions from a single model's output on anything important.
October 8, 2026 update: headless already auto-approves tools. The headless documentation says run automatically approves tools, so a batch does not need an additional --dangerously-skip-permissions flag. Removing the flag does not make the run read-only. Use a disposable working copy and a controlled sandbox without production credentials, then inspect the diff. A prompt saying “review only” is not an execution boundary. Interactive plan/build modes and tool approvals are separate from run.
Wrapping Up
I first treated GitLab Duo as a web chat box. Finding the CLI entry point let me connect it to my review workflow: repeatable, automatable, comparable analysis.
As a community maintainer, this is the daily review workflow I recorded in the original post. It won't replace your judgment, but it saves a massive amount of "first pass" time so you can focus your energy on the parts that actually require thinking.
If you're already on GitLab, glab duo cli run is worth a try. You might find, like I did, that once you go CLI, the web chat feels like going back to a flip phone.
I put the batch scripts and timeout handling in GitLab Duo CLI advanced patterns, along with how I compare models and filter findings.