| name | gh-cli-ops |
| description | GitHub CLI (gh) operations for repos, PRs/issues, workflows/runs, secrets/variables, releases/tags, and deployment-related automation. Use when a request involves gh commands, GitHub Actions workflows/runs, secrets or variables, releases, deployments/environments, or coordinating git with GitHub. |
Gh Cli Ops
Overview
Use gh + git to manage GitHub repositories, automation, and releases with repeatable, safe workflows.
Quick start (context)
- Use the wrapper so commands are logged:
scripts/ghx auth status,scripts/ghx repo view,git status -sb. - Identify the task category and use the matching section or the command map in
references/gh-command-map.md. - Prefer JSON output (
--json ... --jq ...) for scripted reads; ask before destructive changes (delete, merge, release delete, secret overwrite). - Review
references/auto-summary.mdto adapt based on recent successes/failures.
Automation wrapper (required)
- Use
scripts/ghxfor all gh commands to log outcomes toreferences/usage-log.jsonl. - The wrapper auto-updates
references/auto-summary.mdafter each command to capture what worked or failed. - If you must run
ghdirectly (e.g., debugging), runscripts/track_command.sh gh ...afterward with the same args.
Task map
See references/gh-command-map.md for a task-to-command mapping and safe defaults.
Workflows & runs
- Use
gh workflow list/view/runto inspect or trigger workflows. Ensure the workflow supportson: workflow_dispatchbefore running. - Provide inputs via
-f/-For--jsonwhen needed; confirm expected inputs from the workflow file. - Use
gh run list/view/watch/rerun/downloadto monitor or re-run jobs; usegh run view --log/--log-failedfor logs. - For deploys, identify the deploy workflow and trigger it via
gh workflow runwith the correct--refand inputs. - If
gh workflow runfails withHTTP 403andResource not accessible by integration, check forGITHUB_TOKENorGH_TOKENin the environment. Unset them or replace with a PAT that has workflow permissions, then retry. - Quick fix for local shells:
GITHUB_TOKEN= gh workflow run "<workflow>" -f key=value(clears the env var for that command). - In GitHub Actions, prefer
GH_TOKENset to a PAT or GitHub App token when you need to trigger workflows; the defaultGITHUB_TOKENcan be too limited for dispatching other workflows.
Secrets & variables
- Use
gh secretfor Actions/Dependabot/Codespaces secrets; usegh variablefor Actions/Dependabot variables. - Scope to repo/org/environment as needed; check
gh secret set --helpandgh variable set --helpfor scope flags. - Prefer stdin or
--bodyto avoid shell history; confirm overwrite and scope with the user.
Releases & tags
- Use
gh release list/view/create/download/delete. - Prefer
--generate-notesfor release notes when appropriate; confirm tag names and target commits.
Deployments & environments
- For deployment environments, use environment-scoped secrets/variables (
-e <env>). - For deployment history or custom deploy APIs, use
gh apiwith--paginateand--jqas needed.
PRs, issues, and repo admin
- Use
gh prandgh issuefor everyday collaboration. - Use
gh repo view/fork/clone/syncfor repo operations. - Keep git operations (branching, rebasing, pushing) explicit and separate from gh steps.
API & advanced
- Use
gh apifor endpoints not covered by built-in commands. - Capture JSON with
gh api ... --jqor--paginatefor large lists.
Troubleshooting auth
Resource not accessible by integrationusually means the CLI is using an integration token (oftenGITHUB_TOKEN) that cannot dispatch workflows. Prefer a PAT stored viagh auth login --with-tokenor setGH_TOKENto a PAT with workflow permissions; avoid leavingGITHUB_TOKENexported in local shells.GH_TOKEN/GITHUB_TOKENenvironment variables override stored gh auth. If you see unexpected 403s, unset them or replace with a PAT/GitHub App token that has Actions/workflow permissions before retrying.
Self-improving loop (automated + manual)
Automated (always on when using scripts/ghx):
- Command outcomes are logged to
references/usage-log.jsonl. scripts/auto_improve.pyupdatesreferences/auto-summary.mdand can append repeatable learnings toreferences/gh-ops-notes.md.
Manual (when new patterns are discovered):
- Append new command patterns, flags, or pitfalls to
references/gh-ops-notes.md. - If a command/flag is missing or changed, update
references/gh-command-map.md. - Run
scripts/refresh_gh_reference.shto refreshreferences/gh-help.mdfrom the locally installedgh.
Resources
scripts/
scripts/ghx: wrapper that logs gh command outcomes and triggers auto-summary updates.scripts/track_command.sh: logs command outcomes toreferences/usage-log.jsonl.scripts/auto_improve.py: generatesreferences/auto-summary.mdand auto-notes.scripts/refresh_gh_reference.sh: regeneratereferences/gh-help.mdfrom local gh help output.
references/
references/gh-command-map.md: task-to-command map and safe defaults.references/gh-help.md: auto-generated help snapshot from the local gh version.references/gh-ops-notes.md: living notes for patterns, pitfalls, and team conventions.references/auto-summary.md: auto-generated success/failure summary for recent commands.references/usage-log.jsonl: append-only command log (redacted).