К основному содержанию
скилл CX Codex

gh-cli · logicrw — скилл для Claude Code: работа с GitHub через gh

Скилл учит агента делать всё в GitHub через gh вместо MCP-сервера: PR, issues, поиск по коду, релизы. Полезен, когда не хочется держать отдельный MCP.

Установить в Claude Code · Через Skills CLI (Vercel) Все способы и платформы ↓
npx skills add logicrw/gh-cli-skill --skill gh-cli -a claude-code
Открыть на GitHub

Что делает gh-cli

Скилл описывает, как агенту обращаться к GitHub через gh CLI. Внутри — набор готовых вызовов: список и просмотр PR, диффы, создание и мерж, ревью с комментариями к строкам, issues, файлы репозитория, поиск по коду и репозиториям, коммиты, релизы и теги. Для всего остального есть прямой gh api.

Главное правило скилла — просить только нужные поля. Вместо полного вывода команда идёт с --json и --jq, длинные списки режутся через --limit или head. Это заметно снижает расход токенов, потому что агент не тащит в контекст весь объект PR или issue.

Аутентификация берётся из уже настроенного gh auth — проверить можно через gh auth status. Если gh не авторизован, ни один вызов не пройдёт, так что перед установкой скилла стоит убедиться, что CLI на месте и вход выполнен. Автор заявляет, что скилл заменяет GitHub MCP-сервер прямыми вызовами CLI.

Какие задачи решает

  • посмотреть открытые PR с авторами и датами обновления
  • создать черновик PR из ветки в main
  • оставить ревью-комментарий к конкретной строке файла
  • найти код по запросу внутри репозитория
  • выпустить релиз с тегом и описанием

Примеры запросов агенту

  • Покажи открытые PR в репозитории: номер, заголовок, автор
  • Создай черновик PR из ветки feature-branch в main
  • Оставь ревью-комментарий к строке 42 в file.py в PR 123

Как установить gh-cli

1Через Skills CLI (Vercel)

npx skills add logicrw/gh-cli-skill --skill gh-cli -a claude-code

2Вручную: положить файлы

~/.claude/skills/gh-cli/SKILL.md

Папка скилла целиком; для одного проекта — .claude/skills/gh-cli/

По шагам, с командами для каждой платформы: Как установить скилл в Claude Code: пять способов

Вопросы о gh-cli

Как установить gh-cli в Claude Code?

Выполните npx skills add logicrw/gh-cli-skill --skill gh-cli -a claude-code. Файл скилла окажется по пути ~/.claude/skills/gh-cli/SKILL.md.

Что делает gh-cli?

Описывает агенту работу с GitHub через gh: PR, issues, файлы, поиск, коммиты, релизы. Вместо GitHub MCP-сервера используются прямые вызовы CLI.

Что нужно для работы скилла?

Настроенный gh auth. Проверить вход можно командой gh auth status.

Исходный текст

SKILL.md · MIT
---
name: gh-cli
description: >
  GitHub CLI operations via `gh` command. Use when working with GitHub
  repositories, pull requests, issues, code search, releases, or any
  GitHub API operation. This skill replaces the GitHub MCP server with
  direct CLI calls. Triggers on: GitHub, PR, pull request, issue, repo,
  branch, release, tag, commit, fork, merge, review, gh.
---

# GitHub CLI (`gh`) — Agent Skill

Use the `gh` CLI for ALL GitHub operations. Always use `--json` for structured output and `--jq` for field selection to minimize token usage.

## Authentication

Already configured via `gh auth`. Verify with:

```bash
gh auth status
```

## Core Principle

**Always request only the fields you need** to minimize output tokens:

```bash
# ❌ Bad — returns everything
gh pr view 123

# ✅ Good — returns only what's needed
gh pr view 123 --json title,state,body,url --jq '{title,state,body,url}'
```

---

## Quick Reference

### Pull Requests

```bash
# List open PRs
gh pr list --json number,title,author,updatedAt --jq '.[] | {number,title,author:.author.login}'

# View PR details
gh pr view <number> --json title,state,body,headRefName,baseRefName,additions,deletions,changedFiles

# View PR diff
gh pr diff <number>

# View PR files changed
gh pr diff <number> --name-only

# Create PR
gh pr create --title "title" --body "description" --base main --head feature-branch

# Create draft PR
gh pr create --title "title" --body "description" --draft

# Merge PR
gh pr merge <number> --squash --delete-branch

# Review PR
gh pr review <number> --approve
gh pr review <number> --request-changes --body "feedback"
gh pr review <number> --comment --body "looks good"

# PR review comments
gh api repos/{owner}/{repo}/pulls/{number}/comments --jq '.[].body'

# Add review comment on specific line
gh api repos/{owner}/{repo}/pulls/{number}/comments \
  -f body="comment" -f path="file.py" -F line=42 -f side="RIGHT" \
  -f commit_id="$(gh pr view <number> --json headRefOid --jq .headRefOid)"

# Check PR CI status
gh pr checks <number>

# Update PR branch
gh pr update-branch <number>
```

### Issues

```bash
# List issues
gh issue list --json number,title,labels,assignees --jq '.[] | {number,title,labels:[.labels[].name]}'

# View issue
gh issue view <number> --json title,body,state,labels,assignees,comments

# Create issue
gh issue create --title "title" --body "description" --label "bug"

# Comment on issue
gh issue comment <number> --body "comment text"

# Close issue
gh issue close <number> --reason completed

# Edit issue
gh issue edit <number> --title "new title" --add-label "priority"

# Search issues
gh issue list --search "keyword in:title,body" --json number,title
```

### Repository & Files

```bash
# View repo info
gh repo view --json name,description,defaultBranchRef --jq '{name,description,branch:.defaultBranchRef.name}'

# Get file contents (use gh api to avoid raw output issues)
gh api repos/{owner}/{repo}/contents/{path} --jq '.content' | base64 -d
# Or with ref:
gh api repos/{owner}/{repo}/contents/{path}?ref={branch} --jq '.content' | base64 -d

# List directory
gh api repos/{owner}/{repo}/contents/{path} --jq '.[].name'

# Create/update file
gh api repos/{owner}/{repo}/contents/{path} \
  -X PUT \
  -f message="commit message" \
  -f content="$(echo -n 'file content' | base64)" \
  -f branch="branch-name"
# For update, include sha:
  -f sha="<blob_sha>"

# Delete file
gh api repos/{owner}/{repo}/contents/{path} \
  -X DELETE \
  -f message="delete file" \
  -f sha="<blob_sha>" \
  -f branch="branch-name"

# Push multiple files — use git directly
git add file1 file2 && git commit -m "message" && git push

# Create branch
gh api repos/{owner}/{repo}/git/refs \
  -f ref="refs/heads/new-branch" \
  -f sha="$(gh api repos/{owner}/{repo}/git/ref/heads/main --jq '.object.sha')"

# List branches
gh api repos/{owner}/{repo}/branches --jq '.[].name'

# Fork repo
gh repo fork {owner}/{repo}

# Create repo
gh repo create {name} --public --description "desc"
```

### Search

```bash
# Search code
gh search code "query" --repo {owner}/{repo} --json path,repository,textMatches
gh search code "query language:python" --json path,repository

# Search repos
gh search repos "query" --json fullName,description,stargazersCount --jq '.[] | {name:.fullName,stars:.stargazersCount}'

# Search issues across GitHub
gh search issues "query" --json number,title,repository

# Search PRs
gh search prs "query" --json number,title,repository
```

### Commits & History

```bash
# List commits
gh api repos/{owner}/{repo}/commits --jq '.[].commit.message' | head -20
gh api repos/{owner}/{repo}/commits?sha={branch}\&per_page=10 --jq '.[] | {sha: .sha[:7], message: .commit.message}'

# View specific commit
gh api repos/{owner}/{repo}/commits/{sha} --jq '{message:.commit.message,files:[.files[].filename],stats:.stats}'

# Get commit diff
gh api repos/{owner}/{repo}/commits/{sha} -H "Accept: application/vnd.github.diff"
```

### Releases & Tags

```bash
# List releases
gh release list --json tagName,name,publishedAt

# View latest release
gh release view --json tagName,name,body

# View specific release
gh release view {tag} --json tagName,name,body

# List tags
gh api repos/{owner}/{repo}/tags --jq '.[].name'

# Create release
gh release create {tag} --title "title" --notes "release notes"
```

### Advanced API Access

For any operation not covered above, use `gh api` directly:

```bash
# GET request
gh api repos/{owner}/{repo}/actions/runs --jq '.workflow_runs[:3] | .[].conclusion'

# POST request
gh api repos/{owner}/{repo}/issues/{number}/comments -f body="comment"

# With pagination
gh api repos/{owner}/{repo}/issues --paginate --jq '.[].number'

# Get authenticated user
gh api user --jq '{login,name,email}'

# Team members
gh api orgs/{org}/teams/{team}/members --jq '.[].login'
```

## Output Optimization

Always minimize output for agent consumption:

1. **Use `--json` + `--jq`** for structured, minimal output
2. **Limit results** with `--limit` or API `per_page` parameter
3. **Select fields** — never dump full objects
4. **Pipe to `head`** for long outputs: `| head -50`

## Error Handling

```bash
# Check if command succeeded
gh pr view 999 --json state 2>/dev/null && echo "exists" || echo "not found"

# Safe API call with error handling
gh api repos/{owner}/{repo}/contents/{path} 2>/dev/null || echo "file not found"
```

© logicrw · MIT · logicrw/gh-cli-skill

Похожие скиллы

Все скиллы по теме «Git и GitHub» →

Сначала — gh-cli от других авторов.

gh-cli trailofbits Скилл заставляет ИИ использовать аутентифицированный gh CLI вместо curl и fetch при работе с репозиториями, PR и issues GitHub. Нужен для приватных репо и выше лимитов API. CX Codex +1 6 600установок triage Matt Pocock Скилл проводит issue и внешние PR через роли триажа, проверку и подготовку брифа для агента. Подойдёт мейнтейнеру, который разбирает очередь задач. 990 453установок code-review Matt Pocock Проверяет изменения от выбранной точки по стандартам репозитория и требованиям задачи. Нужен для ревью ветки, PR или незавершённой работы. 789 521установок implement Matt Pocock Выполняет задачу по спецификации или тикетам, ведёт работу через тесты и завершает её ревью с коммитом. Подходит для задач, где нужен дисциплинированный цикл разработки. 774 700установок git-guardrails-claude-code Matt Pocock Скилл ставит хук Claude Code, который останавливает опасные Git-команды до их запуска. Нужен, если агент не должен делать push или удалять изменения. 499 069установок setup-pre-commit Matt Pocock Скилл настраивает pre-commit для JavaScript-репозитория: Husky запускает форматирование, проверку типов и тесты перед коммитом. 489 289установок scaffold-exercises Matt Pocock Скилл создаёт структуру учебных упражнений с секциями, задачами, решениями и пояснениями. Пригодится при запуске нового раздела курса. 480 196установок

Спонсоры проекта

Компании, которые помогают держать аналитику открытой