| name | github-cli-helper |
| description | Execute GitHub CLI commands using the correct Homebrew path. Use when interacting with GitHub PRs, issues, repos, or any gh command. |
GitHub CLI Helper
Instructions
Always use the full Homebrew path when executing GitHub CLI commands to ensure reliability across different shell environments.
IMPORTANT: Use /opt/homebrew/bin/gh instead of just gh for all GitHub CLI operations.
Common Operations
Pull Requests
/opt/homebrew/bin/gh pr create --base main --title "Title" --body "Description"
/opt/homebrew/bin/gh pr list
/opt/homebrew/bin/gh pr view <number>
/opt/homebrew/bin/gh pr status
/opt/homebrew/bin/gh pr merge <number>
/opt/homebrew/bin/gh pr close <number>
/opt/homebrew/bin/gh pr review <number>
Issues
/opt/homebrew/bin/gh issue create --title "Title" --body "Description"
/opt/homebrew/bin/gh issue list
/opt/homebrew/bin/gh issue view <number>
/opt/homebrew/bin/gh issue close <number>
Repository Operations
/opt/homebrew/bin/gh repo clone <owner>/<repo>
/opt/homebrew/bin/gh repo view
/opt/homebrew/bin/gh repo create <name>
/opt/homebrew/bin/gh repo fork
Workflow & Actions
/opt/homebrew/bin/gh run list
/opt/homebrew/bin/gh run view <run-id>
/opt/homebrew/bin/gh run rerun <run-id>
Authentication & Configuration
/opt/homebrew/bin/gh auth status
/opt/homebrew/bin/gh auth login
/opt/homebrew/bin/gh repo set-default
Best Practices
- Always use full path:
/opt/homebrew/bin/gh not gh
- Check authentication first: Run
/opt/homebrew/bin/gh auth status before operations
- Use heredocs for multi-line content: When creating PRs or issues with complex bodies
- Leverage JSON output: Use
--json flag for programmatic processing
- Handle errors gracefully: Check exit codes and provide helpful error messages
Examples
Create PR with detailed body
/opt/homebrew/bin/gh pr create \
--base main \
--title "feat: add new feature" \
--body "$(cat <<'EOF'
## Description
Detailed description here
## Changes
- Change 1
- Change 2
EOF
)"
List PRs in JSON format
/opt/homebrew/bin/gh pr list --json number,title,state,author
Create issue with labels
/opt/homebrew/bin/gh issue create \
--title "Bug: Something is broken" \
--body "Description of the bug" \
--label bug,priority-high
Comment on a PR
/opt/homebrew/bin/gh pr comment 123 --body "Thanks for the contribution!"
Troubleshooting
Command not found
If /opt/homebrew/bin/gh doesn't exist, check alternative locations:
/usr/local/bin/gh (Intel Macs)
- Use
which gh to find the actual location
Authentication errors
Run /opt/homebrew/bin/gh auth login and ensure repo scope is granted.
Enterprise GitHub
Set the GH_HOST environment variable:
export GH_HOST=github.company.com
/opt/homebrew/bin/gh pr list
Tips
- Use
--help flag to see all available options for any command
- Combine with
jq for advanced JSON processing
- Use
--web flag to open resources in browser
- Set aliases in shell config for frequently used commands