← スキル一覧に戻る
Use

github-cli
by apanoia
A repository where to store whatever Claude skills that I create for my own usage and benefit (or yours if it suits you)
⭐ 0🍴 0📅 2025年11月30日
SKILL.md
name: github-cli description: Wrapper for GitHub CLI (gh) in Claude.ai. Covers installation, authentication, and common operations like pushing files, creating branches, PRs, issues, and releases.
GitHub CLI Skill
Use the official GitHub CLI (gh) in Claude.ai for repository operations.
Setup
1. Install (once per session)
apt-get update && apt-get install -y gh
2. Claude.ai Network Allowlist
Add api.github.com to your project's allowed domains:
- Go to your Claude Project settings
- Find Network/Egress settings
- Add
api.github.com - Start a new chat (network settings load at conversation start)
3. Authentication
Set your GitHub PAT as an environment variable:
export GH_TOKEN="github_pat_xxxx"
Create a fine-grained PAT at: https://github.com/settings/tokens?type=beta
Verify auth:
gh auth status
Common Operations
Repository
# View repo info
gh repo view owner/repo
# Create new repo
gh repo create owner/repo --private --description "My project"
# Clone repo
gh repo clone owner/repo
# List your repos
gh repo list
Files & Commits
# Push a single file (create or update)
CONTENT=$(base64 -w 0 myfile.txt)
gh api -X PUT repos/owner/repo/contents/path/to/file.txt \
-f message="Add file" \
-f content="$CONTENT" \
-f branch="main"
# Update existing file (need SHA)
SHA=$(gh api repos/owner/repo/contents/path/to/file.txt --jq '.sha')
gh api -X PUT repos/owner/repo/contents/path/to/file.txt \
-f message="Update file" \
-f content="$CONTENT" \
-f sha="$SHA" \
-f branch="main"
# Delete a file
SHA=$(gh api repos/owner/repo/contents/path/to/file.txt --jq '.sha')
gh api -X DELETE repos/owner/repo/contents/path/to/file.txt \
-f message="Delete file" \
-f sha="$SHA" \
-f branch="main"
# List files in a directory
gh api repos/owner/repo/contents/path/to/dir
Branches
# List branches
gh api repos/owner/repo/branches --jq '.[].name'
# Create branch from main
SHA=$(gh api repos/owner/repo/git/refs/heads/main --jq '.object.sha')
gh api -X POST repos/owner/repo/git/refs \
-f ref="refs/heads/feature/new-branch" \
-f sha="$SHA"
# Delete branch
gh api -X DELETE repos/owner/repo/git/refs/heads/feature/old-branch
Pull Requests
# Create PR (from cloned repo)
gh pr create --title "My PR" --body "Description" --base main --head feature-branch
# Create PR via API (without clone)
gh api -X POST repos/owner/repo/pulls \
-f title="My PR" \
-f body="Description" \
-f head="feature-branch" \
-f base="main"
# List PRs
gh pr list --repo owner/repo
# View PR
gh pr view 123 --repo owner/repo
# Merge PR
gh pr merge 123 --repo owner/repo --squash
Issues
# Create issue
gh issue create --repo owner/repo --title "Bug" --body "Description"
# List issues
gh issue list --repo owner/repo
# Close issue
gh issue close 123 --repo owner/repo
Releases
# Create release
gh release create v1.0.0 --repo owner/repo --title "v1.0.0" --notes "Release notes"
# Create release with files
gh release create v1.0.0 ./dist/*.zip --repo owner/repo
# List releases
gh release list --repo owner/repo
Actions / Workflows
# List workflow runs
gh run list --repo owner/repo
# View run details
gh run view 12345 --repo owner/repo
# Trigger workflow
gh workflow run build.yml --repo owner/repo
Required Permissions
Fine-grained PAT
| Permission | Level | For |
|---|---|---|
| Contents | Read and write | Files, branches |
| Pull requests | Read and write | PRs |
| Issues | Read and write | Issues |
| Actions | Read and write | Workflows |
| Metadata | Read | Auto-granted |
| Workflows | Read and write | Push to .github/workflows/ |
Classic PAT
Use repo scope for full access, or specific scopes as needed.
Tips
Use --jq for JSON parsing
gh api repos/owner/repo --jq '.default_branch'
gh api repos/owner/repo/branches --jq '.[].name'
Batch operations with xargs
# Delete multiple branches
echo -e "old-branch-1\nold-branch-2" | xargs -I {} gh api -X DELETE repos/owner/repo/git/refs/heads/{}
Check rate limits
gh api rate_limit --jq '.resources.core'
References
スコア
総合スコア
70/100
リポジトリの品質指標に基づく評価
✓SKILL.md
SKILL.mdファイルが含まれている
+20
✓LICENSE
ライセンスが設定されている
+10
✓説明文
100文字以上の説明がある
+10
○人気
GitHub Stars 100以上
0/15
○最近の活動
3ヶ月以内に更新がある
0/10
○フォーク
10回以上フォークされている
0/5
✓Issue管理
オープンIssueが50未満
+5
✓言語
プログラミング言語が設定されている
+5
○タグ
1つ以上のタグが設定されている
0/5
レビュー
💬
レビュー機能は近日公開予定です