github-cli-reference
Complete reference for GitHub CLI (gh) installation, authentication, and usage in Claude Code environment
What this skill does
# GitHub CLI Reference
## Purpose
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.
## Activation cues
- Requests to use GitHub CLI or `gh` commands
- Questions about GitHub API, PRs, issues, workflows
- Pull request operations (list, view, create, merge)
- GitHub repository queries
- Workflow run checks
- GitHub API operations
- Authentication errors or "command not found" errors
## Installation (One-Time Setup)
### Step 0: Check if Already Installed
```bash
if [ -f ~/.local/bin/gh ]; then
echo "✅ gh CLI already installed"
~/.local/bin/gh --version
else
echo "gh CLI not found, proceeding with installation..."
fi
```
### Step 1: Download and Extract (Complies with TEMPORARY FILE ISOLATION)
```bash
# 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
```
### Step 2: Verify Installation
```bash
~/.local/bin/gh --version
```
**Expected output**: `gh version 2.40.1 (2023-12-13)`
### Step 3: Test Authentication
```bash
~/.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!
## Critical Usage Rules
### ✅ ALWAYS Do This:
1. **Use full path**: `~/.local/bin/gh` (installed to user bin, not /tmp)
2. **GITHUB_TOKEN automatic**: No prefix needed - gh automatically uses environment variable
3. **Specify repo**: Add `--repo jleechanorg/worldarchitect.ai` for clarity
### ❌ NEVER Do This:
1. **Don't use**: Just `gh` (it's not in PATH unless you add ~/.local/bin)
2. **Don't use /tmp**: Install to ~/.local/bin to comply with TEMPORARY FILE ISOLATION policy
3. **Don't add redundant prefix**: `GITHUB_TOKEN=$GITHUB_TOKEN` is unnecessary
## Command Reference
### Authentication & Status
#### Check auth status
```bash
~/.local/bin/gh auth status
```
#### Check API rate limit
```bash
~/.local/bin/gh api rate_limit --jq '.rate | {limit: .limit, remaining: .remaining}'
```
### Repository Operations
#### View repository info
```bash
~/.local/bin/gh repo view jleechanorg/worldarchitect.ai
```
#### View repository info (JSON)
```bash
~/.local/bin/gh repo view jleechanorg/worldarchitect.ai --json name,owner,isPrivate,defaultBranchRef,description
```
#### List branches
```bash
~/.local/bin/gh api repos/jleechanorg/worldarchitect.ai/branches --jq '.[0:10] | .[] | {name: .name, protected: .protected}'
```
### Pull Request Operations
#### List open PRs
```bash
~/.local/bin/gh pr list --repo jleechanorg/worldarchitect.ai --state open --limit 10
```
#### List all PRs (including closed)
```bash
~/.local/bin/gh pr list --repo jleechanorg/worldarchitect.ai --state all --limit 20
```
#### View specific PR
```bash
~/.local/bin/gh pr view <PR_NUMBER> --repo jleechanorg/worldarchitect.ai
```
#### View PR with JSON output
```bash
~/.local/bin/gh pr view <PR_NUMBER> --repo jleechanorg/worldarchitect.ai --json number,title,state,author,createdAt,body
```
#### View PR checks/status
```bash
~/.local/bin/gh pr checks <PR_NUMBER> --repo jleechanorg/worldarchitect.ai
```
#### Create PR
```bash
~/.local/bin/gh pr create --repo jleechanorg/worldarchitect.ai --title "PR Title" --body "PR Description"
```
#### Create PR (interactive)
```bash
~/.local/bin/gh pr create --repo jleechanorg/worldarchitect.ai --fill
```
#### Merge PR
```bash
~/.local/bin/gh pr merge <PR_NUMBER> --repo jleechanorg/worldarchitect.ai --squash
```
#### View PR comments
```bash
~/.local/bin/gh api repos/jleechanorg/worldarchitect.ai/pulls/<PR_NUMBER>/comments
```
### Issue Operations
#### List issues
```bash
~/.local/bin/gh issue list --repo jleechanorg/worldarchitect.ai --limit 10
```
#### List open issues with labels
```bash
~/.local/bin/gh issue list --repo jleechanorg/worldarchitect.ai --state open --label bug --limit 10
```
#### View specific issue
```bash
~/.local/bin/gh issue view <ISSUE_NUMBER> --repo jleechanorg/worldarchitect.ai
```
#### Create issue
```bash
~/.local/bin/gh issue create --repo jleechanorg/worldarchitect.ai --title "Issue Title" --body "Issue Description"
```
### Workflow Operations
#### List workflows
```bash
~/.local/bin/gh workflow list --repo jleechanorg/worldarchitect.ai
```
#### List workflow runs
```bash
~/.local/bin/gh run list --repo jleechanorg/worldarchitect.ai --limit 10
```
#### List workflow runs for specific workflow
```bash
~/.local/bin/gh run list --repo jleechanorg/worldarchitect.ai --workflow "Workflow Name" --limit 10
```
#### View workflow run details
```bash
~/.local/bin/gh run view <RUN_ID> --repo jleechanorg/worldarchitect.ai
```
#### Watch workflow run
```bash
~/.local/bin/gh run watch <RUN_ID> --repo jleechanorg/worldarchitect.ai
```
### Label Operations
#### List labels
```bash
~/.local/bin/gh label list --repo jleechanorg/worldarchitect.ai
```
#### Create label
```bash
~/.local/bin/gh label create "label-name" --repo jleechanorg/worldarchitect.ai --description "Label description" --color "ff0000"
```
### GitHub API Direct Access
#### Get user info
```bash
~/.local/bin/gh api user --jq '.login'
```
#### Get latest commit on main
```bash
~/.local/bin/gh api repos/jleechanorg/worldarchitect.ai/commits/main --jq '{sha: .sha[0:7], author: .commit.author.name, message: .commit.message | split("\n")[0]}'
```
#### Get repository collaborators
```bash
~/.local/bin/gh api repos/jleechanorg/worldarchitect.ai/collaborators
```
#### Get repository topics
```bash
~/.local/bin/gh api repos/jleechanorg/worldarchitect.ai/topics
```
## Troubleshooting
### Error: "command not found: gh"
**Cause**: Used `gh` instead of full path
**Solution**: Always use `~/.local/bin/gh`
### Error: "You are not logged into any GitHub hosts"
**Cause**: `GITHUB_TOKEN` environment variable not set
**Solution**: Verify `GITHUB_TOKEN` is set with `echo $GITHUB_TOKEN` (should show token value)
### Error: "HTTP 404: Not Found"
**Cause**: Missing `--repo` flag or incorrect repo name
**Solution**: Add `--repo jleechanorg/worldarchitect.ai` to command
### Error: "Resource not accessible by integration"
**Cause**: Token lacks required permissions
**Solution**: Verify token scopes with `gh auth status`, ensure token has `repo` scope
### Binary not found: "~/.local/bin/gh"
**Cause**: gh CLI not installed yet
**Solution**: Run installation steps from "Installation (One-Time Setup)" section
## Advanced Patterns
### Check if gh is installed
```bash
if [ -f ~/.local/bin/gh ]; then
echo "gh CLI is installed"
else
echo "gh CLI not installed, run installation steps"
fi
```
### Get PR number from current branch
```bash
PR_NUMBER=$(~/.local/bin/gh pr list --repo jleechanorg/worldarchitect.ai --head $(git branch --show-current) --json number --jq '.[0].number')
echo "Current branch PR: #$PR_NUMBER"
```
### Check if PR exists for current branch
```bash
PR_EXISTS=$(~/.local/bin/gh pr list --repo jleechanorg/worldarchitect.ai --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
```
### Get PR status with detailed info
```bash
~/.local/bin/gh pr view <PR_NUMBER> --repo jleechanorg/worldarchitect.ai --json number,title,state,isDraft,mergeable,reviewDecision,statusCheckRollup
```
## Environment Variables
### GITHUB_TOKEN
- **Purpose**: Authentication token for GitHub API
- **Set automatically**: AvailableRelated in AI Agents
skill-development
IncludedComprehensive meta-skill for creating, managing, validating, auditing, and distributing Claude Code skills and slash commands (unified in v2.1.3+). Provides skill templates, creation workflows, validation patterns, audit checklists, naming conventions, YAML frontmatter guidance, progressive disclosure examples, and best practices lookup. Use when creating new skills, validating existing skills, auditing skill quality, understanding skill architecture, needing skill templates, learning about YAML frontmatter requirements, progressive disclosure patterns, tool restrictions (allowed-tools), skill composition, skill naming conventions, troubleshooting skill activation issues, creating custom slash commands, configuring command frontmatter, using command arguments ($ARGUMENTS, $1, $2), bash execution in commands, file references in commands, command namespacing, plugin commands, MCP slash commands, Skill tool configuration, or deciding between skills vs slash commands. Delegates to docs-management skill for official documentation.
reprompter
IncludedTransform messy prompts into well-structured, effective prompts — single or multi-agent. Use when: "reprompt", "reprompt this", "clean up this prompt", "structure my prompt", rough text needing XML tags and best practices, "reprompter teams", "repromptception", "run with quality", "smart run", "smart agents", multi-agent tasks, audits, parallel work, anything going to agent teams. Don't use when: simple Q&A, pure chat, immediate execution-only tasks. See "Don't Use When" section for details. Outputs: Structured XML/Markdown prompt, quality score (before/after), optional team brief + per-agent sub-prompts, agent team output files. Success criteria: Single mode quality score ≥ 7/10; Repromptception per-agent prompt quality score 8+/10; all required sections present, actionable and specific.
adaptive-compaction
IncludedAdaptive add-on policy and recovery layer that decides WHEN to compact, prune, snapshot, or fork -- replacing fixed-percent auto-compaction across Claude Code, Codex, and MCP-capable hosts. Trigger on auto-compact timing or damage: "when should I compact", "is it safe to compact now or start a fresh session", "auto-compact fires too early/mid-task", "switching to an unrelated task but the window still has space", "context rot", "answers get worse the longer the session runs", "the agent forgot the plan or my decisions after it summarized", "add a layer on top that manages context without changing the agent", raising autoCompactWindow to give the policy room, or installing/tuning a cross-tool compaction policy or PreCompact hook -- even when "compaction" is never said but the problem is context-window pressure or post-summarization memory loss. Do NOT use to summarize a conversation, build RAG, write a summarization prompt (decides WHEN not HOW), or answer max-context-length trivia.
agent-skill-creator
IncludedCreate cross-platform agent skills from workflow descriptions. Activates when users ask to create an agent, automate a repetitive workflow, create a custom skill, or need advanced agent creation. Triggers on phrases like create agent for, automate workflow, create skill for, every day I have to, daily I need to, turn process into agent, need to automate, create a cross-platform skill, validate this skill, export this skill, migrate this skill. Supports single skills, multi-agent suites, transcript processing, template-based creation, interactive configuration, cross-platform export, and spec validation.
llm-wiki
IncludedUse when building or maintaining a persistent personal knowledge base (second brain) in Obsidian where an LLM incrementally ingests sources, updates entity/concept pages, maintains cross-references, and keeps a synthesis current. Triggers include "second brain", "Obsidian wiki", "personal knowledge management", "ingest this paper/article/book", "build a research wiki", "compound knowledge", "Memex", or whenever the user wants knowledge to accumulate across sessions instead of being re-derived by RAG on every query.
skill-master
IncludedAgent Skills authoring, evaluation, and optimization. Create, edit, validate, benchmark, and improve skills following the agentskills.io specification. Use when designing SKILL.md files, structuring skill folders (references, scripts, assets), ingesting external documentation into skills, running trigger evals, benchmarking skill quality, optimizing descriptions, or performing blind A/B comparisons. Keywords: agentskills.io, SKILL.md, skill authoring, eval, benchmark, trigger optimization.