| name | glab-cli |
| description | Manage GitLab merge requests, issues, and pipelines from the command line using the glab CLI. Use when the user asks about GitLab MRs, issues, pipelines, labels, milestones, or needs to manage project work items via the command line. |
GitLab CLI (glab)
Interact with GitLab from the command line using glab.
When to Use
- User asks to create, view, edit, or search GitLab merge requests
- User needs to manage GitLab issues, labels, or milestones
- User wants to trigger, view, or retry CI/CD pipelines
- User needs to manage releases or changelogs
- User needs to resolve or reply to MR review comments/threads
- MCP tools (
mcp_gitlab_*) are unavailable or failing
- User needs scripted/batch MR or issue operations
Prerequisites
- Install glab:
brew install glab (macOS) or see install instructions
- Authenticate:
glab auth login
- Verify:
glab auth status
Authentication
glab auth login
glab auth login --hostname gitlab.company.com
GITLAB_TOKEN=glpat-xxxx glab auth status
glab auth status
glab auth logout
Merge Request Commands
List MRs
glab mr list
glab mr list --assignee @me
glab mr list --state opened
glab mr list --state merged
glab mr list --state closed
glab mr list --label "bug,urgent"
glab mr list --target-branch main
glab mr list --limit 20
glab mr list --json number,title,state --limit 50
Create MRs
glab mr create --title "feat: add pagination" --description "Closes #88"
glab mr create \
--title "feat: add pagination" \
--description "Adds cursor-based pagination" \
--assignee @me \
--label "backend,enhancement" \
--target-branch main
glab mr create --fill
glab mr create --title "Fix auth" --reviewer user1,user2
glab mr create --title "WIP: experimental feature" --draft
glab mr create --title "Release feature" --milestone "v1.0"
View MRs
glab mr view 42
glab mr view 42 --comments
glab mr view 42 --json number,title,state,author,reviewers
glab mr view 42 --web
Edit MRs
glab mr update 42 --title "Updated title"
glab mr update 42 --label "priority:high"
glab mr update 42 --unlabel "needs-review"
glab mr update 42 --assignee @me
glab mr update 42 --milestone "v1.0"
glab mr update 42 --reviewer user1,user2
Merge & Close MRs
glab mr merge 42
glab mr merge 42 --when-pipeline-succeeds --delete-source-branch
glab mr merge 42 --squash
glab mr close 42
glab mr close 42 --comment "Superseded by !99"
glab mr reopen 42
MR Approvals
glab mr approve 42
glab mr unapprove 42
glab mr view 42 --json approvals
MR Review Threads
glab mr note list 42
glab mr note 42 --body "Looks good to me"
glab mr note 42 --body "Nice catch" --commit abc123 --filename src/main.ts --line 42
glab mr note resolve 42 <discussion-id>
glab mr note 42 --body "Fixed in commit def456"
Issue Commands
List Issues
glab issue list
glab issue list --state opened --label "bug"
glab issue list --assignee @me
glab issue list --search "authentication"
glab issue list --limit 20
glab issue list --json number,title,state --limit 50
Create Issues
glab issue create --title "Bug: Login fails" --description "Steps to reproduce..."
glab issue create \
--title "Add feature" \
--description "Details here" \
--label "enhancement" \
--assignee @me
glab issue create --title "Task" --description "Do this" --milestone "v1.0"
glab issue create --title "Complex task" --description "Details" --weight 3
View Issues
glab issue view 123
glab issue view 123 --comments
glab issue view 123 --json number,title,state,labels,assignees
glab issue view 123 --web
Edit Issues
glab issue update 123 --title "Updated title"
glab issue update 123 --add-label "priority:high"
glab issue update 123 --remove-label "needs-triage"
glab issue update 123 --milestone "v1.0"
glab issue update 123 --assignee @me
glab issue update 123 --weight 5
Close & Reopen Issues
glab issue close 123
glab issue close 123 --comment "Fixed in !456"
glab issue reopen 123
Issue Comments
glab issue note 123 --body "Working on this"
glab issue note 123 --body-file ./comment.md
Pipeline Commands
View Pipelines
glab pipeline list
glab pipeline view
glab pipeline status
glab pipeline view 123
glab pipeline status --wait
Trigger Pipelines
glab pipeline create
glab pipeline create --variable ENV=staging --variable DEBUG=true
glab pipeline retry 123
glab pipeline cancel 123
Pipeline Jobs
glab ci view
glab ci trace 123
glab ci retry 123
glab ci artifact 123
Validate CI Config
glab ci lint
Release Commands
glab release list
glab release create v1.0.0 \
--name "Version 1.0.0" \
--description "Initial stable release"
glab release create v1.0.0 --notes-file CHANGELOG.md
glab release view v1.0.0
glab release delete v1.0.0
Label Commands
glab label list
glab label create "priority:high" --color "#FF0000" --description "High priority"
glab label update "priority:high" --new-name "priority:critical" --color "#CC0000"
glab label delete "old-label"
Common Workflows
Triage New Issues
glab issue list --label none --assignee none
glab issue update 123 --add-label "bug,priority:high" --assignee @me
MR Review Workflow
glab mr checkout 42
git log main..HEAD
glab mr approve 42
Pipeline Debugging
glab pipeline status
glab ci trace <job-id>
glab ci retry <job-id>
Batch Operations
for id in 10 11 12; do glab issue close "$id" --comment "Superseded"; done
for mr in 10 11 12; do glab mr update "$mr" --add-label "backlog"; done
Common Flags
| Flag | Description |
|---|
--json | JSON output with field selection |
--limit | Max results to return |
--search | Search query |
--state | Filter by state (opened, closed, merged) |
--label | Filter by label |
--assignee | Filter by assignee |
--milestone | Filter by milestone |
-R, --repo | Override project (namespace/project) |
Output Formatting
| Command | Use Case |
|---|
glab mr list --json number,title | JSON for scripting |
glab mr list --json number,title --limit 10 | Limited JSON output |
glab issue view 123 --json state | Get issue state only |
Limitations
- Requires
glab auth login before first use
- Rate limits apply based on GitLab instance configuration
- Some commands require specific GitLab Premium/Ultimate features
- Pipeline commands may vary between GitLab.com and self-managed instances
- MR review threads use discussion API (not inline comments)