gitlab
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseGitLab Skill
GitLab Skill
Use the CLI to interact with GitLab. The primary workflow is MR Review — but this skill handles any GitLab operation the user needs.
glab使用 CLI 与 GitLab 交互。核心工作流是 MR 评审,但本 skill 支持处理用户需要的任何 GitLab 操作。
glabURL Parsing
URL 解析
When given a GitLab MR URL like :
https://gitlab.com/group/subgroup/project/-/merge_requests/42- repo_ref: strip and everything from
https://onward →/-/gitlab.com/group/subgroup/project - mr_id: extract the number after →
merge_requests/42
These two values power most glab commands:
glab mr <cmd> <mr_id> --repo <repo_ref>当收到类似 的 GitLab MR URL 时:
https://gitlab.com/group/subgroup/project/-/merge_requests/42- repo_ref:去掉 以及
https://之后的所有内容 →/-/gitlab.com/group/subgroup/project - mr_id:提取 之后的数字 →
merge_requests/42
这两个值是大多数 glab 命令的核心参数:
glab mr <cmd> <mr_id> --repo <repo_ref>MR Review Workflow
MR 评审工作流
When the user asks to review a MR, run this pipeline:
1. Fetch MR info, diff, and existing comments
2. Read & summarize existing comments (understand what's already discussed)
3. code-reviewer + security + qa → review in PARALLEL (with comment context)
4. Compose Thai comment from template
5. Post comment to the MR当用户要求评审某个 MR 时,运行以下流程:
1. 拉取 MR 信息、diff 和已有评论
2. 阅读并总结已有评论(了解已经讨论过的内容)
3. code-reviewer + security + qa → 并行评审(传入评论上下文)
4. 基于模板撰写泰语评论
5. 将评论发布到对应 MRStep 1: Fetch
步骤 1:拉取信息
bash
glab mr view <mr_id> --repo <repo_ref> --output json
glab mr diff <mr_id> --repo <repo_ref>
glab mr note list <mr_id> --repo <repo_ref>Extract from the view output: MR title, source branch, target branch, author.
bash
glab mr view <mr_id> --repo <repo_ref> --output json
glab mr diff <mr_id> --repo <repo_ref>
glab mr note list <mr_id> --repo <repo_ref>从 view 命令的输出中提取:MR 标题、源分支、目标分支、作者。
Step 2: Read Existing Comments
步骤 2:读取已有评论
Before diving into the review, read through all existing MR comments/notes fetched in Step 1. This gives crucial context — other reviewers may have already flagged issues, the author may have explained design decisions, or there may be ongoing discussions that affect how you should review. Summarize the key points:
- Issues already raised by other reviewers
- Author's explanations or decisions
- Unresolved discussions that need attention
- Resolved items (avoid duplicating feedback)
This prevents the review from repeating what's already been said and helps focus on gaps that haven't been addressed yet.
在开始评审前,通读步骤 1 拉取到的所有 MR 已有评论/备注。这会提供关键上下文——其他评审者可能已经标记了问题,作者可能已经解释了设计决策,或者存在仍在进行中的讨论,这些都会影响你的评审方式。总结核心要点:
- 其他评审者已经提出的问题
- 作者的解释或决策
- 需要关注的未解决讨论
- 已解决项(避免重复反馈)
这可以避免评审内容重复已有讨论,帮助聚焦于还没有处理的空缺部分。
Step 3: Parallel Review
步骤 3:并行评审
Read the project's if available (for conventions). Then spawn all three agents at the same time, including a summary of existing comments so reviewers have full context:
CLAUDE.mdAgent(
description: "Code review MR diff",
subagent_type: "code-reviewer",
model: "opus",
prompt: """
[code-reviewer agent instructions — read from ~/.claude/agents/code-reviewer.agent.md]
---如果项目存在 则先读取(了解规范)。然后同时启动三个 Agent,传入已有评论的总结,让评审者获得完整上下文:
CLAUDE.mdAgent(
description: "Code review MR diff",
subagent_type: "code-reviewer",
model: "opus",
prompt: """
[code-reviewer agent 指令 — 读取自 ~/.claude/agents/code-reviewer.agent.md]
---Project Conventions
项目规范
[relevant sections from CLAUDE.md if available, else omit]
[如果存在 CLAUDE.md 则提取相关部分,否则省略]
Existing MR Comments
已有 MR 评论
[summary of existing comments from Step 2 — issues raised, author explanations, unresolved discussions]
Do NOT repeat issues that other reviewers have already flagged unless you have additional insight to add.
[步骤 2 得到的已有评论总结——提出的问题、作者解释、未解决讨论]
除非你有额外的见解补充,否则不要重复其他评审者已经标记过的问题。
Task
任务
Review the following MR diff for convention compliance.
MR: !<mr_id> — <mr_title>
Branch: <source> → <target>
评审以下 MR diff 是否符合规范。
MR: !<mr_id> — <mr_title>
分支: <source> → <target>
Diff
Diff
<full diff output>
"""
)
Agent(
description: "Security review MR diff",
subagent_type: "security",
model: "sonnet",
prompt: """
[security agent instructions — read from ~/.claude/agents/security.agent.md]
<完整 diff 输出>
"""
)
Agent(
description: "Security review MR diff",
subagent_type: "security",
model: "sonnet",
prompt: """
[security agent 指令 — 读取自 ~/.claude/agents/security.agent.md]
Existing MR Comments
已有 MR 评论
[summary of existing comments from Step 2 — issues raised, author explanations, unresolved discussions]
Do NOT repeat security concerns that have already been raised unless you have additional findings.
[步骤 2 得到的已有评论总结——提出的问题、作者解释、未解决讨论]
除非你有额外的发现,否则不要重复已经提出过的安全隐患。
Task
任务
Security review the following MR diff.
MR: !<mr_id> — <mr_title>
Branch: <source> → <target>
对以下 MR diff 进行安全评审。
MR: !<mr_id> — <mr_title>
分支: <source> → <target>
Diff
Diff
<full diff output>
"""
)
Agent(
description: "QA review MR diff",
subagent_type: "qa",
model: "sonnet",
prompt: """
[qa agent instructions — read from ~/.claude/agents/qa.agent.md]
<完整 diff 输出>
"""
)
Agent(
description: "QA review MR diff",
subagent_type: "qa",
model: "sonnet",
prompt: """
[qa agent 指令 — 读取自 ~/.claude/agents/qa.agent.md]
Project Conventions
项目规范
[relevant sections from CLAUDE.md if available, else omit]
[如果存在 CLAUDE.md 则提取相关部分,否则省略]
Existing MR Comments
已有 MR 评论
[summary of existing comments from Step 2 — issues raised, author explanations, unresolved discussions]
Do NOT repeat QA concerns that have already been raised unless you have additional findings.
[步骤 2 得到的已有评论总结——提出的问题、作者解释、未解决讨论]
除非你有额外的发现,否则不要重复已经提出过的 QA 相关问题。
Task
任务
QA review the following MR diff. Focus on:
- Test coverage gaps (are new code paths tested?)
- Missing edge case tests
- Regression risks
- Acceptance criteria validation (if available)
MR: !<mr_id> — <mr_title>
Branch: <source> → <target>
对以下 MR diff 进行 QA 评审。重点关注:
- 测试覆盖缺口(新代码路径是否有测试?)
- 缺失的边界 case 测试
- 回归风险
- 验收标准验证(如果有提供)
MR: !<mr_id> — <mr_title>
分支: <source> → <target>
Diff
Diff
<full diff output>
"""
)
```
Read the agent files from before spawning, so the full agent instructions are included in the prompt.
~/.claude/agents/<完整 diff 输出>
"""
)
在启动 Agent 前先从 `~/.claude/agents/` 读取对应 Agent 文件,确保完整的 Agent 指令都包含在提示词中。Step 4: Compose Thai comment
步骤 4:撰写泰语评论
Read references/mr-review-template.md and fill in findings from all three agents (code-reviewer, security, qa).
读取 references/mr-review-template.md,填入三个 Agent(code-reviewer、security、qa)的所有发现。
Step 5: Post
步骤 5:发布
bash
glab mr note <mr_id> --repo <repo_ref> -m "<thai_comment>"If is not authenticated or fails, output the review in the conversation instead and tell the user.
glabbash
glab mr note <mr_id> --repo <repo_ref> -m "<thai_comment>"如果 未认证或运行失败,则直接在对话中输出评审结果并告知用户。
glabCommon glab Operations
常用 glab 操作
Use these directly via when the user asks for something other than a full review:
Bash| Task | Command |
|---|---|
| List open MRs | |
| View MR details | |
| Approve MR | |
| Check pipeline status | |
| List pipelines | |
| Retry a job | |
| Add a note/comment | |
For , you can omit it if you're already inside the project directory (glab detects the remote automatically).
--repo当用户要求的不是完整评审时,直接通过 运行以下命令:
Bash| 任务 | 命令 |
|---|---|
| 列出打开的 MR | |
| 查看 MR 详情 | |
| 批准 MR | |
| 检查流水线状态 | |
| 列出流水线 | |
| 重试任务 | |
| 添加备注/评论 | |
对于 参数,如果你已经处于项目目录下可以省略(glab 会自动检测远程仓库)。
--repoError Handling
错误处理
- glab not authenticated: tell the user to run
glab auth login - glab command fails: output the review as conversation text instead of posting, explain what failed
- Empty diff: note that the MR has no file changes and skip the review agents
- Large diff (>500 lines): warn the user, proceed but note the review may miss details
- glab 未认证:告知用户运行
glab auth login - glab 命令运行失败:不在 MR 中发布评论,直接在对话中输出评审结果,解释失败原因
- 空 diff:标注该 MR 没有文件变更,跳过评审 Agent
- diff 过大(>500 行):警告用户,继续评审但标注可能会遗漏细节