Token导航 LogoToken导航TokenDH.com
研究检索可写文件github未标认证来源可访问许可证需确认审计提醒

gitlab-fileGitLab file 搜索

Agent Skill

用于围绕 GitLab 项目、Merge Request、Issue、分支、流水线和代码审查流程提供辅助能力。它适合让 Agent 查询项目状态、整理提交差异、辅助检查合并请求或汇总 CI 结果。使用时需要确认项目权限、访问 token 和目标分支范围;涉及合并、推送、改工单或触发流水线时,应先预览影响并核对团队流程。

总安装

1,909

周安装

82

GitHub Stars

1

下载量

669
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:gitlab-file(GitLab file 搜索)
来源仓库:https://github.com/grandcamel/gitlab-assistant-skills
仓库路径:skills/gitlab-file
安装命令:
npx skills add https://github.com/grandcamel/gitlab-assistant-skills --skill gitlab-file
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/grandcamel/gitlab-assistant-skills --skill gitlab-file

简介

用于围绕 GitLab 项目、Merge Request、Issue 等流程提供辅助能力。

  • 适合查询项目状态、整理提交差异、辅助检查合并请求或汇总 CI 结果。
  • 使用时需确认项目权限和访问 token,涉及合并或改工单应预览影响。
  • 安装方式:通过 npx 从指定 GitHub 仓库添加技能。
  • 建议在使用前核对团队流程和目标分支范围。

SKILL.md

File Skill

Repository file operations for GitLab using glab api raw endpoint calls.

Quick Reference

OperationCommand PatternRisk
Get file infoglab api projects/:id/repository/files/:path?ref=:branch-
Get raw contentglab api projects/:id/repository/files/:path/raw?ref=:branch-
Get blameglab api projects/:id/repository/files/:path/blame?ref=:branch-
Create fileglab api projects/:id/repository/files/:path -X POST -f...⚠️
Update fileglab api projects/:id/repository/files/:path -X PUT -f...⚠️
Delete fileglab api projects/:id/repository/files/:path -X DELETE -f...⚠️⚠️

Risk Legend: - Safe | ⚠️ Caution | ⚠️⚠️ Warning | ⚠️⚠️⚠️ Danger

When to Use This Skill

ALWAYS use when:

  • User wants to read file content from GitLab (not local)
  • User wants to create/update/delete files via GitLab API
  • User needs file blame information
  • User wants to download raw file content
  • User mentions "repository file", "blob", "raw content"

NEVER use when:

  • User wants to edit local files (use file editing tools)
  • User wants to search code (use gitlab-search)
  • User wants to browse repository tree (use gitlab-repo)
  • User wants to commit multiple files (use git locally)

API Prerequisites

Required Token Scopes: api

Permissions:

  • Read files: Reporter+ (for private repos)
  • Create/update/delete files: Developer+ (need push access)

URL Encoding

File paths must be URL-encoded. Slashes in paths become %2F:

# src/main.py -> src%2Fmain.py
echo 'src/main.py' | jq -Rr @uri
# Output: src%2Fmain.py

Available Commands

Get File Info (Base64 Encoded)

# Get file metadata and content (base64)
glab api "projects/123/repository/files/README.md?ref=main" --method GET

# With URL-encoded path
glab api "projects/123/repository/files/$(echo 'src/main.py' | jq -Rr @uri)?ref=main"

# From specific branch
glab api "projects/123/repository/files/config.json?ref=develop" --method GET

# From tag
glab api "projects/123/repository/files/version.txt?ref=v1.0.0" --method GET

# From commit SHA
glab api "projects/123/repository/files/app.py?ref=abc123" --method GET

Response includes:

  • file_name - File name
  • file_path - Full path
  • size - File size in bytes
  • encoding - Content encoding (base64)
  • content - Base64-encoded content
  • content_sha256 - SHA256 hash
  • ref - Branch/tag/commit
  • blob_id - Blob SHA
  • commit_id - Last commit SHA
  • last_commit_id - Same as commit_id

Decode Base64 Content

# Get and decode file content
glab api "projects/123/repository/files/README.md?ref=main" | \
  jq -r '.content' | base64 -d

Get Raw File Content

# Get raw file content (not base64)
glab api "projects/123/repository/files/README.md/raw?ref=main" --method GET

# With encoded path
glab api "projects/123/repository/files/$(echo 'src/app.py' | jq -Rr @uri)/raw?ref=main"

# Binary file (save to file)
glab api "projects/123/repository/files/$(echo 'images/logo.png' | jq -Rr @uri)/raw?ref=main" > logo.png

Get File Blame

# Get blame information
glab api "projects/123/repository/files/$(echo 'src/main.py' | jq -Rr @uri)/blame?ref=main" --method GET

# Parse blame output
glab api "projects/123/repository/files/$(echo 'src/main.py' | jq -Rr @uri)/blame?ref=main" | \
  jq -r '.[] | "\(.commit.author_name): lines \(.lines | length)"'

Create File

# Create new file with content
glab api "projects/123/repository/files/$(echo 'docs/new-file.md' | jq -Rr @uri)" --method POST \
  -f branch="main" \
  -f content="# New File\n\nContent here" \
  -f commit_message="Add new documentation file"

# Create with base64 content
glab api "projects/123/repository/files/$(echo 'data/config.json' | jq -Rr @uri)" --method POST \
  -f branch="main" \
  -f content="$(cat config.json | base64)" \
  -f encoding="base64" \
  -f commit_message="Add configuration file"

# Create on new branch
glab api "projects/123/repository/files/$(echo 'feature/new.txt' | jq -Rr @uri)" --method POST \
  -f branch="feature-branch" \
  -f start_branch="main" \
  -f content="Feature content" \
  -f commit_message="Add feature file"

# Create with author info
glab api "projects/123/repository/files/script.sh" --method POST \
  -f branch="main" \
  -f content="#!/bin/bash\necho Hello" \
  -f commit_message="Add script" \
  -f author_email="dev@example.com" \
  -f author_name="Developer"

Update File

# Update file content
glab api "projects/123/repository/files/README.md" --method PUT \
  -f branch="main" \
  -f content="# Updated README\n\nNew content here" \
  -f commit_message="Update README"

# Update with base64 (for binary or complex files)
glab api "projects/123/repository/files/$(echo 'config/settings.json' | jq -Rr @uri)" --method PUT \
  -f branch="main" \
  -f content="$(cat settings.json | base64)" \
  -f encoding="base64" \
  -f commit_message="Update settings"

# Update on feature branch
glab api "projects/123/repository/files/src%2Fapp.py" --method PUT \
  -f branch="feature-update" \
  -f content="$(cat app.py | base64)" \
  -f encoding="base64" \
  -f commit_message="Refactor app module"

# Update with last known commit (for conflict detection)
glab api "projects/123/repository/files/data.json" --method PUT \
  -f branch="main" \
  -f content="{ \"updated\": true }" \
  -f commit_message="Update data" \
  -f last_commit_id="abc123def456"

Delete File

# Delete file
glab api "projects/123/repository/files/$(echo 'old-file.txt' | jq -Rr @uri)" --method DELETE \
  -f branch="main" \
  -f commit_message="Remove deprecated file"

# Delete with author info
glab api "projects/123/repository/files/$(echo 'temp/test.txt' | jq -Rr @uri)" --method DELETE \
  -f branch="main" \
  -f commit_message="Clean up temp files" \
  -f author_email="dev@example.com" \
  -f author_name="Developer"

File Operation Options

OptionTypeDescription
branchstringTarget branch (required for write ops)
start_branchstringSource branch for new files
contentstringFile content (plain text or base64)
encodingstringContent encoding: text (default) or base64
commit_messagestringCommit message (required for write ops)
author_emailstringCustom author email
author_namestringCustom author name
last_commit_idstringExpected last commit (for conflict detection)

Common Workflows

Workflow 1: Download and View File

# Get file content
glab api "projects/123/repository/files/$(echo 'config/app.yml' | jq -Rr @uri)/raw?ref=main"

Workflow 2: Update Configuration File

# 1. Download current file
glab api "projects/123/repository/files/config.json/raw?ref=main" > config.json

# 2. Edit locally
# ... make changes to config.json ...

# 3. Upload updated file
glab api "projects/123/repository/files/config.json" --method PUT \
  -f branch="main" \
  -f content="$(cat config.json | base64)" \
  -f encoding="base64" \
  -f commit_message="Update configuration"

Workflow 3: Create File on Feature Branch

# Create new file on new branch
glab api "projects/123/repository/files/$(echo 'docs/feature.md' | jq -Rr @uri)" --method POST \
  -f branch="feature-docs" \
  -f start_branch="main" \
  -f content="# Feature Documentation\n\nDetails here..." \
  -f commit_message="Add feature documentation"

Workflow 4: Check File History via Blame

# Get blame info for a file
glab api "projects/123/repository/files/$(echo 'src/critical.py' | jq -Rr @uri)/blame?ref=main" | \
  jq -r '.[] | "\(.commit.short_id) \(.commit.author_name): \(.lines | length) lines"'

Workflow 5: Batch Read Multiple Files

# Read multiple files
for file in "README.md" "package.json" "Dockerfile"; do
  echo "=== $file ==="
  glab api "projects/123/repository/files/$(echo "$file" | jq -Rr @uri)/raw?ref=main"
  echo ""
done

Workflow 6: Copy File Between Branches

# 1. Get file from source branch
content=$(glab api "projects/123/repository/files/config.json/raw?ref=develop")

# 2. Create/update on target branch
echo "$content" | base64 > /tmp/content.b64
glab api "projects/123/repository/files/config.json" --method PUT \
  -f branch="main" \
  -f content="$(cat /tmp/content.b64)" \
  -f encoding="base64" \
  -f commit_message="Sync config from develop"

Troubleshooting

IssueCauseSolution
404 Not FoundFile doesn't existVerify path and branch
400 Path encodingSlashes not encodedUse jq -Rr @uri to encode
Binary content garbledNot using base64Use /raw endpoint or decode base64
Conflict on updateFile changedUse last_commit_id for optimistic locking
403 ForbiddenNo push accessNeed Developer+ role
Large file failsSize limitGitLab has file size limits

Size Limits

  • Default max file size: 10 MB via API
  • Large files: Use Git LFS instead
  • Binary files: Always use base64 encoding

Best Practices

  1. URL-encode paths: Always encode file paths with slashes
  2. Use base64 for binary: Encode binary files as base64
  3. Meaningful commits: Write descriptive commit messages
  4. Use feature branches: Don't commit directly to main for big changes
  5. Check for conflicts: Use last_commit_id for critical updates

Related Documentation

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

37.28%
按下载量换算249

Claude

27.8%
按下载量换算186

Cursor

16.31%
按下载量换算109

Gemini CLI

8.82%
按下载量换算59

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

可疑

权限和风险

可写文件

该 Skill 可能写入或修改本地文件,使用前需要确认目标目录和修改范围。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在 warning/failed 结果,不能写成本站确认安全。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills