AgentSkillsCN

github

通过 gh CLI 进行 GitHub 操作。当用户提及“PR”、“拉取请求”、“GitHub 问题”、“工作流”、“Actions”、“gh”,或当 `git remote` 显示 `github.com` 时,可使用此方法。

SKILL.md
--- frontmatter
name: github
description: GitHub operations via gh CLI. Use when user mentions: PR, pull request, github issue, workflow, actions, gh, or when git remote shows github.com.

GitHub CLI (gh)

When to Use This Skill

Use gh for GitHub repositories. To detect GitHub:

bash
git remote -v | grep -i github.com

If the remote contains github.com, use this skill.

Before Any Operation

Always verify authentication first:

bash
gh auth status

If not authenticated, guide the user to run gh auth login.

Behavioral Guidelines

  1. Creating PRs: Always check for uncommitted changes first with git status
  2. Viewing PRs/Issues: Use --comments flag when user wants full context
  3. CI Operations: Check gh run list before triggering new workflows
  4. Use --web: When the user might benefit from the browser UI
  5. PR descriptions: Use HEREDOC for multi-line bodies to preserve formatting

Command Reference

Pull Requests

ActionCommand
Creategh pr create --title "Title" --body "Desc"
Create draftgh pr create --draft --title "Title"
Listgh pr list
Viewgh pr view <id>
View with commentsgh pr view <id> --comments
Checkoutgh pr checkout <id>
Diffgh pr diff <id>
Mergegh pr merge <id>
Approvegh pr review <id> --approve

Issues

ActionCommand
Creategh issue create --title "Title" --body "Desc"
Listgh issue list
List minegh issue list --assignee=@me
Viewgh issue view <id>
Closegh issue close <id>
Commentgh issue comment <id> --body "Comment"

Workflow Runs (CI/CD)

ActionCommand
List runsgh run list
View rungh run view <id>
View logsgh run view <id> --log
Watch livegh run watch <id>
Rerun failedgh run rerun <id> --failed

Repository

ActionCommand
View infogh repo view
Clonegh repo clone <owner/repo>
Forkgh repo fork
Open in browsergh repo view --web

Advanced: API Calls

For operations not covered by CLI commands:

bash
gh api repos/{owner}/{repo}/pulls/{id}/comments