github
npx machina-cli add skill IvanCampos/agents/github --openclawGitHub CLI
Overview
Use gh for day-to-day GitHub operations from the terminal. Prefer read-only commands first, then run mutating commands only after clear user intent.
Quick Start
- Check installation and auth:
gh --version
gh auth status
- Establish repository context:
scripts/gh_preflight.sh --repo owner/repo
- If not in the target repository, pass
-R owner/repoto commands. - Use
--jsonwith--jqor--templatefor automation-friendly output.
Workflow
- Establish context first.
- Determine GitHub host (
github.comby default), repository, and branch. - Run
scripts/gh_preflight.shbefore multi-step operations.
- Read current state.
- Use
list,view, andstatussubcommands before changing anything.
- Apply requested mutation.
- For create/edit/merge/delete actions, restate the operation and require explicit confirmation unless the user already asked clearly.
- Report stable identifiers.
- Return URLs and IDs for created or changed objects (PR number, issue number, run URL, release tag).
Common Commands
- Repository:
gh repo viewgh repo clone owner/repogh repo creategh repo set-default owner/repo
- Pull requests:
gh pr listgh pr view <number>gh pr checkout <number>gh pr creategh pr review <number> --approve|--request-changes|--commentgh pr merge <number>
- Issues:
gh issue listgh issue view <number>gh issue creategh issue comment <number> --body "..."gh issue close <number>
- Actions:
gh workflow listgh workflow run <workflow>gh run listgh run watch <run-id>gh run view <run-id> --log
- Releases:
gh release listgh release view <tag>gh release create <tag> [assets...]gh release upload <tag> <file>
- API:
gh api repos/{owner}/{repo}/pulls --paginate
For broader command coverage, read references/command-map.md.
Safety Defaults
- Confirm before commands that change remote state:
gh pr create|merge|close|reopen|readygh issue create|edit|close|reopen|deletegh repo create|edit|archive|deletegh release create|edit|deletegh secret set|deletegh variable set|deletegh workflow run
- Avoid destructive flags (
--delete-branch, force flags) unless explicitly requested. - Show exact command before bulk updates and prefer smallest safe scope.
Structured Output
Use JSON output when parsing or summarizing results:
gh pr list --json number,title,url --jq '.[] | "\(.number)\t\(.title)\t\(.url)"'
gh issue list --json number,title,labels --template '{{range .}}{{printf "#%v %v\n" .number .title}}{{end}}'
Troubleshooting
- Auth errors:
gh auth loginorgh auth refresh. - Wrong account/host:
gh auth status --hostname github.com, thengh auth switch. - Unknown command options:
gh <command> <subcommand> --help. - Manual reference:
https://cli.github.com/manual/.
Resources
scripts/
scripts/gh_preflight.sh: Checkghavailability, auth status, and repository context.
references/
references/command-map.md: Command map for repo, PR, issue, actions, release, and API operations.
Overview
Use gh for day-to-day GitHub operations from the terminal, including repositories, pull requests, issues, workflows, releases, and API calls. Start with read-only commands to understand state, then run mutating actions only when the user has clear intent.
How This Skill Works
The skill guides you through gh commands after establishing repository context (host, repo, and branch) with a preflight script (scripts/gh_preflight.sh). It encourages reading current state with view/list/status commands before mutating, and promotes automation-friendly output using --json, --jq, or templates to surface IDs and URLs for created or updated objects.
When to Use It
- When asked to use the GitHub CLI (gh) for repo, PR, issue, workflow, or release tasks.
- When you need to run GitHub Actions workflows or trigger runs from the shell.
- When you want to automate data extraction with JSON output (--json) for scripting.
- When troubleshooting gh authentication, host, or configuration issues.
- When you need to establish repository context and safety checks before changes (read-only first).
Quick Start
- Step 1: Check installation and auth: gh --version; gh auth status.
- Step 2: Establish repository context: scripts/gh_preflight.sh --repo owner/repo.
- Step 3: If not in the target repository, pass -R owner/repo to commands.
Best Practices
- Start with read-only commands (list/view/status) before mutating actions.
- Always establish repository context first with the preflight script (scripts/gh_preflight.sh).
- Confirm before commands that change remote state unless explicit user intent is clear.
- Use --json with --jq or --template to produce automation-friendly output.
- Return stable identifiers (URLs and object numbers) for created or changed items.
Example Use Cases
- gh repo view; gh pr list; gh issue view <num> to survey a project.
- gh pr create to open a PR, then gh pr review <num> --approve or --comment.
- gh workflow list and gh workflow run <workflow> to trigger CI from shell.
- gh release list; gh release view <tag>; gh release create <tag> [assets...] to publish a release.
- gh api repos/{owner}/{repo}/pulls --paginate to fetch open pull requests programmatically.