AgentSkillsCN

api-github

GitHub REST API 用于 Issue、PR、Repository 管理。采用 PAT Token 实现无头模式或 CI 自动化操作。适用于 GitHub 相关的各类运维场景。

SKILL.md
--- frontmatter
name: api-github
description: GitHub REST API for issues, PRs, repos. Uses PAT for headless/CI. Activate for GitHub operations.
allowed-tools: Bash, Read, Grep
user-invocable: true

GitHub API Skill

When to Activate

  • Create/read/update issues
  • Manage pull requests
  • Query repository information
  • Access GitHub Actions status

Authentication

Credentials File: .credentials/github.json

json
{
  "personal_access_token": "ghp_..."
}

Create token at: https://github.com/settings/tokens

Required scopes:

  • repo - Full repository access
  • workflow - GitHub Actions (optional)

Load credentials before API calls:

bash
GITHUB_TOKEN=$(jq -r '.personal_access_token' /Users/dhlee/Git/personal/neuron/.credentials/github.json)

API Base URL

code
https://api.github.com

Common Operations

Get Authenticated User

bash
curl -s -H "Authorization: Bearer $GITHUB_TOKEN" \
  -H "X-GitHub-Api-Version: 2022-11-28" \
  https://api.github.com/user

List Repository Issues

bash
curl -s -H "Authorization: Bearer $GITHUB_TOKEN" \
  -H "X-GitHub-Api-Version: 2022-11-28" \
  "https://api.github.com/repos/{owner}/{repo}/issues?state=open"

Create Issue

bash
curl -s -X POST \
  -H "Authorization: Bearer $GITHUB_TOKEN" \
  -H "X-GitHub-Api-Version: 2022-11-28" \
  -H "Content-Type: application/json" \
  -d '{"title":"Issue title","body":"Issue body","labels":["bug"]}' \
  https://api.github.com/repos/{owner}/{repo}/issues

Get Pull Request

bash
curl -s -H "Authorization: Bearer $GITHUB_TOKEN" \
  -H "X-GitHub-Api-Version: 2022-11-28" \
  https://api.github.com/repos/{owner}/{repo}/pulls/{pr_number}

Create Pull Request

bash
curl -s -X POST \
  -H "Authorization: Bearer $GITHUB_TOKEN" \
  -H "X-GitHub-Api-Version: 2022-11-28" \
  -H "Content-Type: application/json" \
  -d '{"title":"PR title","body":"PR body","head":"feature-branch","base":"main"}' \
  https://api.github.com/repos/{owner}/{repo}/pulls

Error Handling

StatusMeaningAction
401Invalid tokenCheck .credentials/github.json
403Rate limit or scopeWait or check permissions
404Not found or no accessVerify repo/resource exists

Rate Limits

  • Authenticated: 5,000 requests/hour
  • Check: X-RateLimit-Remaining header

References