# Gh CI Pr

> Use GitHub CLI to (1) create/switch branches, (2) create PRs with good descriptions, (3) scan GitHub Actions CI runs for a branch, and (4) if CI fails, open a fix PR that targets the failing base branch (not master).

- Skill: `alirana01/gh-ci-pr` (Agent Skill, multi-file: 4 files)
- Install (CLI): `npx skillmds@latest add alirana01/gh-ci-pr`
- Raw SKILL.md: https://api.skillmd.com/api/skills/alirana01/gh-ci-pr/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: alirana01 (https://skillmd.com/u/alirana01)
- Updated: 2026-09-22
- Page: https://skillmd.com/skills/alirana01/gh-ci-pr

---


# gh-ci-pr Skill

This skill automates PR creation and CI visibility using `gh`.

## When to use
- When you want Cursor to create a branch + PR with a proper task description.
- When CI runs are not visible in the editor and you want them fetched via `gh`.
- When CI fails and you want a "fix PR" that targets the same branch where the failure happened (NOT master/main).

## Key rules / guarantees
- **Never targets `master`/`main` unless the failure happened there.**
- A fix PR is created from the **exact failing commit SHA** and targets the **same failing branch**.
- Uses `gh run list/view` and `gh api` only (no web scraping).

## Inputs (ask user if missing)
- Repo (optional; defaults to current git remote)
- Base branch to scan (e.g. `release/v5.4`, `develop`, `feature/foo`)
- Optional: workflow name filter (if repo has many)
- Short task summary for PR body (ticket links, bullet points)

## Workflow
1. Scan CI runs for the chosen branch.
2. If latest run is success: optionally create PR for current branch changes.
3. If latest run is failure:
   - Identify failing run + failing commit SHA
   - Create fix branch from that SHA: `ci-fix/<branch>/<run_id>`
   - Attempt local reproduction (run project tests/linters if known)
   - Commit fixes
   - Push fix branch
   - Open PR: **base = failing branch**, head = fix branch
   - PR body includes run link, failure summary, and what changed.

## Scripts
- `scripts/ci_scan.sh <branch> [limit]`
- `scripts/fix_from_failure.sh <branch> [limit]`
- `scripts/pr_create.sh <base_branch> <head_branch> <title> <body_file>`

