glab-cli
GLab CLI
Use glab with host-aware defaults instead of hardcoding gitlab.com.
Workflow
Follow this order unless the user explicitly asks for a single command.
1. Let glab use the current context by default
Do not run host detection by default.
In a Git repository, prefer:
glab <command>
Only add GITLAB_HOST, --hostname, or -R when the task targets another repo or another instance, or when glab resolves the wrong context.
2. Detect the platform only when context is unclear or failing
Check git remote -v only when:
glabresolves to the wrong instance- auth checks fail against an unexpected host
- the repository has both GitHub and GitLab remotes
- multiple GitLab hosts are present
- the task targets a different instance than the current directory
Rules:
- Prefer a GitLab remote over any GitHub or Bitbucket remote.
- If the remote host is
gitlab.com, treat the platform asgitlab.com. - If the remote host is anything else, treat the platform as
self-managed-or-dedicated. - If multiple GitLab hosts appear in
git remote -v, treat the result as ambiguous and confirm before any write operation. - If
GITLAB_HOSTis already set, let it override the remote-derived host.
If git remote -v does not show a GitLab remote:
- check whether the user is in the intended repository
- ask for the GitLab host or repository URL only if the task is otherwise blocked
- avoid guessing
gitlab.comfor a private installation
If multiple GitLab hosts are present in git remote -v, do not silently pick one for write operations. Confirm the target or set GITLAB_HOST explicitly first.
3. Reuse explicit context only when needed
For repository-scoped commands, prefer one of these patterns:
glab <command>
GITLAB_HOST="$host" glab <command>
glab <command> -R "$repo"
GITLAB_HOST="$host" glab <command> -R "$repo"
Decision rules:
- If the current directory is already the target GitLab repository, keep using bare
glabcommands. - If the command targets another repository on the same instance, add
-R "$repo". - If the command targets another GitLab instance, set
GITLAB_HOST="$host"and add-R "$repo"when the command is repository-scoped. - For
glab api, prefer--hostname "$host"when calling an instance other than the current repository context.
4. Confirm authentication after glab context is chosen
Check auth:
glab auth status
glab auth status --hostname "$host"
glab auth status --all
Sign in:
glab auth login
glab auth login --hostname "$host"
glab auth login --stdin < token.txt
glab auth login --hostname "$host" --token "$TOKEN"
Notes:
glab auth loginin an interactive Git repository can detect GitLab instances from Git remotes.GITLAB_TOKEN,GITLAB_ACCESS_TOKEN, andOAUTH_TOKENoverride stored credentials.- Prefer
--hostnamefor self-managed or dedicated instances instead of relying on defaults.
5. Run the task-specific command
Use these command families.
Repository and project operations
glab repo view
glab repo view "$repo"
glab repo clone "$repo"
GITLAB_HOST="$host" glab repo clone "$repo"
Merge requests
glab mr create --fill --yes
glab mr create -t "title" -d "description" -b main -s feature-branch
glab mr list
glab mr view 123
glab mr diff 123
glab mr checkout 123
glab mr note 123 -m "Looks good to me"
glab mr update 123 --label needs-review --reviewer alice
glab mr merge 123
Issues
glab issue list
glab issue view 123
glab issue create -t "title" -d "description"
glab issue create -t "title" -l bug -a alice --web
glab issue note 123 -m "Can you share repro steps?"
glab issue update 123 --label triage --assignee alice
CI/CD
glab ci list
glab ci status
glab ci view
glab ci trace 12345
glab ci run
Releases
glab release create v1.2.3 --notes "release notes"
glab release create v1.2.3 --notes-file CHANGELOG.md
glab release view v1.2.3
API
glab api projects/:fullpath
glab api projects/:fullpath/merge_requests --paginate
glab api graphql -f query='query { currentUser { username } }'
glab api --hostname "$host" projects/:fullpath
For checked command syntax and doc links, read references/verified-commands.md.
Patterns
Prefer repository context over manual URL building
Many glab commands accept -R/--repo with:
OWNER/REPOGROUP/NAMESPACE/REPO- a full HTTPS URL
- a Git URL
Use the repository path form when you already have repo from the detection step. It is shorter and easier to compose.
Prefer GITLAB_HOST for cross-instance adaptation
For most CLI commands, GITLAB_HOST="$host" is the simplest host override.
Example:
GITLAB_HOST="$host" glab repo clone "$repo"
GITLAB_HOST="$host" glab issue list -R "$repo"
For glab api, --hostname "$host" is usually clearer than relying only on environment.
Use placeholders in glab api
When running glab api inside a GitLab repository, placeholders such as :fullpath, :branch, :namespace, and :repo resolve from the current repository.
Prefer them when they remove brittle manual encoding:
glab api projects/:fullpath
glab api projects/:fullpath/repository/branches/:branch
Escalate only when platform evidence conflicts
Stop and reassess if:
- Git remotes point to both GitHub and GitLab and the intended target is unclear
- the detected host and the authenticated host disagree
- the repository lives on a private host but the task uses
gitlab.comURLs - the command mixes one instance's host with another instance's repo path
More from flc1125/skills
subagent-orchestrator
Orchestrate subagent workflows for complex tasks that benefit from decomposition, role-based delegation, and parallel execution. Use when Codex should assemble a temporary team of subagents, choose roles from a reusable role library, create a controlled fallback role when no preset role fits, coordinate read-heavy work in parallel, or handle write-heavy work with ownership boundaries, staged execution, and an integrator-led merge path.
31github-create-pr
Create GitHub pull requests from a local branch using a reviewable workflow for branch checks, diff analysis, PR title/body writing, and gh CLI creation. Use when opening a PR, drafting or improving a PR description, preparing a branch for review, or adding reviewers on GitHub.
13async
Launch and coordinate Codex subagents as deferred tasks. Use when the user wants to start bounded subagent work now, keep the main thread moving without waiting by default, then later join, collect, or redirect that work through a stable task reference.
12study
Guide structured learning for a topic by diagnosing current level, defining stage goals, building a learning path, generating practice, and running review loops. Use when the user wants to learn something step by step, start from zero, build a study plan, prepare for an exam or skill, get guided practice, or continue a topic through staged coaching rather than a one-off answer.
12code-review
Request or perform a git-backed code review for a defined diff or SHA range using implementation context and requirements. Use when finishing a task, completing a major feature, preparing to merge, or when you need a fresh review before proceeding.
11gitlab-create-mr
Create GitLab merge requests from a local branch using a reviewable workflow for branch checks, GitLab host detection, diff analysis, title and description writing, and `glab mr create`. Use when opening a GitLab merge request, drafting or improving merge request copy, preparing a branch for review, or working across GitLab.com and self-managed GitLab instances.
11