| name | gh-workflows |
| description | Manage GitHub Actions workflows with the gh CLI (list, run, cancel, monitor). |
When to Use
Use this skill whenever you need to inspect, trigger, or stop GitHub Actions workflows. It wraps gh workflow and gh run commands so you can keep CI pipelines healthy without leaving the terminal.
Prerequisites
ghCLI authenticated withgh auth login --scopes repo,workflow. Confirm viagh auth status.jqavailable to pretty-print JSON results.- Environment:
GITHUB_REPOSITORY(owner/name). Ask for it if missing.GITHUB_TOKEN(gh uses it automatically once authenticated).DEFAULT_BRANCH(fallback for manual dispatches; default tomain).
Common Parameters
--repo "$GITHUB_REPOSITORY"is required for every command.--json ... --jq '.'returns machine-friendly payloads.- When scripts provide
workflownames, accept either filename (deploy.yml) or workflow ID.
Procedures
List Workflows (/workflows-list)
- Run:
gh workflow list --repo "$GITHUB_REPOSITORY" --limit ${LIMIT:-20} --json id,name,path,state. - Use
jqto format the response. - Summarize key fields: name, path, state, and id so downstream commands can use them.
List Workflow Runs (/workflows-runs)
- Require a workflow identifier.
- Optional filters:
- Branch:
--branch ${BRANCH}(omit if empty). - Status:
--status ${STATUS:-all}.
- Branch:
- Command:
gh run list --repo "$GITHUB_REPOSITORY" \ --workflow "$WORKFLOW" \ ${BRANCH:+--branch "$BRANCH"} \ --status ${STATUS:-all} \ --limit ${LIMIT:-20} \ --json databaseId,workflowName,displayTitle,headBranch,status,conclusion,createdAt - Pipe to
jq '.'and surface the most recent run id for convenience.
View a Workflow Run (/workflows-view)
- Accept a
run_id(numeric or URL) and optional--logflag. - Command:
gh run view "$RUN_ID" --repo "$GITHUB_REPOSITORY" \ --json databaseId,workflowName,displayTitle,event,headBranch,status,conclusion,logsUrl,htmlUrl - Share the JSON and hyperlink to
logsUrl/htmlUrlfor quick navigation.
Cancel a Run (/workflows-cancel)
- Confirm the run is in
in_progressorqueuedstate (usegh run view). - Command sequence:
gh run cancel "$RUN_ID" --repo "$GITHUB_REPOSITORY" gh run watch "$RUN_ID" --repo "$GITHUB_REPOSITORY" --exit-status || true - Report the final status (cancelled/completed). If already finished, note that cancellation was skipped.
Trigger a Workflow (/workflows-trigger)
- Require workflow file/ID plus ref/branch.
- Compose inputs:
EXTRA_INPUTS=${INPUTS_JSON:+--inputs "$INPUTS_JSON"} gh workflow run "$WORKFLOW" --repo "$GITHUB_REPOSITORY" --ref "${REF:-${BRANCH:-$DEFAULT_BRANCH}}" $EXTRA_INPUTS - Capture the run id from gh output and share it for monitoring.
Monitor a Run (/workflows-monitor)
- Command:
gh run watch "$RUN_ID" --repo "$GITHUB_REPOSITORY" --exit-status. - Stream output back. At completion, annotate whether the run concluded with success, failure, or cancellation.
Safety Checks
- Never cancel or rerun workflows outside the configured repo.
- If a command fails due to missing repo/ref, prompt the user for the missing data before retrying.
- Treat manual dispatch inputs carefully—validate JSON before passing
--inputs.