GitLab API Skill
Node.js client for the GitLab REST API (v4). Reads config from ./.env.
Security Rules
- NEVER read, cat, print, grep, or expose the
GITLAB_TOKEN value. - NEVER use
curl, wget, or any tool to call GitLab API directly. All access MUST go through gitlab-client. - AI may read/write
.env to manage GITLAB_URL, but GITLAB_TOKEN must be set by the user manually.
Setup
Requires ./.env with:
GITLAB_URL=https://gitlab.fullnine.com.cn
GITLAB_TOKEN=<your-personal-access-token>
If token is missing, prompt the user to edit ./.env and create a token at /-/profile/personal_access_tokens (scope: api).
Install (first time): source ~/.nvm/nvm.sh && npm install
Quick Start
gitlab-client users me # Current user
gitlab-client projects list --owned # My projects
gitlab-client issues list --project 42 --state opened # Project issues
gitlab-client mrs create --project 42 --source-branch feat --target-branch main --title "My MR"
Commands Reference
Format: gitlab-client [id] [--key value ...]
All list actions support --page N --per-page N (default 20, max 100).
Projects
| Action | Usage | Options |
|---|
| -------- | ------- | --------- |
| list | projects list | --search --owned --membership --visibility |
| get | projects get | |
| search | projects search "term" | |
| create | projects create --name "name" | --description --visibility --namespace-id --initialize-with-readme |
| edit | projects edit | --name --description --visibility |
| delete | projects delete | |
| fork | projects fork | --namespace |
| members | projects members | |
| hooks | projects hooks | |
Issues
| Action | Usage | Options |
|---|
| -------- | ------- | --------- |
| list | issues list --project | --state --labels --milestone --assignee-id --search |
| get | issues get --project --iid | |
| create | issues create --project --title "T" | --description --labels --assignee-ids --milestone-id --due-date --confidential |
| edit | issues edit --project --iid | --title --description --state-event --labels --assignee-ids |
| close | issues close --project --iid | |
| reopen | issues reopen --project --iid | |
| delete | issues delete --project --iid | |
| notes | issues notes --project --iid | |
| add-note | issues add-note --project --iid --body "text" | |
Merge Requests
| Action | Usage | Options |
|---|
| -------- | ------- | --------- |
| list | mrs list --project | --state --labels --milestone --source-branch --target-branch --search |
| get | mrs get --project --iid | |
| create | mrs create --project --source-branch "src" --target-branch "tgt" --title "T" | --description --assignee-id --reviewer-ids --labels --milestone-id --remove-source-branch --squash |
| edit | mrs edit --project --iid | --title --description --state-event --labels --assignee-id |
| merge | mrs merge --project --iid | --merge-commit-message --squash --should-remove-source-branch |
| changes | mrs changes --project --iid | |
| commits | mrs commits --project --iid | |
| notes | mrs notes --project --iid | |
| add-note | mrs add-note --project --iid --body "text" | |
| approve | mrs approve --project --iid | |
| pipelines | mrs pipelines --project --iid | |
Branches
| Action | Usage | Options |
|---|
| -------- | ------- | --------- |
| list | branches list --project | --search |
| get | branches get --project --branch "name" | |
| create | branches create --project --branch "name" --ref "main" | |
| delete | branches delete --project --branch "name" | |
| delete-merged | branches delete-merged --project | |
Commits
| Action | Usage | Options |
|---|
| -------- | ------- | --------- |
| list | commits list --project | --ref-name --since --until --path |
| get | commits get --project --sha "abc123" | |
| diff | commits diff --project --sha "abc123" | |
| comments | commits comments --project --sha "abc123" | |
| add-comment | commits add-comment --project --sha "abc123" --note "text" | |
Repository / Files
| Action | Usage | Options |
|---|
| -------- | ------- | --------- |
| tree | repo tree --project | --path --ref --recursive |
| file | repo file --project --file-path "path" | --ref |
| raw | repo raw --project --file-path "path" | --ref |
| create-file | repo create-file --project --file-path "p" --branch "b" --content "c" --commit-message "m" | |
| update-file | repo update-file --project --file-path "p" --branch "b" --content "c" --commit-message "m" | |
| delete-file | repo delete-file --project --file-path "p" --branch "b" --commit-message "m" | |
| compare | repo compare --project --from "main" --to "feat" | |
Pipelines
| Action | Usage | Options |
|---|
| -------- | ------- | --------- |
| list | pipelines list --project | --status --ref |
| get | pipelines get --project --pipeline-id | |
| jobs | pipelines jobs --project --pipeline-id | |
| job-log | pipelines job-log --project --job-id | |
| retry | pipelines retry --project --pipeline-id | |
| cancel | pipelines cancel --project --pipeline-id | |
| create | pipelines create --project --ref "main" | --variables "K1=v1,K2=v2" |
Groups
| Action | Usage | Options |
|---|
| -------- | ------- | --------- |
| list | groups list | --search --owned |
| get | groups get | |
| projects | groups projects | --search |
| members | groups members | |
| issues | groups issues | --state |
| mrs | groups mrs | --state |
Users
| Action | Usage |
|---|
| -------- | ------- |
| me | users me |
| list | users list [--search "john"] |
| get | users get |
| projects | users projects |
Labels
| Action | Usage | Options |
|---|
| -------- | ------- | --------- |
| list | labels list --project | |
| create | labels create --project --name "bug" --color "#FF0000" | --description |
| edit | labels edit --project --name "bug" | --new-name --color |
| delete | labels delete --project --name "bug" | |
Milestones
| Action | Usage | Options |
|---|
| -------- | ------- | --------- |
| list | milestones list --project | --state |
| get | milestones get --project --milestone-id | |
| create | milestones create --project --title "v1.0" | --description --due-date --start-date |
| edit | milestones edit --project --milestone-id | --title --state-event |
| delete | milestones delete --project --milestone-id | |
Tags & Releases
| Action | Usage | Options |
|---|
| -------- | ------- | --------- |
| tags list | tags list --project | --search |
| tags create | tags create --project --tag-name "v1.0" --ref "main" | --message |
| tags delete | tags delete --project --tag-name "v1.0" | |
| releases list | releases list --project | |
| releases create | releases create --project --tag-name "v1.0" --name "R1" | --description |
Snippets
| Action | Usage | Options |
|---|
| -------- | ------- | --------- |
| list | snippets list --project | |
| get | snippets get --project --snippet-id | |
| create | snippets create --project --title "T" --file-name "f" --content "c" | --visibility |
Search
| Action | Usage |
|---|
| -------- | ------- |
| global | search global --scope --search "query" |
| project | search project --project --scope --search "query" |
| group | search group --group --scope --search "query" |
Scopes — global: projects|issues|merge_requests|milestones|snippet_titles|users. Project: issues|merge_requests|milestones|notes|wiki_blobs|commits|blobs. Group: projects|issues|merge_requests|milestones.
Runners
| Action | Usage | Options |
|---|
| -------- | ------- | --------- |
| list | runners list --project | |
| all | runners all | --type --status |
Webhooks
| Action | Usage | Options |
|---|
| -------- | ------- | --------- |
| list | hooks list --project | |
| create | hooks create --project --url "url" | --push-events --merge-requests-events --issues-events --token |
| delete | hooks delete --project --hook-id | |
Usage Notes
- Auth: Uses
PRIVATE-TOKEN header. Scopes: api (full), read_api (read-only), read_user, read_repository. - Project ID: Use numeric ID or URL-encoded path (
my-group%2Fmy-project). - Output: JSON. Pipe to
jq for filtering: gitlab-client projects list | jq '.[].name' - Dates: ISO 8601 format (
YYYY-MM-DDTHH:MM:SSZ). - Labels: Comma-separated:
--labels "bug,feature,urgent". - Errors:
401 unauthorized, 403 forbidden, 404 not found, 422 validation, 429 rate limited.