From claude-commands
Provides copy-paste instructions for GitHub CLI (gh) installation, authentication, and commands in Claude Code environment, covering repo ops, PRs, issues, and API usage to avoid common errors.
npx claudepluginhub joshuarweaver/cascade-code-general-misc-2 --plugin jleechanorg-claude-commandsThis skill uses the workspace's default tool permissions.
Provide comprehensive, copy-paste ready instructions for GitHub CLI (gh) installation and usage to prevent common mistakes like missing full paths or forgetting GITHUB_TOKEN environment variable prefix.
Guides GitHub CLI (gh) commands for creating/managing PRs, issues, CI runs, releases, auth, and JSON scripting from terminal.
Reference GitHub CLI (gh) for repos, issues, PRs, Actions, projects, releases, gists, codespaces, orgs via terminal. Covers install, auth, setup.
Executes GitHub CLI `gh` operations for issues, PRs, Actions, releases, and REST/GraphQL APIs with JSON/JQ parsing. Activates on tasks like 'create issue', 'check CI', or GitHub URLs.
Share bugs, ideas, or general feedback.
Provide comprehensive, copy-paste ready instructions for GitHub CLI (gh) installation and usage to prevent common mistakes like missing full paths or forgetting GITHUB_TOKEN environment variable prefix.
gh commandsif [ -f ~/.local/bin/gh ]; then
echo "✅ gh CLI already installed"
~/.local/bin/gh --version
else
echo "gh CLI not found, proceeding with installation..."
fi
# Only install if not already present
if [ ! -f ~/.local/bin/gh ]; then
# Use mktemp for unique temporary directory (CLAUDE.md policy compliance)
TMP_GH_DIR="$(mktemp -d)"
cd "$TMP_GH_DIR"
curl -sL https://github.com/cli/cli/releases/download/v2.40.1/gh_2.40.1_linux_amd64.tar.gz -o gh.tar.gz
tar -xzf gh.tar.gz
mkdir -p ~/.local/bin
cp gh_2.40.1_linux_amd64/bin/gh ~/.local/bin/gh
chmod +x ~/.local/bin/gh
cd - > /dev/null
rm -rf "$TMP_GH_DIR"
fi
~/.local/bin/gh --version
Expected output: gh version 2.40.1 (2023-12-13)
~/.local/bin/gh auth status
Expected output: ✓ Logged in to github.com account <username> (GITHUB_TOKEN)
Note: GitHub CLI automatically uses the GITHUB_TOKEN environment variable - no prefix needed!
~/.local/bin/gh (installed to user bin, not /tmp)--repo jleechanorg/your-project.com for claritygh (it's not in PATH unless you add ~/.local/bin)GITHUB_TOKEN=$GITHUB_TOKEN is unnecessary~/.local/bin/gh auth status
~/.local/bin/gh api rate_limit --jq '.rate | {limit: .limit, remaining: .remaining}'
~/.local/bin/gh repo view jleechanorg/your-project.com
~/.local/bin/gh repo view jleechanorg/your-project.com --json name,owner,isPrivate,defaultBranchRef,description
~/.local/bin/gh api repos/jleechanorg/your-project.com/branches --jq '.[0:10] | .[] | {name: .name, protected: .protected}'
~/.local/bin/gh pr list --repo jleechanorg/your-project.com --state open --limit 10
~/.local/bin/gh pr list --repo jleechanorg/your-project.com --state all --limit 20
~/.local/bin/gh pr view <PR_NUMBER> --repo jleechanorg/your-project.com
~/.local/bin/gh pr view <PR_NUMBER> --repo jleechanorg/your-project.com --json number,title,state,author,createdAt,body
~/.local/bin/gh pr checks <PR_NUMBER> --repo jleechanorg/your-project.com
~/.local/bin/gh pr create --repo jleechanorg/your-project.com --title "PR Title" --body "PR Description"
~/.local/bin/gh pr create --repo jleechanorg/your-project.com --fill
~/.local/bin/gh pr merge <PR_NUMBER> --repo jleechanorg/your-project.com --squash
~/.local/bin/gh api repos/jleechanorg/your-project.com/pulls/<PR_NUMBER>/comments
~/.local/bin/gh issue list --repo jleechanorg/your-project.com --limit 10
~/.local/bin/gh issue list --repo jleechanorg/your-project.com --state open --label bug --limit 10
~/.local/bin/gh issue view <ISSUE_NUMBER> --repo jleechanorg/your-project.com
~/.local/bin/gh issue create --repo jleechanorg/your-project.com --title "Issue Title" --body "Issue Description"
~/.local/bin/gh workflow list --repo jleechanorg/your-project.com
~/.local/bin/gh run list --repo jleechanorg/your-project.com --limit 10
~/.local/bin/gh run list --repo jleechanorg/your-project.com --workflow "Workflow Name" --limit 10
~/.local/bin/gh run view <RUN_ID> --repo jleechanorg/your-project.com
~/.local/bin/gh run watch <RUN_ID> --repo jleechanorg/your-project.com
~/.local/bin/gh label list --repo jleechanorg/your-project.com
~/.local/bin/gh label create "label-name" --repo jleechanorg/your-project.com --description "Label description" --color "ff0000"
~/.local/bin/gh api user --jq '.login'
~/.local/bin/gh api repos/jleechanorg/your-project.com/commits/main --jq '{sha: .sha[0:7], author: .commit.author.name, message: .commit.message | split("\n")[0]}'
~/.local/bin/gh api repos/jleechanorg/your-project.com/collaborators
~/.local/bin/gh api repos/jleechanorg/your-project.com/topics
Cause: Used gh instead of full path
Solution: Always use ~/.local/bin/gh
Cause: GITHUB_TOKEN environment variable not set
Solution: Verify GITHUB_TOKEN is set with echo $GITHUB_TOKEN (should show token value)
Cause: Missing --repo flag or incorrect repo name
Solution: Add --repo jleechanorg/your-project.com to command
Cause: Token lacks required permissions
Solution: Verify token scopes with gh auth status, ensure token has repo scope
Cause: gh CLI not installed yet Solution: Run installation steps from "Installation (One-Time Setup)" section
if [ -f ~/.local/bin/gh ]; then
echo "gh CLI is installed"
else
echo "gh CLI not installed, run installation steps"
fi
PR_NUMBER=$(~/.local/bin/gh pr list --repo jleechanorg/your-project.com --head $(git branch --show-current) --json number --jq '.[0].number')
echo "Current branch PR: #$PR_NUMBER"
PR_EXISTS=$(~/.local/bin/gh pr list --repo jleechanorg/your-project.com --head $(git branch --show-current) --json number --jq 'length')
if [ "$PR_EXISTS" -gt 0 ]; then
echo "PR exists for current branch"
else
echo "No PR for current branch"
fi
~/.local/bin/gh pr view <PR_NUMBER> --repo jleechanorg/your-project.com --json number,title,state,isDraft,mergeable,reviewDecision,statusCheckRollup
~/.local/bin/gh pr list --repo jleechanorg/your-project.com --json number,title --jq '.[] | "\(.number): \(.title)"'
#!/bin/bash
set -e
# Define gh command
GH="~/.local/bin/gh"
REPO="jleechanorg/your-project.com"
# Use in script
$GH pr list --repo $REPO --limit 5
~/.local/bin/gh pr list --repo jleechanorg/your-project.com | grep "OPEN"
gh is in PATH (use ~/.local/bin/gh)GH variable in scripts for reusability# Set up gh command variable for easy reuse
GH="~/.local/bin/gh"
REPO="jleechanorg/your-project.com"
# Now you can use it like this:
$GH pr list --repo $REPO
$GH issue list --repo $REPO
$GH workflow list --repo $REPO
pr-workflow-manager.md - PR creation and management best practicesbuild-test-lint-autopilot.md - Pre-PR validationcloud-ops-credential-guard.md - Token and credential managementWhen using gh CLI, always: