GitLab CLI Skills
Comprehensive GitLab CLI (glab) command reference and workflows.
Quick start
CODEBLOCK0
Multi-agent identity note
When you want different agents to appear as different GitLab users, give each agent its own GitLab bot/service account. Multiple personal access tokens on the same GitLab user still act as that same visible identity.
Use the Actor identity for actor-authored GitLab comments, replies, approvals, and other writes. Use an agent identity only when the GitLab action is explicitly that agent's own work product. Choose the intended visible actor before the first GitLab write.
Treat shell identity as sticky and unsafe by default. If another env file was sourced earlier in the same shell/session, glab may still write as that previously loaded identity unless you deliberately switch and verify first.
A practical pattern is one env file per actor, for example ~/.config/openclaw/env/gitlab-actor.env, ~/.config/openclaw/env/gitlab-reviewer.env, and ~/.config/openclaw/env/gitlab-release.env. Keep these env files outside version control, restrict their permissions (for example chmod 600), be mindful of backup exposure, and use least-privilege bot/service-account tokens. In a reused shell, clear stale GitLab auth vars first or start a fresh shell. If those files use plain KEY=value lines, load them with exported vars before running glab:
CODEBLOCK1
Plain source updates the current shell but may not export variables to child processes such as glab. If the token/host vars are not exported, glab may silently fall back to shared stored auth from ~/.config/glab-cli/config.yml, which can make the wrong account appear to perform the action.
Required pre-flight before any GitLab write
Run this immediately before any GitLab write, including glab mr note, review replies/approvals, and any glab api POST/PATCH/PUT/DELETE call:
CODEBLOCK2
This assumes the target actor env file set GITLAB_HOST for the exact GitLab instance you intend to modify. Do not write until both commands clearly show the intended visible actor on that host.
Wrong-identity remediation
If a comment or reply was posted under the wrong identity:
- 1. Stop posting.
- Delete the mistaken comment or reply if cleanup is needed.
- INLINECODE18 or start a fresh shell.
- Source the correct env file with
set -a; source ...; set +a. - Rerun
glab auth status --hostname "$GITLAB_HOST" and glab api --hostname "$GITLAB_HOST" user. - Repost under the correct actor.
- Verify the thread no longer shows the wrong visible author for the replacement message.
If the wrong-identity write changed state beyond a comment or reply, do not treat the comment cleanup steps as sufficient. Re-auth as above, then use the matching GitLab reversal for that write under the correct actor and host, such as unapproving an MR or sending the compensating glab api --hostname "$GITLAB_HOST" mutation for the exact resource that was changed.
Skill organization
This skill routes to specialized sub-skills by GitLab domain:
Core Workflows:
- -
glab-mr - Merge requests: create, review, approve, merge - INLINECODE24 - Issues: create, list, update, close, comment
- INLINECODE25 - CI/CD: pipelines, jobs, logs, artifacts
- INLINECODE26 - Repositories: clone, create, fork, manage
Project Management:
- -
glab-milestone - Release planning and milestone tracking - INLINECODE28 - Sprint/iteration management
- INLINECODE29 - Label management and organization
- INLINECODE30 - Software releases and versioning
Authentication & Config:
- -
glab-auth - Login, logout, Docker registry auth - INLINECODE32 - CLI configuration and defaults
- INLINECODE33 - SSH key management
- INLINECODE34 - GPG keys for commit signing
- INLINECODE35 - Personal and project access tokens
- INLINECODE36 - Personal GitLab to-do triage and completion (added v1.92.0)
CI/CD Management:
- -
glab-job - Individual job operations - INLINECODE38 - Scheduled pipelines and cron jobs
- INLINECODE39 - CI/CD variables and secrets
- INLINECODE40 - Secure files for pipelines
- INLINECODE41 - Runner management: list, assign/unassign, inspect jobs/managers, pause/unpause, delete (added v1.87.0; expanded in v1.90.0)
- INLINECODE42 - Runner controller, scope, and token management (EXPERIMENTAL, admin-only)
Collaboration:
- -
glab-user - User profiles and information - INLINECODE44 - Code snippets (GitLab gists)
- INLINECODE45 - Incident management
- INLINECODE46 - Work items: tasks, OKRs, key results, next-gen epics (added v1.87.0)
Advanced:
- -
glab-api - Direct REST API calls - INLINECODE48 - Kubernetes cluster integration
- INLINECODE49 - Deploy keys for automation
- INLINECODE50 - GitLab slash command quick actions for batching state changes
- INLINECODE51 - Stacked/dependent merge requests
- INLINECODE52 - Terraform/OpenTofu state management
Utilities:
- -
glab-alias - Custom command aliases - INLINECODE54 - Shell autocompletion
- INLINECODE55 - Command help and documentation
- INLINECODE56 - Version information
- INLINECODE57 - Update checker
- INLINECODE58 - Changelog generation
- INLINECODE59 - Software supply chain security
- INLINECODE60 - GitLab Duo AI assistant
- INLINECODE61 - Model Context Protocol server for AI assistant integration (EXPERIMENTAL)
v1.92.0 Updates
Key user-facing changes in glab v1.92.0 that affect this skill set:
- -
glab-todo: adds glab todo list and glab todo done for personal to-do triage from the CLI. glab-auth: re-login now clears stale credentials when switching from OAuth to token auth; troubleshooting should prefer a fresh glab auth login when stored credentials appear stuck after auth-method changes.
v1.91.0 Updates
Key user-facing changes in glab v1.91.0 that affect this skill set:
- -
glab-api: adds multipart/form-data request support via --form for endpoints that expect file uploads or multipart fields. glab-auth: improves diagnostics when an exported env token fails authentication; troubleshooting should explicitly check env-token precedence before assuming stored login is broken.glab-duo: current user-facing surface is glab duo ask and glab duo cli; older glab duo update guidance is stale and should not be recommended.
v1.90.0 Updates
Key user-facing changes in glab v1.90.0 that affect this skill set:
- -
glab-auth: glab auth login adds --web, --container-registry-domains, and --ssh-hostname; CI auto-login is now GA. glab-mr: glab mr create adds --auto-merge; glab mr note now has list, resolve, and reopen subcommands in addition to note-posting flags.glab-runner: adds jobs, managers, and update --pause|--unpause.glab-runner-controller: adds get and shifts runner scope management under scope list|create|delete.
v1.89.0 Updates
v1.89.0+: 18 commands across 12 sub-skills now support --output json / -F json for structured output — raw GitLab API responses ideal for agent/automation parsing. Affected sub-skills: glab-release, glab-ci, glab-milestone, glab-schedule, glab-mr, glab-repo, glab-label, glab-deploy-key, glab-ssh-key, glab-gpg-key, glab-cluster, glab-opentofu.
Other v1.89.0 changes:
- -
glab-auth: glab auth login now prompts for SSH hostname separately from API hostname on self-hosted instances glab-stack: glab stack sync --update-base flag added to rebase stack onto updated base branchglab-release: --notes / --notes-file are now optional for glab release create and INLINECODE118
When to use glab vs web UI
Use glab when:
- - Automating GitLab operations in scripts
- Working in terminal-centric workflows
- Batch operations (multiple MRs/issues)
- Integration with other CLI tools
- CI/CD pipeline workflows
- Faster navigation without browser context switching
Use web UI when:
- - Complex diff review with inline comments
- Visual merge conflict resolution
- Configuring repo settings and permissions
- Advanced search/filtering across projects
- Reviewing security scanning results
- Managing group/instance-level settings
Common workflows
Daily development
CODEBLOCK3
Code review
CODEBLOCK4
CI/CD debugging
CODEBLOCK5
Decision Trees
"Should I create an MR or work on an issue first?"
CODEBLOCK6
Use glab issue create + glab mr for when:
- - Work needs discussion/approval before coding
- Tracking feature requests or bugs
- Sprint planning and assignment
- Want issue to auto-close when MR merges
Use glab mr create directly when:
- - Quick fixes or typos
- Working from existing issue
- Hotfixes or urgent changes
"Which CI command should I use?"
CODEBLOCK7
Quick reference:
- - Pipeline-level:
glab ci status, glab ci view, INLINECODE124 - Job-level:
glab ci trace, glab job retry, INLINECODE127 - Artifacts:
glab ci artifact (by pipeline) or job artifacts via INLINECODE129
"Clone or fork?"
CODEBLOCK8
Fork when:
- - You don't have write access to the original repo
- Contributing to open source projects
- Experimenting without affecting the original
- Need your own copy for long-term work
Clone when:
- - You're a project member with write access
- Working on organization/team repositories
- No need for a personal copy
"Project vs group labels?"
CODEBLOCK9
Group-level labels:
- - Consistent labeling across organization
- Examples: priority::high, type::bug, status::blocked
- Managed centrally, inherited by projects
Project-level labels:
- - Project-specific workflows
- Examples: needs-ux-review, deploy-to-staging
- Managed by project maintainers
Related Skills
MR and Issue workflows:
- - Start with
glab-issue to create/track work - Use
glab-mr to create MR that closes issue - Script:
scripts/create-mr-from-issue.sh automates this
CI/CD debugging:
- - Use
glab-ci for pipeline-level operations - Use
glab-job for individual job operations - Script:
scripts/ci-debug.sh for quick failure diagnosis
Repository operations:
- - Use
glab-repo for repository management - Use
glab-auth for authentication setup - Script:
scripts/sync-fork.sh for fork synchronization
Configuration:
- - Use
glab-auth for initial authentication - Use
glab-config to set defaults and preferences - Use
glab-alias for custom shortcuts
GitLab CLI 技能
全面的 GitLab CLI (glab) 命令参考和工作流程。
快速入门
bash
首次设置
glab auth login
常用操作
glab mr create --fill # 从当前分支创建合并请求
glab issue create # 创建议题
glab ci view # 查看流水线状态
glab repo view --web # 在浏览器中打开仓库
多智能体身份说明
当您希望不同的智能体以不同的 GitLab 用户身份出现时,请为每个智能体分配其自己的 GitLab 机器人/服务账户。同一 GitLab 用户下的多个个人访问令牌仍将显示为同一可见身份。
对于由操作者撰写的 GitLab 评论、回复、批准及其他写入操作,请使用操作者身份。仅当 GitLab 操作明确是该智能体自己的工作成果时,才使用智能体身份。在首次 GitLab 写入操作之前选择预期的可见操作者。
默认情况下,将 shell 身份视为具有粘性且不安全。如果在同一 shell/会话中之前已加载了其他环境文件,glab 可能会继续使用之前加载的身份进行写入,除非您有意切换并先进行验证。
一个实用的模式是为每个操作者创建一个环境文件,例如 ~/.config/openclaw/env/gitlab-actor.env、~/.config/openclaw/env/gitlab-reviewer.env 和 ~/.config/openclaw/env/gitlab-release.env。将这些环境文件置于版本控制之外,限制其权限(例如 chmod 600),注意备份暴露风险,并使用最小权限的机器人/服务账户令牌。在重复使用的 shell 中,先清除过期的 GitLab 认证变量,或启动一个新的 shell。如果这些文件使用简单的 KEY=value 行格式,请在运行 glab 之前使用导出的变量加载它们:
bash
unset GITLABTOKEN GITLABACCESSTOKEN OAUTHTOKEN GITLAB_HOST
set -a
source ~/.config/openclaw/env/gitlab-.env
set +a
简单的 source 会更新当前 shell,但可能不会将变量导出到子进程(如 glab)。如果令牌/主机变量未导出,glab 可能会静默回退到 ~/.config/glab-cli/config.yml 中共享的已存储认证,这可能导致错误的账户执行操作。
任何 GitLab 写入前的必要检查
在任何 GitLab 写入操作之前立即运行以下命令,包括 glab mr note、审查回复/批准以及任何 glab api 的 POST/PATCH/PUT/DELETE 调用:
bash
glab auth status --hostname $GITLAB_HOST
glab api --hostname $GITLAB_HOST user
这假设目标操作者的环境文件已为要修改的确切 GitLab 实例设置了 GITLAB_HOST。在两个命令都明确显示该主机上预期的可见操作者之前,不要进行写入。
错误身份修复
如果评论或回复以错误身份发布:
- 1. 停止发布。
- 如果需要清理,删除错误的评论或回复。
- unset GITLABTOKEN GITLABACCESSTOKEN OAUTHTOKEN GITLABHOST 或启动一个新的 shell。
- 使用 set -a; source ...; set +a 加载正确的环境文件。
- 重新运行 glab auth status --hostname $GITLABHOST 和 glab api --hostname $GITLAB_HOST user。
- 以正确的操作者身份重新发布。
- 验证该线程不再显示替换消息的错误可见作者。
如果错误身份的写入更改了评论或回复之外的状态,请不要认为评论清理步骤就足够了。按上述步骤重新认证,然后使用匹配的 GitLab 撤销操作,在正确的操作者和主机下对该写入进行撤销,例如取消批准 MR 或为被更改的确切资源发送补偿性的 glab api --hostname $GITLAB_HOST 变更。
技能组织
本技能按 GitLab 领域路由到专业子技能:
核心工作流程:
- - glab-mr - 合并请求:创建、审查、批准、合并
- glab-issue - 议题:创建、列出、更新、关闭、评论
- glab-ci - CI/CD:流水线、作业、日志、制品
- glab-repo - 仓库:克隆、创建、复刻、管理
项目管理:
- - glab-milestone - 发布规划和里程碑跟踪
- glab-iteration - 冲刺/迭代管理
- glab-label - 标签管理和组织
- glab-release - 软件发布和版本管理
认证与配置:
- - glab-auth - 登录、登出、Docker 注册表认证
- glab-config - CLI 配置和默认值
- glab-ssh-key - SSH 密钥管理
- glab-gpg-key - 用于提交签名的 GPG 密钥
- glab-token - 个人和项目访问令牌
- glab-todo - 个人 GitLab 待办事项分类和完成(v1.92.0 新增)
CI/CD 管理:
- - glab-job - 单个作业操作
- glab-schedule - 定时流水线和定时任务
- glab-variable - CI/CD 变量和密钥
- glab-securefile - 流水线安全文件
- glab-runner - 运行器管理:列出、分配/取消分配、检查作业/管理器、暂停/恢复、删除(v1.87.0 新增;v1.90.0 扩展)
- glab-runner-controller - 运行器控制器、范围和令牌管理(实验性,仅管理员)
协作:
- - glab-user - 用户资料和信息
- glab-snippet - 代码片段(GitLab Gist)
- glab-incident - 事件管理
- glab-workitems - 工作项:任务、OKR、关键结果、下一代史诗(v1.87.0 新增)
高级:
- - glab-api - 直接 REST API 调用
- glab-cluster - Kubernetes 集群集成
- glab-deploy-key - 自动化部署密钥
- glab-quick-actions - GitLab 斜杠命令快速操作,用于批量状态变更
- glab-stack - 堆叠/依赖合并请求
- glab-opentofu - Terraform/OpenTofu 状态管理
实用工具:
- - glab-alias - 自定义命令别名
- glab-completion - Shell 自动补全
- glab-help - 命令帮助和文档
- glab-version - 版本信息
- glab-check-update - 更新检查器
- glab-changelog - 变更日志生成
- glab-attestation - 软件供应链安全
- glab-duo - GitLab Duo AI 助手
- glab-mcp - 用于 AI 助手集成的模型上下文协议服务器(实验性)
v1.92.0 更新
glab v1.92.0 中影响本技能集的关键面向用户变更:
- - glab-todo:新增 glab todo list 和 glab todo done,用于从 CLI 进行个人待办事项分类。
- glab-auth:重新登录时,从 OAuth 切换到令牌认证时现在会清除过期的凭据;当存储的凭据在认证方式变更后似乎卡住时,故障排除应优先使用全新的 glab auth login。
v1.91.0 更新
glab v1.91.0 中影响本技能集的关键面向用户变更:
- - glab-api:通过 --form 新增对 multipart/form-data 请求的支持,适用于需要文件上传或多部分字段的端点。
- glab-auth:改进了当导出的环境令牌认证失败时的诊断信息;故障排除应首先明确检查环境令牌优先级,然后再假设存储的登录已损坏。
- glab-duo:当前面向用户的界面是 glab duo ask 和 glab duo cli;旧的 glab duo update 指南已过时,不应再推荐。
v1.90.0 更新
glab v1.90.0 中影响本技能集的关键面向用户变更:
- - glab-auth:glab auth login 新增 --web、--container-registry-domains 和 --ssh-hostname;CI 自动登录现已正式发布。