/install gitlab-skill
GitLab Operations
This skill enables comprehensive GitLab operations including creating and cloning repositories, listing projects, managing issues, merge requests, branches, commits, pipelines, and more.
Configuration
The GitLab skill uses a secure, layered credential management system. Credentials are loaded in the following priority order:
1. Environment Variables (Recommended - Most Secure) ⭐
Set GitLab credentials as environment variables:
export GITLAB_HOST="https://gitlab.example.com"
export GITLAB_TOKEN="glpat-your-token-here"
Benefits:
- Most secure approach
- Never committed to version control
- Standard practice for production systems
- Works seamlessly with CI/CD pipelines
Generating a GitLab Access Token:
- Go to GitLab → User Settings → Access Tokens
- Create a personal access token with appropriate scopes:
api- Full API accessread_repository- For repository operationswrite_repository- For creating branches, commits, etc.
- Copy the token immediately (you won't see it again)
Persistent Configuration: Add to your shell profile (~/.bashrc, ~/.zshrc, etc.):
export GITLAB_HOST="https://gitlab.example.com"
export GITLAB_TOKEN="glpat-your-token-here"
2. User Configuration File
Create a configuration file in your home directory:
mkdir -p ~/.claude
cat > ~/.claude/gitlab_config.json \x3C\x3C 'EOF'
{
"host": "https://gitlab.example.com",
"access_token": "glpat-your-token-here"
}
EOF
chmod 600 ~/.claude/gitlab_config.json # Restrict file permissions
Location: ~/.claude/gitlab_config.json
Benefits:
- Secure location outside skill directory
- Won't be accidentally committed
- Easy to manage multiple GitLab instances
- Supports file-based automation
3. Runtime Prompt (Fallback)
If credentials are not found in environment variables or config files, the skill can prompt for credentials interactively (when the --allow-prompt flag is used):
python3 scripts/gitlab_api.py projects --allow-prompt
Note: This is not recommended for automation or CI/CD pipelines.
Configuration Priority
The skill loads credentials in this order (first match wins):
- Environment Variables (
GITLAB_HOST,GITLAB_TOKEN) - Highest Priority - User Config File (
~/.claude/gitlab_config.json) - Legacy Config (
scripts/config.json- deprecated, shows warning) - Runtime Prompt (only if
--allow-promptflag is used)
Example Config File Template
An example configuration template is available at scripts/config.example.json:
{
"host": "https://gitlab.example.com",
"access_token": "glpat-your-token-here"
}
Important Security Notes
DO:
✅ Use environment variables for production systems
✅ Store user config in ~/.claude/gitlab_config.json
✅ Restrict file permissions: chmod 600 ~/.claude/gitlab_config.json
✅ Use different tokens for different environments
✅ Rotate tokens regularly
DON'T:
❌ Commit credentials to version control
❌ Store real tokens in scripts/config.json
❌ Share access tokens in chat logs or output
❌ Use the same token across multiple environments
❌ Print or log access tokens
SSL Certificate Issues
For internal GitLab instances with self-signed certificates, use the --insecure flag:
python3 scripts/gitlab_api.py projects --insecure
This bypasses SSL certificate verification (useful for development/testing but not recommended for production).
Testing Credential Loading
Test that credentials are configured correctly:
# Test using credential loader directly
python3 scripts/credential_loader.py --show-source
# List projects to verify API access
python3 scripts/gitlab_api.py projects
# Check which credential source is being used
python3 scripts/gitlab_api.py projects --allow-prompt
Troubleshooting
Problem: "GitLab credentials not configured"
Solutions:
- Check environment variables:
echo $GITLAB_HOST $GITLAB_TOKEN - Check user config:
cat ~/.claude/gitlab_config.json - Verify token is valid and not expired
- Ensure token has required API scopes
Problem: "Authentication failed (401)"
Solutions:
- Verify token hasn't expired or been revoked
- Check token has required scopes (
api,read_repository, etc.) - Ensure token format is correct (starts with
glpat-) - Test token manually:
curl -H "PRIVATE-TOKEN: $GITLAB_TOKEN" "$GITLAB_HOST/api/v4/user"
Problem: "Resource not found (404)"
Solutions:
- Verify GitLab host URL is correct
- Check project ID or path
- Ensure user has access to the project
- Test with
python3 scripts/gitlab_api.py projectsto list accessible projects
Migration from Old Configuration
If you have an existing scripts/config.json file:
-
Immediate Action: Move credentials to secure location
# Export to environment variables export GITLAB_HOST=$(jq -r '.host' scripts/config.json) export GITLAB_TOKEN=$(jq -r '.access_token' scripts/config.json) # Or move to user config mkdir -p ~/.claude cp scripts/config.json ~/.claude/gitlab_config.json chmod 600 ~/.claude/gitlab_config.json -
Replace config.json with placeholder:
cat > scripts/config.json \x3C\x3C 'EOF' { "_comment": "This file is deprecated", "host": "https://gitlab.example.com", "access_token": "glpat-your-token-here" } EOF -
Verify new configuration works:
python3 scripts/credential_loader.py --show-source python3 scripts/gitlab_api.py projects
Common Operations
Create Repository
When the user wants to create a new GitLab repository:
- Prompt for required information:
- Project name (required)
- Description (optional)
- Visibility level: public, private, or internal (optional, defaults to private)
- Namespace/group path (optional, defaults to user's personal namespace)
- Initialize with README (optional, defaults to false)
- Use POST
/api/v4/projectsendpoint with the provided parameters - Include additional options if specified:
initialize_with_readme: Create repository with initial READMEdefault_branch: Set default branch name (defaults to "main")wiki_enabled: Enable wiki (defaults to true)issues_enabled: Enable issues (defaults to true)merge_requests_enabled: Enable merge requests (defaults to true)jobs_enabled: Enable CI/CD pipelines (defaults to true)
- Handle response and provide:
- Project URL
- Git clone URL
- Web URL
- Project ID
- Confirmation with formatted Markdown output
Example output format:
## ✅ Repository Created Successfully
**Project**: my-project
**Project ID**: 123
**Visibility**: Private
**URL**: [View Project](https://gitlab.example.com/username/my-project)
**Clone**: `git clone https://gitlab.example.com/username/my-project.git`
Error handling:
- Name already exists: Suggest alternative names
- Invalid namespace: List available namespaces
- Permission denied: Check user permissions and token scopes
Clone Repository
When the user wants to clone a GitLab repository:
- Parse the repository URL to extract the project path and host
- Verify the host matches the configured GitLab instance in
config.json - If authentication is required for private repositories, use the access token from config
- Clone to the specified directory or current directory if not specified
- Use git clone with appropriate authentication:
- For HTTPS: use token as password
- For SSH: use git@host:project-path.git format
- Confirm successful clone with repository path and brief info
Example workflow:
User: "clone https://gitlab.example.com/group/project to ./myproject"
Action:
1. Extract host (gitlab.example.com) and project path (group/project)
2. Run git clone with authentication
3. Confirm: "✅ Cloned to ./myproject"
Authentication note: For private repos requiring HTTPS auth, embed token in URL: https://oauth2:TOKEN@host/project.git
List Repositories/Projects
When the user wants to see their GitLab repositories:
- Load configuration from
config.json - Fetch all projects using the GitLab API (
/api/v4/projects) - Use
membership=trueto show only projects the user is a member of - Sort by
updated_atdescending to show recently updated projects first - Handle pagination automatically to fetch all projects
- Output results in Markdown format with:
- Project count summary
- Formatted table with: Name, Visibility, Last Updated, URL
- Group/namespace information if relevant
- Links to each project
Example output format:
## Found 25 GitLab Projects
| Name | Visibility | Last Updated | URL |
|------|------------|--------------|-----|
| group/project-name | Public | 2025-04-02 | [View](https://gitlab.example.com/group/project-name) |
...
Search Projects
When the user wants to search for specific projects:
- Use the
/api/v4/projectsendpoint withsearch=\x3Cquery>parameter - Filter by visibility if requested (
visibility=public|private|internal) - Limit results to top 20 matches unless more are requested
- Output in Markdown table format
Project Details
When the user asks about a specific project:
- Use
/api/v4/projects/:idendpoint (project ID or path-encoded URL) - Fetch detailed information including:
- Description, default branch, star count, forks count
- Last activity date
- Repository size
- Permissions
- Output in formatted Markdown with sections for each detail category
Issues
List issues:
- Use
/api/v4/projects/:id/issuesfor project-specific issues - Use
/api/v4/issuesfor all issues across projects - Support filtering: state (opened/closed), labels, milestone, assignee
- Output in Markdown table with: ID, Title, State, Author, Assignee, Updated, Link
Create issue:
- Use POST
/api/v4/projects/:id/issues - Required: title
- Optional: description, labels, assignee_id, milestone_id
- Ask user for missing required information
- Confirm creation and show the issue URL
Get issue details:
- Use GET
/api/v4/projects/:id/issues/:issue_iid - Fetch complete issue information including description, labels, assignees
- Output formatted Markdown with all issue details
- Show state icon (🟢 opened, 🔴 closed), author, assignees, labels, milestone
- Display full description and link to issue in GitLab
- Handle missing fields gracefully with "None" or "Unassigned" placeholders
Update issue:
- Use PUT
/api/v4/projects/:id/issues/:issue_iid - Allow updating title, description, state, labels, etc.
- Confirm changes and show updated issue link
Merge Requests
List merge requests:
- Use
/api/v4/projects/:id/merge_requestsfor project-specific MRs - Use
/api/v4/merge_requestsfor all MRs across projects - Support filtering: state (opened/closed/merged), author, assignee, labels
- Output in Markdown table with: IID, Title, State, Author, Target Branch, Source Branch, Link
Create merge request:
- Use POST
/api/v4/projects/:id/merge_requests - Required: source_branch, target_branch, title
- Optional: description, assignee_id, labels, remove_source_branch
- Ask user for missing required information
- Confirm creation and show MR URL
Show MR details:
- Fetch MR with discussions, changes, and pipeline status
- Output comprehensive Markdown with:
- Basic info (title, state, branches, author)
- Changes summary (files changed, additions, deletions)
- Pipeline status if available
- Recent discussions/comments
Branches
List branches:
- Use
/api/v4/projects/:id/repository/branches - Show name, protected status, commit info, last commit date
- Output in Markdown table
Create branch:
- Use POST
/api/v4/projects/:id/repository/branches - Required: branch_name, ref (starting branch or commit SHA)
- Confirm creation with branch details including:
- Branch name and protection status (🔒 protected icon)
- Latest commit SHA, message, author, and date
- Link to branch in GitLab
- Handle errors gracefully:
- Branch already exists (400 error)
- Invalid branch name or ref (400 error)
- Invalid project or insufficient permissions (403/404 errors)
Delete branch:
- Use DELETE
/api/v4/projects/:id/repository/branches/:branch - Warn before deletion
- Confirm deletion
Commits
List commits:
- Use
/api/v4/projects/:id/repository/commits - Support filtering: ref_name (branch), since, until, author
- Show short SHA, author, message, date
- Output in Markdown table with links to commit diffs
Show commit details:
- Use
/api/v4/projects/:id/repository/commits/:sha - Show full commit message, author, committer, file changes
- Display diff summary
Pipelines
List pipelines:
- Use
/api/v4/projects/:id/pipelines - Show ID, status, ref, user, created date, duration
- Output in Markdown table with status indicators (✅ ✗ ⏳)
Show pipeline details:
- Fetch pipeline jobs and stages
- Display job status, duration, and logs URLs
- Show overall pipeline status and timing
Error Handling
When encountering errors:
-
Authentication failed (401/403):
- Inform user the access token may be invalid or lacks required permissions
- Suggest checking
config.jsonor generating a new token with appropriate scopes
-
Project not found (404):
- Verify project ID or path
- Check if user has access to the project
- Suggest listing projects to find the correct ID
-
Rate limiting (429):
- Inform user about rate limits
- Suggest waiting before retrying
-
Network errors:
- Check if GitLab host is reachable
- Verify network connection
- For internal GitLab instances with self-signed certificates, handle SSL verification appropriately
-
Invalid parameters:
- Explain what parameter was invalid
- Provide guidance on correct values
- Show API documentation links if relevant
API Pagination
For endpoints that return paginated results:
- Check
x-total-pagesheader - Iterate through all pages to fetch complete results
- For large result sets (>100 items), ask user if they want all results or just the first N
- Show progress when fetching multiple pages
Output Formatting Principles
- Use Markdown for all human-readable output - tables, lists, code blocks
- Include links to relevant GitLab resources - project URLs, issue links, MR links
- Show counts and summaries - total results, filtered counts
- Use visual indicators for status - ✅ for success, ✗ for failure, ⏳ for pending
- Format dates in readable format - YYYY-MM-DD or relative time (2 days ago)
- Truncate long text - commit messages, descriptions, with option to show full text
- Group related information - use headers and sections for complex outputs
Interactive Workflows
For complex operations requiring multiple steps:
- Ask for confirmation before destructive operations (delete, close, etc.)
- Offer choices when there are multiple valid approaches
- Suggest next actions after completing an operation (e.g., after creating an issue, ask if they want to create another)
- Handle ambiguous inputs - if a project name is ambiguous, show matching projects and ask user to select
Example Workflows
User asks: "Show me my open merge requests"
Action:
- Fetch MRs from all projects using
/api/v4/merge_requests?state=opened - Group by project
- Output in Markdown table with project name, MR details, and links
User asks: "Create an issue in myproject about the login bug"
Action:
- Load config.json
- Find project ID for "myproject"
- Ask for issue details if not provided (description, labels, assignee)
- Create the issue via API
- Confirm creation and show issue URL
User asks: "What's the status of the main branch in project-group/webapp?"
Action:
- Find project by name/path
- Fetch branch details for "main"
- Show commit info, protection status
- Optionally show recent commits or pipeline status
Notes
- All API calls should include the access token in the
PRIVATE-TOKENheader - Use proper SSL/TLS handling for internal GitLab instances with self-signed certificates
- Respect rate limits and implement exponential backoff if needed
- Cache project ID lookups when appropriate to avoid repeated API calls
- 确保已安装 OpenClaw(本地或 Docker 部署)
- 在对话框中输入安装命令:
/install gitlab-skill - 安装完成后,直接呼叫该 Skill 的名称或使用
/gitlab-skill触发 - 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
gitlab-skill 是什么?
GitLab operations including creating and cloning repositories, listing projects, managing issues, merge requests, branches, commits, and pipelines. Use this... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 132 次。
如何安装 gitlab-skill?
在 OpenClaw 或 Claude Code 对话框中运行命令「/install gitlab-skill」即可一键安装,无需额外配置。
gitlab-skill 是免费的吗?
是的,gitlab-skill 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。
gitlab-skill 支持哪些平台?
gitlab-skill 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。
谁开发了 gitlab-skill?
由 Albert(@pickbert)开发并维护,当前版本 v1.0.1。